cudacondawindows-11

Issues with CUDA installation via `cuda-toolkit` on win 11 - cannot find VS C++ tools?


On Windows 11 and using mamba/mininforge, I installed CUDA to a Python 3.9 environment using mamba install cuda-toolkit==12.1* - channel is conda-forge. When activating the environment, I get a bunch of output to the terminal (see below). Not sure what this means - can't CUDA find the C++ build tools?

Prior to install CUDA I installed VS 2022 C++ tools, which should work (https://quasar.ugent.be/files/doc/cuda-msvc-compatibility.html), but apparently my CUDA installation isn't looking for the 2022 folder (only 2019). Do I need to add them to the path or something?

C:\Users\mluerig>mamba activate my-env

C:\Users\mluerig>SET DISTUTILS_USE_SDK=1

C:\Users\mluerig>SET MSSdk=1

C:\Users\mluerig>SET "VS_VERSION=16.0"

C:\Users\mluerig>SET "VS_MAJOR=16"

C:\Users\mluerig>SET "VS_YEAR=2019"

C:\Users\mluerig>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"

C:\Users\mluerig>set "MSYS2_ENV_CONV_EXCL=CL"

C:\Users\mluerig>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"

C:\Users\mluerig>set "CXX=cl.exe"

C:\Users\mluerig>set "CC=cl.exe"

C:\Users\mluerig>set "VSINSTALLDIR="

C:\Users\mluerig>set "NEWER_VS_WITH_OLDER_VC=0"

C:\Users\mluerig>for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -version [16.0,17.0) -property installationPath`) do (set "VSINSTALLDIR=%i\" )

C:\Users\mluerig>if not exist "" (for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -requires Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 -property installationPath`) do (
set "VSINSTALLDIR=%i\"
 set "NEWER_VS_WITH_OLDER_VC=1"
) )

C:\Users\mluerig>if not exist "" (for /F "usebackq tokens=*" %i in (`vswhere.exe -nologo -products * -requires Microsoft.VisualStudio.Component.VC.v142.x86.x64 -property installationPath`) do (
set "VSINSTALLDIR=%i\"
 set "NEWER_VS_WITH_OLDER_VC=1"
) )

C:\Users\mluerig>if not exist "" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\" )


C:\Users\mluerig>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" )

C:\Users\mluerig>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\" )

C:\Users\mluerig>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\" )

C:\Users\mluerig>IF NOT "" == "" (
set "INCLUDE=;"
 set "LIB=;"
 set "CMAKE_PREFIX_PATH=;"
)

C:\Users\mluerig>call :GetWin10SdkDir

C:\Users\mluerig>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 exit /B 1

C:\Users\mluerig>exit /B 0

C:\Users\mluerig>for /F %i in ('dir /ON /B "C:\Program Files (x86)\Windows Kits\10\\include\10.*"') DO (SET WindowsSDKVer=%~i )

C:\Users\mluerig>(SET WindowsSDKVer=10.0.22621.0 )

C:\Users\mluerig>if errorlevel 1 (echo "Didn't find any windows 10 SDK. I'm not sure if things will work, but let's try..." )  else (echo Windows SDK version found as: "10.0.22621.0" )
Windows SDK version found as: "10.0.22621.0"

C:\Users\mluerig>set "CMAKE_PLAT=x64"

C:\Users\mluerig>set "VCVARSBAT=64"

C:\Users\mluerig>set "CMAKE_ARGS=-DCMAKE_BUILD_TYPE=Release"

C:\Users\mluerig>IF "" == "1" (set "CMAKE_ARGS=-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= -DCMAKE_PROGRAM_PATH=\bin;\Scripts;\Library\bin;\bin;\Scripts;\Library\bin" )

C:\Users\mluerig>IF NOT "win-64" == "win-64" (
set "CONDA_BUILD_CROSS_COMPILATION=1"
 set "CMAKE_ARGS=-DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=AMD64"
)  else (set "CONDA_BUILD_CROSS_COMPILATION=0" )

C:\Users\mluerig>IF 2019 GEQ 2019 (
set "CMAKE_GEN=Visual Studio 16 2019"
 set "USE_NEW_CMAKE_GEN_SYNTAX=1"
)  ELSE (
IF "win-64" == "win-64" (set "CMAKE_GEN=Visual Studio 16 2019 Win64" )  else (set "CMAKE_GEN=Visual Studio 16 2019" )
 set "USE_NEW_CMAKE_GEN_SYNTAX=0"
)

C:\Users\mluerig>echo "NEWER_VS_WITH_OLDER_VC=0"
"NEWER_VS_WITH_OLDER_VC=0"

C:\Users\mluerig>if "0" == "1" (set /p NEWER_VS= 0<"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" )

C:\Users\mluerig>type "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"
The system cannot find the path specified.

C:\Users\mluerig>dir "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\\VC\Redist\MSVC\"
The system cannot find the path specified.

C:\Users\mluerig>if "0" == "1" (
echo ""
 if "~0,4" == "14.2" (set "CMAKE_GEN=Visual Studio 16 2019" )  else (set "CMAKE_GEN=Visual Studio 17 2022" )
 set "USE_NEW_CMAKE_GEN_SYNTAX=1"
)

C:\Users\mluerig>IF "" == "" SET "CMAKE_GENERATOR=Visual Studio 16 2019"

C:\Users\mluerig>IF "1" == "1" (
IF "" == "" SET "CMAKE_GENERATOR_PLATFORM=x64"
 IF "" == "" SET "CMAKE_GENERATOR_TOOLSET=v142"
)

C:\Users\mluerig>pushd C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
The system cannot find the path specified.

C:\Users\mluerig>CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.29 10.0.22621.0
The system cannot find the path specified.

C:\Users\mluerig>if 1 NEQ 0 (if "" == "" (CALL "VC\Auxiliary\Build\vcvars64.bat" ) )
The system cannot find the path specified.

C:\Users\mluerig>popd

C:\Users\mluerig>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1

C:\Users\mluerig>if errorlevel 1 exit /B 1

C:\Users\mluerig>exit /B 0

C:\Users\mluerig>if defined INCLUDE (set "INCLUDE_CONDA_NVCC_BACKUP=" )

C:\Users\mluerig>set "INCLUDE=;\targets\x64"

Solution

  • I finally found the answer to this - I think. Importantly, on the same installation that produced these messages, I was able to install CUDA via mamba. The trick was to set all the necessary flags during prior installation of the C++ tools in the VS installer (which I hadn't done before), and to use the correct cuda-toolkit version that goes with them.

    However, even after this I got a stream of messages like this in my terminal, which were simply showing that the VS C++ tools were found and loaded correctly. In the end I did not manage to deactivate them, but I think it can be done by finding the appropriate environmental variable and setting it (e.g. something like VSCMD_DEBUG).