Code fails to compile when "Generate GPU Debug Information" is set to "Yes"

My compilation environment consists of visual studio 2019 and cuda 11.5. When I tried to compile my code, it was frustrating that there was an error of MSB3721, and there was no other error except MSB3721.

After many attempts, I found that if I set the “Configuration Properties” → “CUDA C/C++” → “Device” → “Generate GPU Debug Information” of the visual studio 2019 project to “Yes”, the compilation will fail. If set to “No”, the compilation is successful, but I can’t use “Nsight”-> “Start CUDA Debugging” to debug the CUDA kernel function.

I would like to know what is causing this issue and how to pass compilation with “yes” set so that I can debug CUDA kernel functions. Thanks!

In the code I wrote, many functions have the prefix of host____device when they are declared, but I basically did not write the prefix of__host____device__ when these functions were defined. Will this cause the above problems?

Because the amount of code is very large, nearly 100,000 lines, I hope to modify the code after confirming that this is the cause of the above problem.

the declaration and definition should match. but if your MSB3721 error goes away for non-debug, that may not be the issue.

rather than working with 100,000 lines of code, you could build a simple test case to explore.

MSB3721 is a generic error. It just means nvcc failed to compile without telling you why. It’s necessary to increase the VS verbosity level in order to see why. There are many forum posts describing this.