How to get Visual Studio 2017 to use CUDA 9.1?

I have just installed CUDA 9.1. CUDA 9.0 was previously installed. When I attempt to compile a CUDA source file, I get

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio017\Community3\VC\Tools\MSVC4.12.25827\bin\HostX86\x64" -x cu -rdc=true -IC:\[bunch of C++ libraries]-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include"  -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static -Xptxas -v -g   -DWIN64 -D_WINDOWS -D_DEBUG -DTablebaseBuild -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -o x64\Debug\ "C:\MyProject\"

1>c:\program files\nvidia gpu computing toolkit\cuda\v9.0\include\crt/host_config.h(133): fatal error C1189: #error:  -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!

This has two problems, probably related: (1) Error for unsupported VS version; (2) compiler being used is 9.0.

I can find no option, extension, or path setting in VS to change the default compiler. Environment variable PATH contains C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\libnvvp and C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin.

VS macros are
(CUDA_PATH)=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1 (CUDA_PATH_V9_0)=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
$(CUDA_PATH_V9_1)=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1

How do I “retarget” VS to use CUDA 9.1 to compile and link CUDA (.cu) files?

Windows 7 64-bit; Visual Studio 2017 15.5.3; CUDA 9.1.85; NSight

The “retargeting” is accomplished by right-clicking the project in Solution Explorer, choosing Build Customizations, unchecking CUDA 9.0, and checking CUDA 9.1. After this, the 9.1 toolkit is used, rather than 9.0.

Next, there is an error in host_config.h, found in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include\crt. The error is in the test for supported VS version. As of 2016, MS started incrementing the macro _MSC_VER with every minor release, not just major releases. For VS2017 15.5.3, _MSC_VER is 1912. The test in host_config.h is

#if _MSC_VER < 1600 || _MSC_VER > 1911

so it fails, giving the “unsupported error”.

However, just changing the test to “>1912” gives a new set of errors, such as

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community3\VC\Tools\MSVC\14.12.25827\include\type_traits(504): error : expression must have a constant value

There is something else that needs to be done.

Problem with Cuda Sdk 9.1 at Visual Studio Pro 15.5.4 or Enterprise 2017 Trail, community version could be supported but if you update visual studio you get the same problem: VS x86_x64 Cross Tools Command Prompt for VS 2017 error: expression must have a constant value
cl /?: Microsoft ® C/C++ Optimizing Compiler Version 19.12.25831 for x64 (Dont want 2015 stuff but 2017 compile tools cpp) force MSVC 14.11.25503

I have been able to compile a initial demo program by the following methods.

Change 1911 to 1912 in host_config.h.
Change these new files (type_traits and xstddef ) to old files.

These files are in \Program Files(x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include.

Explain: what are the “old files”?

I’m stuck on the same thing… What are the old files? Also, I’m seeing some people say that 15.4 works - where can I get the earlier version of VS?


I just got CUDA and VS 2017 to work. I uninstalled CUDA / CUDA Nsight extension and VS 2017 (v 15.5). Then then installed VS 15.4 from

as the community edition. Then I installed

CUDA 9.0 from

and rebuild my project (a cmake project) and I didn’t get the errors that you mentioned above.

Good luck!

@christopher.fowler: Thanks, I’ll look into that.

Seeing how this thread is now a month old, and the Visual Studio integration with CUDA appears somewhat, for the lack of a better term, fundamental (on the basis that NVIDIA’s own video tutorials show the building of CUDA projects using VS), does anyone know whether this has been filed as a bug report? Have we seen any official response on the matter?

On the face of it, these fixes appear quite simple, and I’d rather wait NVIDIA to get their products in order rather than my having to install deprecated software.

Any thoughts?


I have a couple conferences coming up so I don’t have that luxury. I say take the hack and run with it. It’s definitely not ideal.

Previous Visual Studio 2017 15.4.5 works fine with offline enterprise iso (compile tools: vs2017 but not needed vs2015) installation. Now there are 3 Patches for Cuda 9.1, we use this in VsC++ because syntax highlighting(not 9.0). Just easy create a cuda9.1 cpp 2017 project from template, compile&run. Sry did not find the actual Vs2017 version solution yet, but previous!

If you have trouble reinstall windows 10 and start vs2017 15.4.5 installation on launch second time is old version without update, at least Cuda 9.1 and 3 patches. Some friend reported to me, advanced he also installed actual nVidia driver 391.01. Vote or comment by add a post, if it works fine for you too.

Visual Studio 2017 R15.4 is no longer available for download from Microsoft. Visual Studo 2017 R15.6 released March 22, 2018. Only previous released available to download.

Need appropriage fix as no work around exist as of March 23, 2018.

We can switch project to use previous toolset of VS2017.
Just follow instruction

Courtesy of, this link should work for VS Community 2017 15.4.5:
For those that want to just use the latest version that works with this legacy CUDA 9.1 Toolkit. Hopefully it doesn’t die for a while.