Question

I would like to ask how can we debug cuda kernel that is called from a mexfunction with VS 2010 and Nsight. I followed the instructions in http://http.developer.nvidia.com/NsightVisualStudio/2.2/Documentation/UserGuide/HTML/Content/Attach_CUDA_to_Process.htm but the attach button is not enabled in order to attach matlab.

PS: Win 7 64x, Matlab 2011 x64, VS 2010, CUDA SDK 5.5 64x, Nsight 3.1 64x, GForce 9600.

enter image description here

Was it helpful?

Solution

  1. Open Nsight Monitor Nsight Visual Studio Edition 3.1 -> Nsight Monitor
  2. Go the Nsight Monitor Options (on the left of taskbar) -> CUDA -> Use this Monitor for CUDA attach ->true
  3. Add environmental variable NSIGHT_CUDA_DEBUGGER = 1 via Advance System Settings -> Environmental Variables and add the aforementioned variable both in User and System variables in the two panels.
  4. Start Matlab and Visual Studio and try to attach Matlab with the Nsight debugger and qualifier the Computer name and that it is.

Tested on Matlab 2011a 64x and VS 2010 with SP1.

enter image description here

OTHER TIPS

It is enough to set the NSIGHT_CUDA_DEBUGGER environment variable just for MATLAB, so you don't have to slow down your entire system by having every process attachable. Quoting NVIDIA's Nsight documentation:

Setting NSIGHT_CUDA_DEBUGGER=1 can degrade the performance of an application, since the debugger is made resident. The effect is minimal on Tesla™ devices and headless devices; it is most severe on display devices with a desktop, where the debugger by necessity may need to serialize launches that would otherwise have been asynchronous. Therefore, it’s not always desirable to set NSIGHT_CUDA_DEBUGGER=1 at a system-wide or user-wide level.

To set it in a running MATLAB session (and spare the rest of your system):

>> setenv('NSIGHT_CUDA_DEBUGGER','1')

Hit Refresh or reselect the Nsight GPU Debugger and it works:

enter image description here

You still need to configure Nsight to allow attaching, but it's a one-time setting:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top