CUDA 9 Unsupported Visual Studio Version Error

I have the same problem however my host_config.h file already has 1911 see:

#if _MSC_VER < 1600 || _MSC_VER > 1911

#error – unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!

I have Visual Studio 2017 enterprise… what is the version?

You can simply print out the value of the pre-defined macro _MSC_VER.

Microsoft has changed their method of delivering compilers and keeps cranking out new versions of MSVS 2017 every few months, so if you updated or installed recently you are probably at version 1913 or so by now. The latest version of CUDA is 9.1, not sure what the upper limit on supported MSVS 2017 versions for that is.

This change of delivery method for the MSVS compiler creates problems due to the tight integration of CUDA with supported host toolchains, and it may be non-trivial for NVIDIA to resolve because its having the carpet pulled out from under CUDA every few months. The situation is exacerbated by Microsoft not maintaining an archive of older versions (like NVIDIA maintains an archive of CUDA going back to 1.0), making it difficult to impossible for MSVS users to install an older version that is supported by CUDA. I would consider that bad form on the part of Microsoft, but opinions may differ.

I agree the problem is more on microsoft, i found that i was on 1912… still having issues building… i found installing a side by side minor version MSVC toolset solved some of my problems though… https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/ is the link i found helpful.

Given the situation, going forward to ‘sync with nVidia’ it would be really helpful if nVidia could warn in advance of the highest version of Visual Studio supported/targeted in any upcoming Cuda update (As it’s easier to update if the next Cuda update supports a later version, then it is to rollback or side install an older toolchain).

As of today we are on Visual Studio 15.5.4, and won’t update past that until Cuda surpasses it.

Then past that from this experience it would only make sense to update Visual Studio when there is a new Cuda update available.

I totally appreciate this isn’t nVidia’s fault.

I don’t know for CUDA 9.1, but for CUDA 9, NVIDIA was exceedingly clear in the Windows Installation Guide that only the original version of MSVS 2017 was supported and not any of the subsequent minor releases.

But that doesn’t really help, because people that install MSVS 2017 for the first time get whatever the latest minor version happens to be at that point in time, and they may not even know what _MSC_VER their compiler has. All they can tell is that the CUDA tool chain isn’t working with their host compiler and that is frustrating.

There have been similar issues on the Linux side with gcc updates, so this isn’t a problem restricted to Windows. The underlying issues is a cultural shift over the past decade towards rapid software release versioning, which creates problems if there are dependencies between products from different vendors which are on different release schedules driven by different market requirements (the CUDA schedule needs to be in sync with GPU hardware releases, for example).

Things were easier in the past when there wasn’t a rapid release philosophy and people often staid on the same toolchain for many years instead of always chasing the latest, and before software companies adopted a model where users are more or less forced to use the latest version (and sometimes upgraded automatically without them even noticing, as in the case of updating OS components that break CUDA functionality).

Any solutions as of now, for CUDA 9 compatibility with VS2017?
My machine config is as below and I am facing similar issue of “unsupported Visual Studio Version”. I am trying to execute simple cuda program.

Software Version
MS Visual Studio Enterprise 2017 15.5.2
Cuda Version = 9.0

As pointed out in #25, the Windows Installation Guide for CUDA 9.0 is clear that only the original MSVS 2017 release is supported, not the subsequent minor releases (which you appear to have installed).

Meanwhile, CUDA 9.1 has been out for a while and I would suggest giving that a try.

CUDA 9.1 does’nt help. Similar errors.
I guess, as of now, downgrading to 2015 version of VS and using CUDA 8 is the safe option, to continue work.

I know CUDA 8 works on VS2015 community edition but not sure about Enterprise Edition of VS 2015.
I have VS 2017 Enterprise edition, as of now, which I am planning to downgrade.

Any suggestions?

Hi,

I have Windows 10, 64 bit system in use.

I just installed everything on a completely new system.
Visual Studio Community Edition reports version 15.5.4.

cl (x64 environment) reports (sorry German output)
Microsoft ® C/C+±Optimierungscompiler Version 19.12.25834 für x64

nvcc --version
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:08:12_Central_Daylight_Time_2017
Cuda compilation tools, release 9.1, V9.1.85

Then error message
#error – unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
occurs.

[s]I patched host_config.h
( c:\program files\nvidia gpu computing toolkit\cuda\v9.0\include\crt\host_config.h line 133
like suggested in one of the above messages )

from

#if _MSC_VER < 1600 || _MSC_VER > 1911

to

#if _MSC_VER < 1600 || _MSC_VER > 1912

(last number changed from 1911 to 1912)[/s]

-> not a good idea!

Now “nvcc helloworld.cu” reports

nvcc helloworld.cu
helloworld.cu
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\type_traits(504): error: expression must have a constant value

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

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

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

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

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

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

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

8 errors detected in the compilation of “C:/Users/Marie/AppData/Local/Temp/tmpxft_0000103c_00000000-12_helloworld.cpp1.ii”.

One of the line has this code in Microsoft file:

// STRUCT TEMPLATE is_object

template
struct is_object
: bool_constant<!is_function_v<_Ty> /* this line is reported /
&& !is_reference_v<_Ty> /
this line is reported /
&& !is_void_v<_Ty>> /
this line is reported */
{ // determine whether _Ty is an object type
};

How do I get rid of these errors? Some command line option to nvcc needed?
Some further (hopefully backward compatible) patching of Microsoft files needed?

Many thanks!

Best regards,
Marie

Solution/workaround:
In Visual Studio 2017 installer there is also a possibility to install additionally VS2015.
After this, the suggested environment (from Microsoft, e.g. VS2015 x64) were not working.

I opened a DOS-Box (cmd.exe) and called

“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32”

This gave me pathes for cl.exe, even when 32bit is opened (not yet solved/able to open x64 environment)

cl.exe:
Microsoft ® C/C+±Optimierungscompiler Version 19.00.24225.1 für x86

This version seems to be compatible with nvcc from CUDA SDK v9.1:
nvcc helloworld.cu

It creates an exe (assuming 32bit, not checked), which I can execute. It prints “Hello world”.

The host compiler version checks put into the header file host_config.h are not being put there by NVIDIA just for fun. Therefore overriding or removing them rarely works, as all kind of “weird” compilation errors typically result. The underlying reason is the tight integration of the CUDA toolchain with host toolchains which requires adjustments on the CUDA side as the host toolchains change.

I don’t have MSVS 2015, but traditionally Microsoft has used separate batch files to set up environment variables necessary for a particular platform. For my MSVS 2010 installation I invoke

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat

to set up the environment for the x64 (64-bit) tool chain. I would suggest looking for the equivalent batch file in your MSVS 2015 installation and giving that a try.

Many thanks for your answer!
Yes, you are right, with installing the older version of Visual Studio,
changing the check in host_config.h is not more a good idea, I reverted it.

With your hint I was able to locate the file for x64 on my system:

“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat”

cl
Microsoft ® C/C+±Optimierungscompiler Version 19.00.24225.1 für x64
Copyright © Microsoft Corporation. Alle Rechte vorbehalten.

Syntax: cl [ Option… ] Dateiname… [ /link Linkeroption… ]

C:>

Also with this I am now able to call nvcc and compile.

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 Vs2015 stuff but Vs 2017 build tools Cpp!) force MSVC 14.11.25503

Same problem with Visual Studio Pro 2017 Trail, community version could be supported but if you update visual studio you get the same problem!

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1\0_Simple\matrixMul>“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 Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\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" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xcompiler “/wd 4819” -g -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -o x64/Debug/matrixMul.cu.obj “C:\ProgramData\NVIDIA Corporation\CUDA Samples\v9.1\0_Simple\matrixMul\matrixMul.cu”
matrixMul.cu
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\type_traits(504): error: expression must have a constant value

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

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

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

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

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

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

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

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xutility(543): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xtr1common(58): error: class “std::enable_if<, int>” has no member “type”
detected during instantiation of type “std::enable_if_t<, int>”
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xutility(543): here

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xutility(3135): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xutility(3662): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xtr1common(58): error: class “std::enable_if<, void>” has no member “type”
detected during instantiation of type “std::enable_if_t<, void>”
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xutility(3662): here

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xmemory0(390): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xmemory0(1002): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xmemory0(1322): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xstring(1718): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xutility(298): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\vector(495): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\algorithm(278): error: expression must have a constant value

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xstring(1780): error: more than one instance of overloaded function “std::_Deallocate_plain” matches the argument list:
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
argument types are: (std::_Rebind_alloc_t<std::_Rebind_alloc_t<std::allocator, char>, std::_Container_proxy>, std::_Container_proxy *)
detected during:
instantiation of “void std::_String_alloc<_Alloc_types>::_Free_proxy() [with _Alloc_types=std::_String_base_types<char, std::allocator>]”
(1728): here
instantiation of “std::_String_alloc<_Alloc_types>::~_String_alloc() [with _Alloc_types=std::_String_base_types<char, std::allocator>]”
(1909): here
instantiation of “std::basic_string<_Elem, _Traits, _Alloc>::basic_string(const std::basic_string<_Elem, _Traits, _Alloc> &) [with _Elem=char, _Traits=std::char_traits, _Alloc=std::allocator]”
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\system_error(503): here
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xstring(1780): error: more than one instance of overloaded function “std::_Deallocate_plain” matches the argument list:
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
argument types are: (std::_Rebind_alloc_t<std::_Rebind_alloc_t<std::allocator<__wchar_t>, __wchar_t>, std::_Container_proxy>, std::_Container_proxy *)
detected during:
instantiation of “void std::_String_alloc<_Alloc_types>::_Free_proxy() [with _Alloc_types=std::_String_base_types<__wchar_t, std::allocator<__wchar_t>>]”
(1728): here
instantiation of “std::_String_alloc<_Alloc_types>::~_String_alloc() [with _Alloc_types=std::_String_base_types<__wchar_t, std::allocator<__wchar_t>>]”
(1947): here
instantiation of “std::basic_string<_Elem, _Traits, _Alloc>::basic_string(const _Elem *, std::basic_string<_Elem, _Traits, _Alloc>::size_type) [with _Elem=__wchar_t, _Traits=std::char_traits<__wchar_t>, _Alloc=std::allocator<__wchar_t>]”
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\string(657): here

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xstring(1780): error: more than one instance of overloaded function “std::_Deallocate_plain” matches the argument list:
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
argument types are: (std::_Rebind_alloc_t<std::_Rebind_alloc_t<std::allocator<char16_t>, char16_t>, std::_Container_proxy>, std::_Container_proxy *)
detected during:
instantiation of “void std::_String_alloc<_Alloc_types>::_Free_proxy() [with _Alloc_types=std::_String_base_types<char16_t, std::allocator<char16_t>>]”
(1728): here
instantiation of “std::_String_alloc<_Alloc_types>::~_String_alloc() [with _Alloc_types=std::_String_base_types<char16_t, std::allocator<char16_t>>]”
(1947): here
instantiation of “std::basic_string<_Elem, _Traits, _Alloc>::basic_string(const _Elem *, std::basic_string<_Elem, _Traits, _Alloc>::size_type) [with _Elem=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]”
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\string(662): here

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\xstring(1780): error: more than one instance of overloaded function “std::_Deallocate_plain” matches the argument list:
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
function template “void std::_Deallocate_plain(_Alloc &, _Alloc::value_type *)”
argument types are: (std::_Rebind_alloc_t<std::_Rebind_alloc_t<std::allocator<char32_t>, char32_t>, std::_Container_proxy>, std::_Container_proxy *)
detected during:
instantiation of “void std::_String_alloc<_Alloc_types>::_Free_proxy() [with _Alloc_types=std::_String_base_types<char32_t, std::allocator<char32_t>>]”
(1728): here
instantiation of “std::_String_alloc<_Alloc_types>::~_String_alloc() [with _Alloc_types=std::_String_base_types<char32_t, std::allocator<char32_t>>]”
(1947): here
instantiation of “std::basic_string<_Elem, _Traits, _Alloc>::basic_string(const _Elem *, std::basic_string<_Elem, _Traits, _Alloc>::size_type) [with _Elem=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]”

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\string(667): here

24 errors detected in the compilation of “C:/Users/Asrocki/AppData/Local/Temp/tmpxft_00003aec_00000000-14_matrixMul.compute_70.cpp1.ii”.

Same “type_traits(504): error : expression must have a constant value” error after modifying the MSVC max ver.

Any news?
Will we ever be able to use it with VS 2017?

Will Nvidia ever make an independent compiler from the visual studio version?

CUDA SDK v9.1 still does not solve the problem.

We don’t want a new compiler. We want to use nvcc together with latest Visual Studio 2017 compilers.
So for us this is no way to go.
But it would be nice to get faster updates of NVIDIA CUDA SDK
(or at least some kind of description how to patch)
when an update of Visual Studio is rolled out.

Thank you! That really helps a lot!