在 Visual Studio 2017 中使用 CUDA [英] Using CUDA with Visual Studio 2017

查看:108
本文介绍了在 Visual Studio 2017 中使用 CUDA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装 CUDA,但收到一条消息,提示找不到支持的 Visual Studio 版本".我认为这是因为我使用的是 Visual Studio 2017(社区),而 CUDA 目前最多只支持 Visual Studio 2015.不幸的是,Microsoft 不允许我在不支付订阅费的情况下下载旧版本的 Visual Studio.

有没有办法解决与 VS 2017 的兼容性问题,或者我可以不使用 CUDA?

解决方案

  1. 如果要安装带有 Visual Studio 2017CUDA 8.0,则需要为 Visual Studio 2017 安装其他组件.

    单击开始"菜单并键入 Visual Studio 安装程序.打开 Visual Studio 安装程序

    打开 Individual components 选项卡并选择 VC++ 2015.3 v140 工具集
    编译器、构建工具和运行时下.

  1. 如果您尚未安装 .NET Framework 3.5,则还需要安装它.
    Nvda.Build.CudaTasks.v8.0.dll 程序集

    1. 下载完整的 CUDA 工具包 发行版并将其解压缩到磁盘上的某个位置.
    2. 如果您没有安装 CUDA 工具包,请立即安装.如果您只安装了 Visual Studio 2017,请取消选中 Visual Studio 集成 复选框.


    现在您希望收到 找不到支持的 Visual Studio 版本" 错误.

    但是为了在 Visual Studio 2017 中成功构建 Cuda 工具包项目,您还需要按照步骤 5 和 6 进行操作.

    1. 转到CUDAVisualStudioIntegrationextrasvisual_studio_integrationMSBuildExtensions
      解压发行版中的文件夹,复制所有文件并将它们粘贴到
      C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140BuildCustomizations:

    1. 在最后一步中,您需要编辑您的 Cuda 项目,以识别来自 Visual Studio 2017 的 NVidia 构建任务.在文本编辑器中打开 .vcxproj 文件,找到所有出现的 CUDA 8.0.props.用 $(VCTargetsPath14) 替换字符串开头的宏,以便 XML 片段如下所示:

    <块引用>

    <Import Project="$(VCTargetsPath14)BuildCustomizationsCUDA 8.0.props"/></ImportGroup>

    不要忘记编辑文件末尾的自定义目标路径:

    <块引用>

    <Import Project="$(VCTargetsPath14)BuildCustomizationsCUDA 8.0.targets"/></ImportGroup>



    请务必仔细检查您的路径配置!
    如果您在命令提示符下使用 nvcc,您可能不会从 Visual Studio 文件夹中调用 cl.exe



    现在您可以从 Visual Studio 2017 构建您的 Cuda 项目.

    此解决方案的部分内容来自 奥列格·塔拉索夫的博客.

    I'm trying to install CUDA, but I get a message saying "No supported version of visual studio was found". I think that this is because I am using Visual Studio 2017 (Community), and CUDA currently only supports up to Visual Studio 2015. Unfortunately, Microsoft will not allow me to download old versions of Visual Studio without paying a subscription fee.

    Is there a way I can get around the compatibility issue with VS 2017, or can I not use CUDA?

    解决方案

    1. If you want to install CUDA 8.0 with Visual Studio 2017 you need to install additional components for Visual Studio 2017.

      Click on the Start Menu and type Visual Studio Installer. Open Visual Studio Installer

      Open Individual components tab and select VC++ 2015.3 v140 toolset
      under Compilers, build tools and runtimes.

    1. You also need to install .NET Framework 3.5 if you didn't have it installed.
      Nvda.Build.CudaTasks.v8.0.dll assembly dependents on MS .NET Framework 3.5.

    Open Classical Control Panel, go to Programs and features
    and press Turn Windows features on or off. Check .NET Framework 3.5 and press OK.

    1. Download full CUDA toolkit distribution and extract it somewhere on your disk.
    2. If you didn't have CUDA toolkit installed, do it now. If you have only Visual Studio 2017 installed, unselect Visual Studio integration checkbox.


    Now you want to receive the "No supported version of the visual studio was found" error.

    But in order to successfully build Cuda toolkit projects in Visual Studio 2017, you also need to follow steps 5 and 6.

    1. Go to the CUDAVisualStudioIntegrationextrasvisual_studio_integrationMSBuildExtensions
      folder in your extracted distribution, copy all the files and paste them to
      C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140BuildCustomizations:

    1. In the last step, you will need to edit your Cuda projects to recognize NVidia's build tasks from Visual Studio 2017. Open your .vcxproj file in a text editor and find all occurrences of CUDA 8.0.props. Replace the macro at the beginning of the string with $(VCTargetsPath14) so that XML snippet would look as follows:

    <ImportGroup Label="ExtensionSettings"> <Import Project="$(VCTargetsPath14)BuildCustomizationsCUDA 8.0.props" /></ImportGroup>

    Don't forget to edit the custom targets path at the end of the file:

    <ImportGroup Label="ExtensionTargets"> <Import Project="$(VCTargetsPath14)BuildCustomizationsCUDA 8.0.targets" /></ImportGroup>



    Make sure to double check your path conifuration!
    If you use nvcc from command prompt you might not be calling cl.exe from Visual Studio folder!



    Now you can build your Cuda project from Visual Studio 2017.

    Parts of this solution are from Oleg Tarasov blog.

    这篇关于在 Visual Studio 2017 中使用 CUDA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆