CUDA lazy loading not enabled in a release build in Visual Studio


I just noticed that the lazy loading might not be enabled in a release build in Visual studio, but it is confirmed enabled in the debug build. I use the following code to see if it is enabled:

CUmoduleLoadingMode mode = CU_MODULE_EAGER_LOADING;
  assert(CUDA_SUCCESS == cuInit(0));
  assert(CUDA_SUCCESS == cuModuleGetLoadingMode(&mode));

  debugLog(((mode == CU_MODULE_LAZY_LOADING) ? "lazy" : "eager"));

When I run a debug build, it showed “lazy” while if I run the release build it showed “eager”. I use Visual Studio 2022 with CUDA 12.3. And it doesn’t matter if I manually set CUDA_MODULE_LOADING=LAZY or not. I also compared the configurations for both release and debug mode, except the debugging related part they are more or less identical.

My question: is lazy loading always guaranteed to turn on when I use CUDA 12.3 on Windows (no matter what result cuModuleGetLoadingMode() returns) ?

Thanks in advance.