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

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

问题描述

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

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.

是否可以解决VS 2017的兼容性问题,还是不能使用CUDA?

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

推荐答案

  1. 如果要使用Visual Studio 2017安装CUDA 8.0,则需要安装Visual Studio 2017的其他组件.

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

    打开Individual components选项卡,然后选择VC++ 2015.3 v140 toolset
    Compilers, build tools and runtimes下.
  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. 如果尚未安装.NET Framework 3.5,则还需要安装.
    Nvda.Build.CudaTasks.v8.0.dll程序集依赖于MS .NET Framework 3.5 .
  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.

打开Classical Control Panel,转到Programs and features
,然后按Turn Windows features on or off.检查.NET Framework 3.5,然后按OK.

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. 下载完整的CUDA toolkit发行版并将其提取到磁盘上的某个位置.
  2. 如果尚未安装CUDA toolkit,请立即执行.如果仅安装了Visual Studio 2017,请取消选择Visual Studio integration复选框.
  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.


现在,您希望收到 "No supported version of the visual studio was found" 错误.


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

但是要成功在Visual Studio 2017中构建Cuda工具包项目,您还需要执行步骤5和6.

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

  1. 转到提取的发行版中的CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions
    文件夹,复制所有文件并将其粘贴到
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\BuildCustomizations:

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

<ImportGroup Label="ExtensionSettings"> <Import Project="$(VCTargetsPath14)\BuildCustomizations\CUDA 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)\BuildCustomizations\CUDA 8.0.targets" /></ImportGroup>

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



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





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!



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

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

此解决方案的部分来自 Oleg Tarasov博客.

Parts of this solution are from Oleg Tarasov blog.

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

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