visual-c++cuda

CUDA compatibility with Visual Studio 2022 version 17.10


I have just upgraded Visual Studio 2022 to the latest version 17.10, and found that my program using CUDA v12.0 does not compile because of the error in NVIDIA GPU Computing Toolkit\CUDA\v12.0\include\crt\host_config.h:

#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.

because _MSC_VER = 1940 in Visual Studio 2022 v17.10.

Is it safe to use compilation flag -allow-unsupported-compiler in my case or just patch host_config.h allowing for higher _MSC_VER, or Visual Studio 2022 v17.10 is actually and irreparably incompatible with CUDA 12.0 (and below)?


Solution

  • There are version requirements on both sides. For background info, see MSVC Toolset Minor Version Number 14.40 in VS 2022 v17.10, aka "we ran out of digits".

    Note that when you activate these escape hatches, you're using a configuration that hasn't been tested by CUDA and MSVC, but things will probably work (as long as your CUDA version isn't extremely old; e.g. MSVC's previous requirement was CUDA 11.6.)

    enter image description here