Building with VS 2015 vs VS 2017

I have just installed the CUDA Toolkit 9.1 on my Windows machine.
Also, I have the latest version of Visual Studio installed.

I did build the deviceQuery_vs2017.sln in Visual Studio 2017 in Release mode and everything went fine. The .exe is where it is supposed to be. The output makes sense.

My question is: why can’t I build other solutions in VS 2017?
For instance, when I try to build nbody_vs2017.sln or bandwidthTest_vs2017.sln I get the following error (reported only for nbody):

1>------ Build started: Project: nbody, Configuration: Release x64 ------
1>Compiling CUDA source file bodysystemcuda.cu...
1>
1>C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1_Simulations\nbody>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_60,code=\"sm_60,compute_60\" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -gencode=arch=compute_70,code=\"sm_70,compute_70\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio017\Community\VC\Tools\MSVC4.13.26128\bin\HostX86\x64" -x cu  -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include"     --keep-dir x64\Release -maxrregcount=0  --machine 64 --compile -cudart static -Xcompiler "/wd 4819"    -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /FS /Zi  /MT " -o x64/Release/bodysystemcuda.cu.obj "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1_Simulations\nbody\bodysystemcuda.cu"
1>c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt/host_config.h(135): fatal error C1189: #error:  -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
1>bodysystemcuda.cu
1>C:\Program Files (x86)\Microsoft Visual Studio017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations\CUDA 9.1.targets(707,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_60,code=\"sm_60,compute_60\" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -gencode=arch=compute_70,code=\"sm_70,compute_70\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio017\Community\VC\Tools\MSVC4.13.26128\bin\HostX86\x64" -x cu  -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include"     --keep-dir x64\Release -maxrregcount=0  --machine 64 --compile -cudart static -Xcompiler "/wd 4819"    -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /FS /Zi  /MT " -o x64/Release/bodysystemcuda.cu.obj "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1_Simulations\nbody\bodysystemcuda.cu"" exited with code 2.
1>Done building project "nbody_vs2017.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Everything works fine when I build the vs2015 solution.


I’ve just read below that others have the same problem. It’s been quiet some time since it has been reported. I would like to know whether anyone is working on this, or we should not expect to be considered.

The behavior of host_config.h will vary depending on how it is used (or not) in the compilation process. The compilation of the deviceQuery project involves entirely host library calls which can be processed by cl.exe, the host compiler.

In the case of nbody, a .cu file will be processed by nvcc and the host_config.h file will get included. In that situation, the processing of host_config.h will generate this error.

If you would like a more exact description of the difference in these two cases, it’s probably best to just study that header file yourself.

Currently, people using VS2017 seem to be able to get things to work with the 15.4 toolchain. If you are on a later toolchain, that is probably why you are seeing this.

I can’t make any direct statements about the future, but in general looking back historically, new CUDA releases often bring updated support or support for new VS versions or toolchains.