Debugging cuda code using visual studio

Hi, I just started developing some code for cuda. I’m running on an xp box using vs2005. For some reason i can’t get the debugger to step into the cuda code even when I’m running under EmuDebug. Can some one help me ?

Thanks

Eri

Put a breakpoint inside one of your global functions rather than trying to step into GPU code from the host code. I have found that I cannot step into a foo<<<>>>() function directly, but I can put a break inside it to debug it.

Mark

thanks did the trick

Any suggestion for inspecting shared variables in visual studio 2005? They seem to give me a problem.

Thanks

I had the same problem. It was solved after copeing the custom compile options from the sdk.

hope this helps

Eri

I will check that out.

thanks

I have a similar problem but placing a breakpoint within the kernel doesn’t work. It will step into the kernel?

Here’s the setup:

A .cpp file launches a routine in a .cu file that then invokes a kernel call. The kernel is in this same .cu file. The .cpp files are compiled using msvc compiler and the .cu with nvcc.

It was built as a DLL using CUDA rules and setting the properties of the .cu file as follows:

nvcc.exe -ccbin "C:\Program Files\Microsoft Visual Studio 8\VC\bin" -deviceemu -c  -Xcompiler "/EHsc /W3 /nologo /Wp64 /O2 /Zi   /MDd /GR"  -o Debug\rtw_gpu_cu.obj rtw_gpu_cu.cu

Any ideas?

Thanks for your help!

Hi all,

I am facing a problem with a new cuda dll project : when I am debugging my test project, the values displayed by the debugger are completely wrong for most of them, although the program works correctly (that values are ok when returned by the dll functions to the main program). I included two cuda dlls in the project, the first can be debugged but not the new one. Here is the command line :

"nvcc.exe" -ccbin "C:\Program Files\Microsoft Visual Studio 8\VC\bin"  -c -D"WIN32" -D"_DEBUG" -D"_CONSOLE" -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Wp64 /O2 /Zi   /MTd " -I"C:\CUDA_2_0\include" -I"./" -I"C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\inc" -I"C:\Program Files\GnuWin32\include" -o "Debug\blabla.obj" blabla.cu

I used the cuda.rules file. I have been looking for the error since severall days so if anyone has an idea…

I reply to my one question since I (finally) found the bug :

The compilation options must be the same for the visual compiler and the cuda compiler : in my case, I had /O2 option for cuda and /Od for visual.

Thank you for that tip, sudoca!

Thanks here, too!

Thanks!

In my case I did not have any cpp files in my project but had the /O2 optimization option enabled. I disabled optimizations (/Od flag) and I worked fine.

Thanks!

In my case I did not have any cpp files in my project but had the /O2 optimization option enabled. I disabled optimizations (/Od flag) and I worked fine.

You can try NSight but it does not allow debugging on a single GPU config (which I suppose is really absurd) and you need to have atleast 2 GPUs to debug your kernels on the device unlike the emuDebug, monitor global and shared memory etc.

Take a look: http://www.nvidia.com/nsight

You can try NSight but it does not allow debugging on a single GPU config (which I suppose is really absurd) and you need to have atleast 2 GPUs to debug your kernels on the device unlike the emuDebug, monitor global and shared memory etc.

Take a look: http://www.nvidia.com/nsight

Another trouble is that Nsight only works in Visata/win 7. I’m still with winXP, can’t use the software.

Another trouble is that Nsight only works in Visata/win 7. I’m still with winXP, can’t use the software.

Duplicated…

Duplicated…

I’ve read this thread and applied all the suggested solutions but the execution still refuses to pause inside a global function, though pausing within a host function within the same .cu file…

VS makes any breadpoint inside my global function inactive once I press F5 and says:

“The breakpoint will not currently be hit. No executable code is assosiated with this line
Possible causes include: preprocessor directives and compiler/linker optimizations.”

I’ve disabled all optimizations, both in VC++ and NVCC compilers, the linker doesn’t seem to be relevant to this…
Of course, I have the -deviceemu activated in EmuDebug, and ‘Generate debug information’ set ‘-D_DEBUG -D_WIN32’

The only NVCC compilation type that builds is 'Generate object hybrid file (–compile / -c), other settings here either return a CUDA build rule error or even cause the linker to crash… Maybe this is relevant to the inactive kernel breakpoints?