11
votes

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\nvidia gpu computing 
toolkit\cuda\v9.0\include\crt\host_config.h 133 

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.

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 screenshotscreenshot with the installed components.

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.

Thanks, Mikhail

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

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

  #if _MSC_VER < 1600 || _MSC_VER > 1912

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.

4
Microsoft have already released at least one update of VS2017 which broke CUDA 9. You might be a victim of another. When did you download and install both CUDA and VS and what exact version do both report?talonmies
Thanks, I've made an edit to my postMikhail Genkin
Can someone who is using VS2017 and CUDA post there versions of both pleaseMikhail Genkin

4 Answers

20
votes

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

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

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

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.

3
votes

I'm using CUDA 9.2 and VS 2017 (Version 15.7.5). Simply Modifying host_config.h (usually under C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.*\include\crt, can be found in the VS output from build) works for me.

Change the line

#if _MSC_VER < 1600 || _MSC_VER > 1913

to

#if _MSC_VER < 1600 || _MSC_VER > 1914

or something similar, based on the version of cl.exe

2
votes

In VS update 15.4.3 Microsoft updated version number of their CL compiler to 14.12 (https://www.visualstudio.com/ru-ru/news/releasenotes/vs2017-relnotes#15.4.4)

That's why CUDA 9.0.176 refuse to compile. Today NVIDIA updated CUDA to 9.1.85, so just update just update CUDA to 9.1 https://developer.nvidia.com/cuda-downloads

1
votes

For anyone that's reading this question, update in CUDA 10. It works right out of the box. No need to install previous compiler tool-sets and the like mentioned in other answers. Simply download CUDA 10, install it and uninstall previous CUDA versions. Then make a new CUDA 10 project and place your code. It will work.

If you're getting errors, don't forget to set compute_xx,sm_xx appropriately, in Project Properties -> CUDA C/C++ -> Device -> Code Generation.