Way to debug PyOptiX applications

Hi,

I’m developping an application using PyOptiX and I’m passing a lot of time debugging my program manually.
I was wondering if there is a possibility to use Nsight on PyOptiX application to debug more easily ?
Because PyOptiX is launching using python, I don’t have a brut executable file to give to Nsight.
So I don’t know if it exists a way for Nsight to launch my program. I know that in one moment, the execution is passed to OptiX C++ compiled function, I was wondering if maybe we could read this execution.
In my case, it seems that PyOptiX is using a shared library file called optix.cpython-39-x86_64-linux-gnu.so.

I’m not familiar with Nsight GUI or command line, and I didn’t find ressources online concerning PyOptiX debugging options.
Thank you for your advices.

Could you please clarify what Nsight you’re referring to?

There are many tools named Nsight:
Nsight Systems for application profiling,
Nsight Compute for CUDA kernel profiling,
Nsight Graphics for OpenGL, Vulkan, DirectX profiling,
Nsight Visual Studio Edition under Windows for CUDA kernel debugging,
Nsight Eclipse Plugins under Linux for CUDA kernel debugging,
CUDA-GDB for CUDA kernel debugging.

Generally you would need to set the Python interpreter as executable inside any of these tools and define the command line running your Python program.
I think that would not allow setting breakpoints inside the Python source code though since they debuggers are for C/C++.
If you wanted to debug your Python host code, that would need to happen inside some Python development IDE.
(The last time I debugged Python host code was inside Visual Studio Code on Omniverse extensions and that worked OK. I have not used PyOptiX, yet.)

I can ask around internally after you clarified what you’re trying in what Linux development environment.

I would like to use Nsight Compute to mostly debug more easily OptiX C++ shaders raygen & closest_hit, and use the profiler incidentally.
I’m currently running my program on a CentOS 7 equiped with a Nsight Compute v2023.3.1.0 without admin permission.

Thank you for your help.

NSight Compute can only profile CUDA (OptiX) kernels, not debug them, so you use that to optimize correctly running device code.

You cannot debug faulty code with that. You can only find out where an individual kernel spends most of the time and analyze different versions of your code with baseline comparisons. You can also see CUDA source code and final SASS code side-by-side to see what is actually happening inside the final microcode on the GPU. Only that explains where performance goes.

Inside Nsight Compute, you would enter the command line with which you would normally start your Python program inside a console, then start the profiling with a set of CUDA performance analyses selected.
You can start that paused and then run to the next CUDA kernel by clicking on one of the CUDA API GUI buttons until you reach your raygen kernel you want to profile and then click profile.
Then all data is gathered by Nsight Compute and displayed in various modes, like summary, source code view etc.
For more information on Nsight Compute and tutorials, please visit: https://developer.nvidia.com/nsight-compute

For that to work with OptiX, you must compile your OptiX device code with line information and use the correct OptixModuleCompileOptions debugLevel (moderate).
https://raytracing-docs.nvidia.com/optix8/guide/index.html#program_pipeline_creation#7017

Never profile debug device code or with OptixModuleCompileOptions on full debug or with OptiX validation mode enabled!
The debug device code is completely different and much slower than fully optimized release code.

Ok,
Thank you for your help and clarification. I am sorry for my misunderstanding of Nsight Compute.

For debugging activity then, I should use Nsight Visual Studio Edition if I understood ?
Then with, can I directly launch my PyOptiX program with python and access to OptiX C++ shader activity ?

Thank you again.

For debugging activity then, I should use Nsight Visual Studio Edition if I understood ?
Then with, can I directly launch my PyOptiX program with python and access to OptiX C++ shader activity ?

NSight Visual Studio Edition (Nsight VSE) is for Windows Microsoft Visual Studio.
That is not the same as Microsoft Visual Studio Code, which is foremost an editor plus extensions which can build a development environment.

If you’re under Linux, as the optix.cpython-39-x86_64-linux-gnu.so filename implies, you would be using CUDA-GDB from the CUDA Toolkit for kernel debugging or Nsight Eclipse Plugins.

I’m not using Linux so I have zero experience with either.

Also OptiX kernel debugging might still not be fully functional.
Please read these search results on this forum: https://forums.developer.nvidia.com/search?q=debugging%20%23visualization%3Aoptix