在 Visual Studio 2017 中使用 CUDA [英] Using CUDA with Visual Studio 2017
问题描述
我正在尝试安装 CUDA,但收到一条消息,提示找不到支持的 Visual Studio 版本".我认为这是因为我使用的是 Visual Studio 2017(社区),而 CUDA 目前最多只支持 Visual Studio 2015.不幸的是,Microsoft 不允许我在不支付订阅费的情况下下载旧版本的 Visual Studio.
有没有办法解决与 VS 2017 的兼容性问题,或者我可以不使用 CUDA?
- 如果要安装带有
Visual Studio 2017
的CUDA 8.0
,则需要为 Visual Studio 2017 安装其他组件.
单击开始"菜单并键入 Visual Studio 安装程序.打开 Visual Studio 安装程序
打开Individual components
选项卡并选择VC++ 2015.3 v140 工具集
在编译器、构建工具和运行时
下.
- 如果您尚未安装
.NET Framework 3.5
,则还需要安装它.
Nvda.Build.CudaTasks.v8.0.dll代码> 程序集
- 下载完整的
CUDA 工具包
发行版并将其解压缩到磁盘上的某个位置. - 如果您没有安装
CUDA 工具包
,请立即安装.如果您只安装了Visual Studio 2017
,请取消选中Visual Studio 集成
复选框.
现在您希望收到找不到支持的 Visual Studio 版本"
错误.但是为了在
Visual Studio 2017
中成功构建 Cuda 工具包项目,您还需要按照步骤 5 和 6 进行操作.- 转到
CUDAVisualStudioIntegrationextrasvisual_studio_integrationMSBuildExtensions
解压发行版中的文件夹,复制所有文件并将它们粘贴到
C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140BuildCustomizations:
- 在最后一步中,您需要编辑您的
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?
解决方案- 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
.
- 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 pressTurn Windows features on or off
. Check .NET Framework 3.5 and press OK.- 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.
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.- 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:
- 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)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 usenvcc
from command prompt you might not be callingcl.exe
fromVisual 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屋!
- 下载完整的