在Visual Studio 2017中使用CUDA [英] Using CUDA with Visual Studio 2017
问题描述
我正在尝试安装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?
推荐答案
- 如果要使用
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
下.
- If you want to install
CUDA 8.0
withVisual 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
OpenIndividual components
tab and selectVC++ 2015.3 v140 toolset
underCompilers, build tools and runtimes
.
- 如果尚未安装
.NET Framework 3.5
,则还需要安装.
Nvda.Build.CudaTasks.v8.0.dll
程序集依赖于MS .NET Framework 3.5 .
- 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.
- 下载完整的
CUDA toolkit
发行版并将其提取到磁盘上的某个位置. - 如果尚未安装
CUDA toolkit
,请立即执行.如果仅安装了Visual Studio 2017
,请取消选择Visual Studio integration
复选框.
- Download full
CUDA toolkit
distribution and extract it somewhere on your disk. - If you didn't have
CUDA toolkit
installed, do it now. If you have onlyVisual Studio 2017
installed, unselectVisual 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.
- 转到提取的发行版中的
CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions
文件夹,复制所有文件并将其粘贴到
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\BuildCustomizations:
- 在最后一步,您将需要编辑
Cuda
项目,以识别Visual Studio 2017
中NVidia的构建任务.在文本编辑器中打开您的.vcxproj
文件,找到所有出现的CUDA 8.0.props
.用$(VCTargetsPath14)
替换字符串开头的宏,以便XML片段如下所示:
- In the last step, you will need to edit your
Cuda
projects to recognize NVidia's build tasks fromVisual Studio 2017
. Open your.vcxproj
file in a text editor and find all occurrences ofCUDA 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屋!