CUDA Toolkit v12.0 failed to compile every sample with .cu files on Windows 10 and Visual Studio 2022

Build started…
1>------ Build started: Project: bandwidthTest, Configuration: Debug x64 ------
1>Compiling CUDA source file bandwidthTest.cu…
1>
1>D:\CUDA\v12.0\cuda-samples-12.0\Samples\1_Utilities\bandwidthTest>“D:\CUDA\v12.0\bin\nvcc.exe” -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" -gencode=arch=compute_75,code="sm_75,compute_75" -gencode=arch=compute_80,code="sm_80,compute_80" -gencode=arch=compute_86,code="sm_86,compute_86" -gencode=arch=compute_90,code="sm_90,compute_90" --use-local-env -ccbin “D:\VS\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64” -x cu -I./ -I…/…/…/Common -I./ -ID:\CUDA\v12.0/include -I…/…/…/Common -I"D:\git\vcpkg\installed\x64-windows\include" -ID:\CUDA\v12.0\include -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xcompiler “/wd 4819” --threads 0 -g -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -Xcompiler “/Fdx64/Debug/vc143.pdb” -o D:\CUDA\v12.0\cuda-samples-12.0\Samples\1_Utilities\bandwidthTest\x64\Debug\bandwidthTest.cu.obj “D:\CUDA\v12.0\cuda-samples-12.0\Samples\1_Utilities\bandwidthTest\bandwidthTest.cu”
1>D:\VS\2022\Professional\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.0.targets(799,9): error MSB3721: The command ““D:\CUDA\v12.0\bin\nvcc.exe” -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" -gencode=arch=compute_75,code="sm_75,compute_75" -gencode=arch=compute_80,code="sm_80,compute_80" -gencode=arch=compute_86,code="sm_86,compute_86" -gencode=arch=compute_90,code="sm_90,compute_90" --use-local-env -ccbin “D:\VS\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64” -x cu -I./ -I…/…/…/Common -I./ -ID:\CUDA\v12.0/include -I…/…/…/Common -I"D:\git\vcpkg\installed\x64-windows\include” -ID:\CUDA\v12.0\include -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xcompiler “/wd 4819” --threads 0 -g -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler “/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -Xcompiler “/Fdx64/Debug/vc143.pdb” -o D:\CUDA\v12.0\cuda-samples-12.0\Samples\1_Utilities\bandwidthTest\x64\Debug\bandwidthTest.cu.obj “D:\CUDA\v12.0\cuda-samples-12.0\Samples\1_Utilities\bandwidthTest\bandwidthTest.cu”” exited with code 1.
1>Done building project “bandwidthTest_vs2022.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:04.075 ==========


==> If your try to reproduce the compilation using nvcc in the command prompt, nothing happens.
==> It’s happening since previous version of CUDA Toolkit (v10.x, v11.x), now I’m sharing here at forum
==> deviceQuery works because is C++ only - don’t use nvcc
==> Anyone has similar problem?


D:\CUDA\v12.0\cuda-samples-12.0\bin\win64\Debug\deviceQuery.exe Starting…

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: “NVIDIA GeForce RTX 2060”
CUDA Driver Version / Runtime Version 12.0 / 12.0
CUDA Capability Major/Minor version number: 7.5
Total amount of global memory: 6144 MBytes (6442123264 bytes)
(030) Multiprocessors, (064) CUDA Cores/MP: 1920 CUDA Cores
GPU Max Clock rate: 1680 MHz (1.68 GHz)
Memory Clock rate: 7001 Mhz
Memory Bus Width: 192-bit
L2 Cache Size: 3145728 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 65536 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1024
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 6 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
CUDA Device Driver Mode (TCC or WDDM): WDDM (Windows Display Driver Model)
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: No
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.0, CUDA Runtime Version = 12.0, NumDevs = 1
Result = PASS

I’ve solved the problem. Changing my TEMP and TMP variables to a path without spaces (my user name from %USERPROFILE%).
My old TEMP and TMP variables were:
TEMP = %USERPROFILE%\AppData\Local\Temp
TMP = %USERPROFILE%\AppData\Local\Temp

I’ve changed to:
TMP=D:\Temp\Local\Temp
TEMP=D:\Temp\Local\Temp

Now, working with Visual Studio 2022.
It’s an issue on NVIDIA CUDA Toolkit to Windows.
Should be documented, as least, as workaround.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.