Samples: CUDACOMPILE : nvcc error : ‘cudafe++’ died with status 0xC0000005 (ACCESS_VIOLATION)

Issue: Building Projects with Visual Studio and CUDA 12.5.1 on Windows

When attempting to build projects with the latest Visual Studio and CUDA 12.5.1_555.85 on Windows, the following error is encountered from msbuild:

0>------- Started building project: AppEncCuda
0> Message: Building NVCC (Device) object AppEncode/AppEncCuda/CMakeFiles/AppEncCuda.dir/__/__/Utils/Debug/AppEncCuda_generated_crc.cu.obj
0> Message: crc.cu
0> Message: crc.cu
0>CUSTOMBUILD(0,0): Error nvcc: 'cudafe++' died with status 0xC0000005 (ACCESS_VIOLATION)
0> Message: CMake Error at AppEncCuda_generated_crc.cu.obj.Debug.cmake:280 (message):
0> Message:   Error generating file
0> Message:   ...../Video_Codec_SDK_12.2.72/build/AppEncode/AppEncCuda/CMakeFiles/AppEncCuda.dir/__/__/Utils/Debug/AppEncCuda_generated_crc.cu.obj
0> Message: 
0> Message: 
0>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): Error MSB8066: Custom build for '......\Video_Codec_SDK_12.2.72\Samples\Utils\crc.cu' exited with code 1.

Extended logs from CMake with NVCC_REPORT_ALLERROR environment variable show:

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build ..../Video_Codec_SDK_12.2.72/build --config Debug --target ALL_BUILD -j 26 --
[build] MSBuild version 17.11.2+c078802d4 for .NET Framework
[build] 
[build]   Building NVCC (Device) object AppEncode/AppEncCuda/CMakeFiles/AppEncCuda.dir/__/__/Utils/Debug/AppEncCuda_generated_crc.cu.obj
[build]   Building NVCC (Device) object AppEncode/AppEncLowLatency/CMakeFiles/AppEncLowLatency.dir/__/__/Utils/Debug/AppEncLowLatency_generated_Resize.cu.obj
[build]   Resize.cu
[build]   crc.cu
[build] C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.34021\include\vcruntime.h(192): error : invalid redeclaration of type name "size_t" [....\Video_Codec_SDK_12.2.72\build\AppEncode\AppEncLowLatency\AppEncLowLatency.vcxproj]
[build]         typedef unsigned int     size_t;
[build]                                  ^

The issue seems similar to one described in an NVIDIA forum post, but not exactly the same.

Environment Details

  • Visual Studio Version:

    Microsoft Visual Studio Community 2022
    Version 17.11.0 Preview 3.0
    VisualStudio.17.Preview/17.11.0-pre.3.0+35103.136
    
  • MSVC Versions Installed (latest tools used):

    14.39.33519
    14.41.34021
    
  • Video Codec SDK Version:

    12.2.72
    
  • CUDA Version:

    v12.5 Update 1
    

Can you suggest me what to do next?