Python remote debugging with PyCharm, CUDA, and Conda

Niranda Perera
1 min readMar 17, 2020

--

#DeepLearning, #CUDA, #PyTorch, #tensorflow are the hype in software engineering these days, and I am also working on some HPC-Deep learning integration.

One requirement I had was to create a debugging setup that includes PyCharm, CUDA, and Conda. I do not have an Nvidia GPU device on my laptop, but my workstation has one and I have ssh access to it. This I think, is a common setup for most of us, and hence I think this would be a quick summary of how you can set up ‘remote debugging’.

So, my setup is,

  • Local laptop without Nvidia device, running PyCharm Pro as the IDE
  • Remote workstation with an Nvidia device, running CUDA, and python environment running on Anaconda.
  • Remote access to the workstation is set up through ssh
  • Following test script (from PyCuda docs)

Steps:

Steps are quite straight forward. But there are a couple of ‘Aha…’ points!

  1. Create a new project and add the above test script.
  2. Add a new SSH remote interpreter for PyCharm. Refer PyCharm docs. In the interpreter, set python path to conda python binary (path from the remote machine). Ex: In my workstation, conda python was in /home/niranda/anaconda3/bin/python
  3. Setup remote debugging for the project. Refer PyCharm docs.
  4. This is the most important step. Set PATH and LD_LIBRARY_PATH in the debug configurations. These values should be taken from the remote machine.

That’s it! Now you can simply debug your code, pointing to the remote python interpreter than has CUDA, pycuda and/ or anything you like! :-)

Cheers

--

--