How can I debug the .cu shaders of OptiX in linux

Hi, I try to debug the optix-advanced-examples in linux.
My platform is Ubuntu 18.04 with a gtx 1080ti, optix 6.5. The example can run well.

I try to debug the .cu shaders, which are compiled into ptx files. I’ve only find guidance of the debug with Nsight VSE, but it’s not supported in Linux. I try to debug with cuda-gdb, but I fail to set breakpoint in neither .cu files nor .ptx files.

Can I get some guidance about the debug in Linux?

are you chinese?is your name your qq number?can i contact you? im chinese too, i also met same problem.

Yes, I’ve send friend request to you if your name is your qq id.

Can anyone help me?

Hi, here is a list of things you can check:

  • Use OPTIX_COMPILE_OPTIMIZATION_LEVEL_0
  • Use OPTIX_COMPILE_DEBUG_LEVEL_FULL
  • Install the latest driver, if you haven’t already
  • Install the latest version of cuda_gdb, if you haven’t already

Note that cuda-gdb debugging is not up to the same level of OptiX support as Nsight VSE. With cuda-gdb, breakpoints will usually work, but you will not be able to step through source code, you can only step through assembly. You can currently monitor registers, but not local variables. This means that you might be able to find out where something crashes, but stepping through an algorithm can be very difficult. The tools team is working on improving the cuda-gdb experience, I just want you to be aware that it’s not easy to use for general debugging yet.

You might also explore passing the mouse click coordinates to your OptiX program, and put printf() inside an if() block that checks whether the current launch index matches the mouse click coordinates. If your program is not crashing, then another suggestion is to use your OptiX shaders to display debug information to the screen visually, for example color pixels red if they meet some criteria. These are not ideal solutions, but they can be very useful in many situations.


David.

The first two flags are for OptiX 7.0.0 though and are used to control the module compile and pipeline link options.

Also make sure your CUDA compiler command line options contain --generate-line-info (or shorter -lineinfo).
Otherwise Nsight wouldn’t be able to match PTX code lines to the original CUDA source locations.

Thanks for your answer and suggestion @droettger. Hope there be an awesome tool like Nsight VSE someday in linux platform.