Search code examples
cudansight

let Nsight start debugging after certain kernel function is executed


My CUDA program have too many kernel functions and if I open the CUDA debugging mode, I'll have to wait for an whole hour after the breakpoint in certain kernel function is triggered.

Is there any way for Nsight to start debugging after certain kernel functions, or only debug the certain kernel function?

I'm using Nsight with VS2012


Solution

  • In theory you can follow the instructions in the Nsight help file (either the online help or local help. At the time of writing the page is here).

    In short:

    • In the Nsight Monitor options, CUDA » Use this Monitor for CUDA attach should be True.
    • Before starting your application, set an environment variable called NSIGHT_CUDA_DEBUGGER to 1.
    • Then in your CUDA kernel, you can add a breakpoint like this:

      asm("brkpt;");
      

    This will work similar to the __debugbreak() intrinsic or int 3 assembly instruction in host code. When hit you will get a dialog prompting you to attach the CUDA debugger.

    In practice, at least for me it Just Doesn't Work™. Maybe you'll have more luck.