Vscode to use virtual environment in remote computation node
I want to debug my code locally, so I tried to use vscode to connected to computation node.
Here is the steps:
- submit a batch job which already activate python virtual environment.
The virtual environment is in the workspace
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --partition=alpha
#SBATCH --cpus-per-task=1
#SBATCH --gres=gpu:1
#SBATCH --mem-per-cpu=11G
#SBATCH --output=/dev/null
#SBATCH --job-name="tunnel"
#SBATCH --time=8:00:00
source ~/virtual_env/bin/activate
/usr/sbin/sshd restart
/usr/sbin/sshd -D -p 2222 -f /dev/null -h ${HOME}/.ssh/id_ecdsa
- connnect to the compute node in vscode via Extension Remote-SSH.
Here is the content of ~/.ssh/config
Host login-node
HostName taurus.hrsk.tu-dresden.de
User user-name
PreferredAuthentications publickey
IdentityFile "where you store your id_ed25519 file locally"
IdentitiesOnly yes
Host compute-node
User user-name
PreferredAuthentications publickey
IdentityFile "where you store your id_ed25519 file locally"
ServerAliveInterval 240
ServerAliveCountMax 2
ProxyCommand ssh login-node "nc $(squeue --user your-user-name-for-submit-slurm-job --name=tunnel --states=R -h -O NodeList) 2222"
StrictHostKeyChecking no
Then I can debug my code locally, like in jupyter notebook.
But when I also open a terminal in vscode unter this condition, and source the virtual environment again to run the skript by commandline, it will get stuck.
And I can't use this virtual environment anymore. It seems like, that the files are damaged.