Can't compile CUDA kernels

Hi,

Today my debug Blender build suddenly fails to compile Cycles GPU CUDA kernels for some reason.
I didn’t change any code, so I deleted my old build folder and used make debug to create a brand new one.
However this still didn’t fix things.
The build itself succeeds but if I want to use Cycles with my GTX 1080 I get an error message on the debug console.
Full console output:

Read prefs: C:\Users\nucle\AppData\Roaming\Blender Foundation\Blender\3.5\config\userpref.blend
Vendor: NVIDIA Corporation
Renderer: NVIDIA GeForce GTX 1080/PCIe/SSE2
Version: 4.5.0 NVIDIA 517.40
Context Version: 4.5
Vendor: NVIDIA Corporation
Renderer: NVIDIA GeForce GTX 1080/PCIe/SSE2
Version: 4.5.0 NVIDIA 517.40
Context Version: 4.5
register
WARN (rna.define): C:\Users\nucle\Desktop\SSD_Blender_Source_Code\blender\source\blender\makesrna\intern\rna_define.c:1647 RNA_def_property_ui_text: 'Global Settings.' description from 'mi_settings' '' ends with a '.' !
WARN (rna.define): C:\Users\nucle\Desktop\SSD_Blender_Source_Code\blender\source\blender\makesrna\intern\rna_define.c:1647 RNA_def_property_ui_text: 'Curve Stretch Settings.' description from 'mi_cur_stretch_settings' '' ends with a '.' !
WARN (rna.define): C:\Users\nucle\Desktop\SSD_Blender_Source_Code\blender\source\blender\makesrna\intern\rna_define.c:1647 RNA_def_property_ui_text: 'Curve Surfaces Settings.' description from 'mi_cur_surfs_settings' '' ends with a '.' !
WARN (rna.define): C:\Users\nucle\Desktop\SSD_Blender_Source_Code\blender\source\blender\makesrna\intern\rna_define.c:1239 RNA_def_struct_ui_text: 'Divide selected edges or faces inserting new edges between them, and optionally spread the new edges.' description from 'FORGOTTEN_OT_mesh_connect_spread' '' ends with a '.' !
Vendor: NVIDIA Corporation
Renderer: NVIDIA GeForce GTX 1080/PCIe/SSE2
Version: 4.5.0 NVIDIA 517.40
Context Version: 4.5
CUDA version 11.8 detected, build may succeed but only CUDA 10.1 to 11.4 are officially supported.
Compiling CUDA kernel ...
"nvcc" -arch=sm_61 --cubin "C:\Users\nucle\Desktop\SSD_Blender_Source_Code\build_windows_x64_vc17_Debug\bin\Debug\3.5\scripts\addons\cycles\source\kernel\device\cuda\kernel.cu" -o "C:\Users\nucle\AppData\Roaming\Blender Foundation\Blender\3.5\cache\kernels\cycles_kernel_sm_61_CF7E77A0CDE6C538FDAE549F5A0006EC.cubin" -m64 --ptxas-options="-v" --use_fast_math -DNVCC -I"C:\Users\nucle\Desktop\SSD_Blender_Source_Code\build_windows_x64_vc17_Debug\bin\Debug\3.5\scripts\addons\cycles\source" -DWITH_NANOVDB
nvcc fatal   : Cannot find compiler 'cl.exe' in PATH
Failed to execute compilation command, see console for details.

Refer to the Cycles GPU rendering documentation for possible solutions:
https://docs.blender.org/manual/en/latest/render/cycles/gpu_rendering.html

--------------------------------------------------
Failed to unregister <class 'Texel_Density_3_2_2_291.ui.VIEW3D_PT_texel_density_checker'>
Traceback (most recent call last):
  File "C:\Users\nucle\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\simple-tabs\addon\utils\sidebar.py", line 118, in update
    bpy.utils.unregister_class(panel)
RuntimeError: unregister_class(...):, missing bl_rna attribute from 'RNAMeta' instance (may not be registered)
--------------------------------------------------
Info: Updated sidebar tabs

What’s strange is up until now it has always worked and I didn’t change anything, it just suddenly stopped working.

How do I fix this?

it’s trying to build the kernel on-demand at runtime, which is a bit on the tricky side to setup on windows, odds are you previously were building with WITH_CYCLES_CUDA_BINARIES on in cmake to pre-compile them, and now you are not.

I never set WITH_CYCLES_CUDA_BINARIES to ON, yet it always worked until now.
Anyways I figured out that adding C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64 to Windows PATH makes it work again.

I still find it strange that it just suddenly stopped working, but maybe a Windows update just broke things.

I have WITH_CYCLES_CUDA_BINARIES set to OFF but WITH_CYCLES_DEVICE_CUDA set to ON. What’s the difference between the two options?

WITH_CYCLES_DEVICE_CUDA enables cuda support in blender, it’s required to load both the pre-compiled and on demand kernels

WITH_CYCLES_CUDA_BINARIES enables pre-compilation of the cuda kernels at build time.

if you run blender from the X64 Native tools Visual Studio Command prompt it should setup the compiler for you without having to mess with your path, hardcoding C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\Hostx64\x64 will break over time as the 14.33.31629 bit will change as new VS updates get installed.

Actually I just found out that I originally did turn on WITH_CYCLES_CUDA_BINARIES and a script that I wrote set it to OFF.

Thanks for your help and especially for pointing out that the solution with adding the folder to PATH isn’t a long term solution after all.

Is there any documentation on what the different options in CMakeCache.txt do?

There should be a comment on the line right above every option beyond that i’m not aware of anything.