How could I debug in pycharm in a stable ssh link rather than reconneting ssh each time I debug?

Viewed 61

I'm running deep learning codes.

My pc is poor so I'm using pycharm which connects remote server by ssh.

Here comes the problem:

  1. The default server environment doesn't connect to gpu
  2. I need to use commond like salloc --cpus-per-task=4 --gres=gpu:tesla_v100-pcie-32gb:1 -t 20:0:0 to getting into a new environment which connect to gpu.
  3. When I press RUN or DEBUG in pycharm, it will start a new ssh connection, rushing into the default environment which doesn't connect to gpu. RUN button and DEBUG button

What I know is that: I can use terminal to salloc and then use commond python xx.py to run the script. But what I really want is to use the fantastic DEBUG function of pycharm.What I know about terminal

What I have tried are as follows:

  1. I tried to use os.system("salloc --cpus-per-task=4 --gres=gpu:tesla_v100-pcie-32gb:1 -t 20:0:0") at the beginning of python script. But unfortunately, the program stuck after this command, and getting into a shell openned by sallocmy code result after pressing RUN the program didn't stop
  2. I assumed after the operation of 1, the ssh connection should on the salloced session. So I annotated the os code, and stop and RE-RUN. It failed. Maybe pycharm reconnect ssh to the default environment which doesn't connect to gpu.my modified code result after RE-RUN

Here is my final question: How to let pycharm use some command to salloc an environment on the ssh server first and then RUN or DEBUG my code?

Similar discussions can be found here: Running remote interpreter on a cluster with srun

0 Answers
Related