Problems with latest vs2022 update

I received a nasty surprise after updating to the latest version of vs2022 today. I don’t use cmake … I compile my ptx files by directly calling nvcc.exe in my code. This has worked perfectly until today when I receive this message when trying to compile my .cu code.

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\include\crt/host_config.h(164): fatal error C1189: #error: – unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag ‘-allow-unsupported-compiler’ can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.

I tried the ‘-allow-unsupported-compiler’ flag but then got this error message

nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified

I tried updating to Cuda 12.5 from 12.3 and still get the errors
I tried compiling the ‘optixHello’ sample from the OptiX-Samples and get the same error.

|Error|C1189|#error: – unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag ‘-allow-unsupported-compiler’ can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.|optixHello|C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include\crt\host_config.h|157|||

OptiX 8.0
Geforce RTX 3090 driver 555…85
Windows 11 Pro

Right, this is a known problem.

The Microsoft Visual Studio 2022 Update to version 17.10 extended the Microsoft Visual C version to 19.40 (while the toolset is still v143).

That MSC_VER 1940 number is unfortunately outside the range of the versions MSVS 2022 used so far, which are MSC_VER 1930 to 1939.

In CMake that is MSVC_VERSION 1940 which isn’t documented either yet:
https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html#msvc-version
That table shows how different MSVS versions handled these version numbers.
Also note how the versioning scheme changed in the last three MSVS versions.
(I’ll need to update my own examples’ 3rdparty.cmake script to include 1940 for MSVS 2022 as well now.)

CUDA toolkits are tested against available host compiler versions and contain a version check for known compatible host compilers. You’ll find that inside the CUDA header host_config.h and it looks like this:

#if defined(_WIN32)

#if _MSC_VER < 1910 || _MSC_VER >= 1940

#error -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
...

So that is where your initial error message comes from.

nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified

That error usually happens when one of the options inside your nvcc command line is not parsed correctly and interpreted as input file name.

If in doubt about what command line options are available, issue nvcc.exe --help and look at the help text output:

--allow-unsupported-compiler               (-allow-unsupported-compiler)        
        Disable nvcc check for supported host compiler versions. Using an unsupported
        host compiler may cause compilation failure or incorrect run time execution.
        Use at your own risk. This option has no effect on MacOS.

If the shortcut version with a single minus prefix didn’t work, please try the non-shortcut version with two minuses.

According to the CUDA engineering team, this MSC version check should have been fixed inside the CUDA 12.4.0 version already.

If this is not working in CUDA 12.5, please have a look into its CUDA host_config.h and see if that still checks against _MSC_VER >= 1940. Then that would need a toolkit update release as well.

In either case, setting --allow-unsupported-compiler or changing the CUDA host_config.h to include MSC_VER 1940 should work on CUDA toolkits not knowing that MSC version.

try to change “#if _MSC_VER < 1910 || _MSC_VER >= 1940” to “#if _MSC_VER < 1910 || _MSC_VER >= 2940”, it works in my envirenment

2 Likes

That should only be the last resort.

Prefer to use a CUDA Toolkit which added support for the host compiler version or set the --allow-unsupported-compiler before hacking around inside local CUDA files. That wouldn’t help others compiling your application code.

Even if changing that CUDA header locally, I would have added only the single 1940 version which ran into problems to be able to detect when that happens again.

Thanks for the quick response as usual!

The Cuda 12.5 host_config.h has been corrected to.
#if _MSC_VER < 1910 || _MSC_VER >= 1950

and I can compile without getting the #error – unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022
and I am not using the --allow-unsupported-compiler any more.

But now I’m hitting this error.

1 error detected in the compilation of “E:/code/LWDreamer/framework/render_core/excludeFromBuild/cuda/copy_buffers.cu”.

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include__msvc_iter_core.hpp(293): error: use the “typename” keyword to treat nontype “std::incrementable_traits<>::difference_type [with =_It]” as a type in a dependent context
&& requires(_It __i, incrementable_traits<_It>::difference_type __n)

1 Like

The Cuda 12.5 host_config.h has been corrected to

You mean it was already adjusted correctly correct or you changed it?

From the error message alone I cannot say what’s happening there.
What iterator statement in your code raises that error?
I don’t know how include__msvc_iter_core.hpp has been dragged into that.

Is copy_buffers.cu native CUDA kernel code or OptiX device code?

I’m also not sure if CUDA 12.5 works without issues with OptiX SDK 8.0.0. Not tried myself, yet.
Does the same happen in CUDA 12.3 when using the adjusted _MSV_VER?

I tried updating to Cuda 12.5 from 12.3 and still get the errors

Sorry, my bad there. I should have said that I’m getting the “include__msvc_iter_core.hpp” error

I reverted back to cuda 12.3 with ‘-allow-unsupported-compiler’ flag on( I tried the ‘–allow-unsupported-compiler’’ version as well but still get this error

nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified

Here’ the args I’m passing to nvcc

I think you just have the args.push_back ("--allow-unsupported-compiler"); at the wrong place:

        args.push_back ("-ccbin");
        args.push_back ("--allow-unsupported-compiler"); // This shouldn't be between -ccbin and the host compiler path! Try pushing it one code line earlier or later.
        args.push_back ("C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/");

Thanks, that solved the

nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified

but now I’m hitting the “include__msvc_iter_core.hpp” error again. I tried putting a break point at that line but it never gets hit

I fixed it by modifying line 293 of “C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include__msvc_iter_core.hpp”

I added ‘typename’ before “incrementable_traits”

// clang-format off
template
concept _Cpp17_random_delta = totally_ordered<_It>
&& requires(_It __i, typename incrementable_traits<_It>::difference_type __n) {

Just a warning to VS 2022 Community users. You can not roll back to a previous version if you update to version 17.10 . The change I made to ‘include__msvc_iter_core.hpp’ does allow nvcc to compile without error but if you run in debug mode you’ll get an annoying popup window about ‘include__msvc_iter_core.hpp’ being different from the original distribution.

Hi, if you are an Enterprise or Professional customer and we can uninstall Visual Studio to go back to an earlier release, please check this document: [Visual Studio 2022 Release History | Microsoft Learn

But the Visual Studio Community edition is only supported on the Current channel using the latest version of Visual Studio.

That worked for me as well.

For those stumbling upon this thread in June 2024, make sure to set _MSC_VER >= 1950in your host_config.h(so 1940 isn’t working any more). CUDA 12.5 has 1950 as default, but CUDA 12.1.1 still had 1940 and it would throw same error. Couldn’t check how it is in versions inbetween, since I don’t have them installed.

Just set --allow-unsupported-compiler in your NVCC command line options when using older CUDA Toolkits.
There is no need to change the CUDA host_config.h.

My setup is VS2022 version: v17.10.4, CUDA: 11.8, CuDNN: 8.9. Compiling dlib using this configuration works for me.