Here are some quick instructions for running VS code on a PSC/Access/bridges compute node.
Why? It makes your VS Code session faster, and lets you run notebooks within VS Code without guilt.
It's awkward to connect to a compute node through VS code, since you have to go through a login node first. You can make it easier by setting up a new "host" in your ~/.ssh/config
file that defines the multi-hop connection.
Open your ~/.ssh/config
and add these lines (replacing YOUR_USER_NAME
with your user name on PSC).
Host bridges2
HostName bridges2.psc.edu
User YOUR_USER_NAME
Host r001
HostName r001.ib.bridges2.psc.edu
User YOUR_USER_NAME
ProxyCommand ssh bridges2 -W %h:%p
Host r002
HostName r002.ib.bridges2.psc.edu
User YOUR_USER_NAME
ProxyCommand ssh bridges2 -W %h:%p
This will add routes for the main login node bridges2, as well as two compute nodes: r001 and r002. These are most common for interactive sessions. If you need to use another node, just add another host.
Next, start an interactive session. I like to ssh bridges2
, then create a screen session (in case my connection drops)
# Start or resume a screen session named "A"
screen -dR A
Then launch an interactive session
# Start an interactive session with 8 CPUs for 2 hours
interact -n 8 -t 2:00:00
Once the interactive session starts, make a note of what node you were assigned. Then you can just sleep inside the terminal (so the scheduler doesn't automatically cancel the job) and minimize the terminal--we won't need it anymore.
# Sleep for 30 secs on repeat
watch sleep 30
Now you just need to open a remote VS Code session to the compute node. Open VS Code, click the "Open a Remote window" button in the lower left, select "Connect to Host". You should hopefully see the compute node where your interactive session is running in the dropdown (if not, return to Step 1). Once the session starts, you can open your project as usual.
When you're done, you just close everything in reverse
- Close the VS Code window
- Exit the interactive session running in the separate terminal
- Exit the screen session
If you forget, the interactive session will just run to completion, and then SLURM will kill everything for you.
See also this discussion (from @nx10).