Writing an extension called by python (in C, C++ or CUDA)? Not working? Typical.
When doing the same from R it’s pretty easy to debug, just run with R -d <debugger name> e.g. R -d valgrind or R -d gdb you get into the debugger, continue, then run interactively as usual. (For a more complex example using both at once see this blog post).
Doing this from python seems trickier to me. I started off following this guide: https://johnfoster.pge.utexas.edu/blog/posts/debugging-cc%2B%2B-libraries-called-by-python/
But I’m not really an ipython user, and prefer gdb over lldb (due to familiarity). I think this is a good way to do this if you need an interactive python session, but really this is overcomplicated for my typical use case.
Now all I do is run (say I’m debugging CUDA code):
Then in the debugger (an example with pp-sketchlib):
set args ~/installs/pp-sketchlib/pp_sketch-runner.py --sketch --rfile rfile_test.txt --ref-db Pf6 --cpus 8 --use-gpu r
Works just fine! (as long as you remember to compile with the debug flags on)