I have a very basic question on debugging CUDA code.
Visual Studio, NSight and the device (GeForce GT 720) are all on the same Windows 7 machine.
I have created a .cu file containing a kernel
__global__ void Generate_OnCUDA(void)
, and done a debug build of my project, which contains many C++ source files as well.
I am unable to set a breakpoint in this kernel. Visual Studio disallows setting a breakpoint, with the message “The breakpoint will not currently be hit. No executable code of the debugger’s target code is associated with this line”. Same for every line of the kernel.
I can set breakpoints in my C++ code outside the kernel, including in my C++ code in the .cu file.
How do I set breakpoints, examine variables, etc in the kernel, when the executable is being run under Visual Studio?
The nvcc command generated by Visual Studio:
1>C:\MyProject>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio017\Community\VC\Tools\MSVC4.11.25503\bin\HostX86\x64" -x cu -IC:\MyProject\ ... -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include" -G --keep --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -DWIN64 -D_WINDOWS -D_DEBUG -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MTd " -o x64\Debug\MyKernel.cu.obj "C:\MyProject\MyKernel.cu"
CUDA 9.0 runtime, NSight 5.3, Visual Studio Community 2017 v15.3.2, 64-bit Windows 7