6

I'm using nsight 2.2, Toolkit 4.2, latest nvidia driver, I'm using couple GPUs in my computer. Build customize 4.2. I have set "generate GPU ouput" on CUDA's project properties, nsight monitor is on (everything looks great).

I set several break points on my global - kernel function. nsight stops at the declaration of the function, but skips over several break points. It's just like nsight decide whether to hit a break point or skip over a break point. The funny thing is that nsight stops at for loops, but doesn't stop on simple assignment operations.

One more problem is that I can't set focus or add variables to the watch list. In this case (see attached screenshot) I can't resolve the value of variable : "posss" or "testDetctoinRate1" which are registers in this case. On the other hand, shared memory or block memory would insert automatically to the local's list.

Here is a screen shot of the kernel, before debugging

Here is a screen shot during debugging

I evoke my kernel function with following call:

checkCUDA<<<1, 32>>>(sumMat->rows,sumMat->cols , (UINT *)pGPUsumMat); 
cudaError = cudaGetLastError();
if(cudaError != cudaSuccess)
{
    printf("CUDA error: %s\n", cudaGetErrorString(cudaError));
    exit(-1);
}

kernel call works without an error.

Is there any option to forcing nsight stops at all breakpoints? How can I add thread's registers to my watch list?

Update

Initially, my debug command line is as follows:

# Runtime API (NVCC Compilation Type is hybrid object or .c file)
set CUDAFE_FLAGS=--sdk_dir "c:\Program Files\Microsoft SDKs\Windows\v7.0A\"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" --use-local-env --cl-version 2010 -ccbin "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" -I"..\..\..\opencv\modules\gpu\src\opencv2\gpu\device" -I"..\..\..\opencv\modules\gpu\include\opencv2\gpu" -I"..\..\..\build\include\\"   -G  --keep-dir "Debug" -maxrregcount=0  --machine 32 --compile  -g    -Xcompiler "/EHsc /nologo /Od /Zi  /MDd  " -o "Debug\%(Filename)%(Extension).obj" "%(FullPath)"

I changed on property page --> cuda --> host --> generate hosting debug information --> No

Now my command line doesn't contain the -g and -O letters , my command line is as followed:

# Runtime API (NVCC Compilation Type is hybrid object or .c file)
set CUDAFE_FLAGS=--sdk_dir "c:\Program Files\Microsoft SDKs\Windows\v7.0A\"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" --use-local-env --cl-version 2010 -ccbin "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" -I"..\..\..\opencv\modules\gpu\src\opencv2\gpu\device" -I"..\..\..\opencv\modules\gpu\include\opencv2\gpu" -I"..\..\..\build\include\\"   -G  --keep-dir "Debug" -maxrregcount=0  --machine 32 --compile      -Xcompiler "/EHsc /nologo /Od /Zi  /MDd  " -o "Debug\%(Filename)%(Extension).obj" "%(FullPath)"

Although, I do debug with -o, does it matter? It doesn't make any change.

halfer
  • 19,824
  • 17
  • 99
  • 186
TripleS
  • 1,216
  • 1
  • 23
  • 39

4 Answers4

6

Right click the .cu file in the Solution Explorer, then go to CUDA C/C++ | Device and set Generate GPU Debug Information to Yes (-G0).

Roger Dahl
  • 15,132
  • 8
  • 62
  • 82
  • I'm comparing your command line with one that I have for Visual Studio 2010 CUDA project and your commnand line has `-G` while mine has `-G0`. However, if I set `Generate GPU Debug Information` to `No`, I don't get `-G`. Intead, the `-G` disappears entirely. So this answer may not help. Feel free to make your entire project available. I'll download it and see if debugging works for me. – Roger Dahl Jun 01 '12 at 17:16
  • Thanks for help , I generate GPU debug information was already set for 'Yes' – TripleS Jun 02 '12 at 09:32
  • Hey Roger , thanks for help , finally it's worked , I can watch registers values in nsight. I'd recommend using the latest version of nsight.Plus , if you can aspect specific value , you can declare it as __shared__ instead S – TripleS Jun 06 '12 at 10:19
  • I'm trying to debug cuda code in this project: https://github.com/PointCloudLibrary/pcl. My setting is already `-G` by default, while it still skips the breakpoints, why? – zhangxaochen Oct 07 '15 at 14:18
2

Check whether "Enable CUDA Memory Checker" under Nsight is turned off or not. It may allow NSight to stop breakpoints of your CUDA kernel code on Debug mode of VS C++ 2010. At least, it works for me.

Joon
  • 21
  • 1
  • 1
    so did you turn it **ON** or **OFF**? Besides, whenever I turn it on, my screen goes black and seems the OS breaks down, all I have to do is to restart my PC by pressing the power button ;( – zhangxaochen Oct 07 '15 at 12:57
0

In the debug build, are you passing both the -O and the -g options to nvcc? If so, try removing the -O.

Background: This sounds like the kind of problem one gets when trying to debug code that has been optimized by the compiler. During optimization, the compiler changes the code in such a way that some lines of source no longer have any machine code instructions associated with them, making it impossible for the debugger to set breakpoints on those lines.

Roger Dahl
  • 15,132
  • 8
  • 62
  • 82
  • I changed on property page --> cuda --> host --> generate hosting debug information --> No. It's doesn't make any change . – TripleS Jun 01 '12 at 16:00
  • Actually, the options that start with "-" are for nvcc and the options that start with "/" get passed through to cl. Changes in the `Host` section only affect the "/" cl options. So the "-O" flag would have been from some setting in the `Device` section but I don't see it in your command line options. – Roger Dahl Jun 01 '12 at 17:31
0

I have similar issue. Nsight is not stopping at any of the break points. But completes execution.

If i use -G0 as debug info option. It gives an error.

I am using nvidia 2.2.0.1225 with cuda 4.2 and cuda 5 tool kit. With 301.42 graphic driver.

Zahid
  • 81
  • 1
  • 7