CUDA compatibility with Visual Studio 2022 version 17.10
Asked Answered
E

3

7

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)?

Eliseoelish answered 22/5, 2024 at 7:35 Comment(5)
Cuda 12.0 obviously does not know about the latest version of VS. Best to update CUDA to the lastest and try again. TBH I think you've answered your own question.Pietra
@Johan, thanks, indeed in Cuda 12.5 the conditions in the same place is #if _MSC_VER < 1910 || _MSC_VER >= 1950, which supports new Visual Studio. At the same time, upgrading Cuda on my end will require all users of my program to upgrade Nvidia Graphics drivers, which I would like to avoid.Eliseoelish
then install an older version of VS that CUDA 12.0 won't complain about.Witherite
@RobertCrovella, thanks, I personally can rollback VS installation. But for other developers with Community Edition of Visual Studio, it can be a problem, since only the latest release is officially supported.Eliseoelish
this may be of interestWitherite
A
5

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

  • CUDA 12.4 was the first version to recognize and support MSVC 19.40 (aka VS 2022 17.10).
    • Note: It was definitely CUDA 12.4, not CUDA 12.5, that started allowing this.
    • CUDA 12.3 and older versions rejected MSVC 19.40. The nvcc compiler option --allow-unsupported-compiler can be used as an escape hatch.
  • MSVC 19.40 requires CUDA 12.4 or newer. Older versions will be rejected with error STL1002: "Unexpected compiler version, expected CUDA 12.4 or newer."
    • There's an escape hatch: Define _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH project-wide.
    • This requirement was increased by microsoft/STL#4475.

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

Andy answered 4/6, 2024 at 16:58 Comment(1)
For cuda 11.8 which version we need and for cuda 12.4 which version we need? there is literally 0 info how do you know these :DDobbins
H
3

I tested Visual Studio 2022 community(ver:17.10) with CUDA toolkit(ver:12.2). and had a same error.

after I rollback the Visual Studio version to 17.9.2, solved it.

I think the latest MSVC version 14.40 is not supporting old version of CUDA.

Habakkuk answered 24/5, 2024 at 9:4 Comment(0)
J
3

I observed the same problem after upgrading to VS 17.10 with my CUDA being quite behind on 11.8. There seems to be two official solutions for now:

  1. Downgrade your VS back to 17.9 to get the old host compiler version back (194X)
  2. Upgrade to CUDA 12.5 since this seems to be the first to support the new compiler version (195X) shipping with 17.10 #if _MSC_VER < 1910 || _MSC_VER >= 1950. Note that this might require a driver upgrade to >=528.33 on any executing machine.

For me, passing the flag -allow-unsupported-compiler to nvcc did not work. I tried it in a CMake project and passed it both from the command line during configure step as well as part of the CMAKE_CUDA_FLAGS. CMake already fails during the configure step.

Joint answered 29/5, 2024 at 4:11 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.