Visual Studio 2017 出现 CUDA 9 不支持错误

2022-01-10 00:00:00 visual-studio cuda c++

我最近更新了我的 VS 2017,现在我什至无法构建默认的 CUDA 项目(带有矢量添加的项目).

I've recently updated my VS 2017 and now I cannot even build a default CUDA project (the one with the vector addition).

我怀疑这是由于以下错误:

I suspect that this is due to the following error:

Severity    Code    Description Project File    Line    Suppression State
Error   C1189   #error:  -- unsupported Microsoft Visual Studio version! 
 Only the versions 2012, 2013, 2015 and 2017 are supported! ver2    
c:program files
vidia gpu computing 
toolkitcudav9.0includecrthost_config.h 133 

其他错误无关紧要,一旦我修复它就会消失.请注意,我能够从 CUDA 示例构建和运行 simpleCUFFT.

The other errors are irrelevant and will disappear once I fix this one. Note, that I am able to build and run simpleCUFFT from CUDA samples.

在更新之前,我能够构建默认的 CUDA 项目,但我无法构建 CUDA 示例项目.我已经使用 VS 安装程序更新了我的 VS2017 并安装了 CUDA SDK 10.0.15063.0.附上截图 与已安装的组件.

Before the update I was able to build the default CUDA project but I was not able to build the CUDA Sample project. I've updated my VS2017 using VS installer and installed CUDA SDK 10.0.15063.0. Attached is the screenshot with the installed components.

如果需要任何其他信息,请告诉我.我知道 following 主题,由于我使用的是最新的 CUDA 工具包,我不需要在 host_config.h 中进行更改.

Please let me know if any additional information is required. I am aware of the following topic and since I am using the latest CUDA toolkit, I don't need to make changes in host_config.h.

谢谢,米哈伊尔

我的 VS 版本(在 VS 安装程序中显示)是 15.5.0我的 nvcc 版本是 release 9.0, V9.0.176

My VS version (as displayed in VS installer) is 15.5.0 My nvcc version is release 9.0, V9.0.176

Edit2:我尝试将 host_config.h 第 133 行更改为:

I've tryied to change host_config.h line 133 to:

  #if _MSC_VER < 1600 || _MSC_VER > 1912

此错误不再出现,但是文件 type_trails 中出现了一堆错误表达式必须具有常量值".我不知道如何解决它.

This error does not show up anymore, however, a bunch of errors "expression must have a constant value" show up in the file type_trails. I have no clue how to fix it.

推荐答案

经过一段时间的痛苦,我终于解决了这个问题.以下是有类似问题的人的答案:

After some painful time, I was able to solve the problem. Here is the answer for those who have a similar problem:

1) 确保您拥有 VC++ 2015.3 v140 工具集(可以从 Web 或 Visual Studio 安装程序安装)

1) Make sure that you have VC++ 2015.3 v140 toolset (can be installed either from web or Visual Studio installer)

2) 在项目属性(常规)-> 平台工具集中选择 Visual Studio 2015 (v140).

2) In the project properties (general) -> Platform toolset choose Visual Studio 2015 (v140).

编辑(2018 年 5 月 21 日):我刚刚将 Visual Studio 2017 更新到最新版本 15.7.1.从现在开始,我可以选择 VS 2017 v141 工具集,它工作正常.

Edit (5/21/2018): I've just updated Visual studio 2017 to the latest version 15.7.1. From now on, I can choose VS 2017 v141 toolset and it works fine.

相关文章