VS Code is a free editor from Microsoft, which is open source and support many useful extensions.
It may be a good alternative to terminal based editors (like vim, nano and Emacs) for some of our users.
Work with files on cluster, almost as if they would be on your own laptop
Great syntax highlighting, linting, etc. for many languages (using extensions). Tools for debuging
Extensions simplifying work with git (recommended: Git Graphs)
Graphs produced on server, can be viewed directly withing VS Code
When you are done editing - you can run sbatch job from terminal panel of VS Code
You can set up port forwarding
And more
IMPORTANT: don't run computations in VS Code!
Use VS Code only to edit scripts, use linting, etc.
Only run calculations using srun/sbatch
Download and install it on your local machine: download
Make sure you activated NYU VPN
VS Code Lock files shall NOT be saved in /home. Ways to achieve that
In extensions tab of VS Code find extension "Remote - SSH"
press settings icon -> Extension settings
Do one of the following:
Don’t use lock files (uncheck "Remote.SSH: Use Flock")
Store lock file in /tmp (check Remote.SSH: Lockfiles In Tmp)
Inside VS Code
F1
remote-ssh: Connect to Host
New host (or - Configure SSH host)
ssh <user>@greene.hpc.nyu.edu
specify the path to the file, where the configuration of this connection will be saved
More details here: https://code.visualstudio.com/docs/remote/ssh
VS Code connections causes a node process running from your user account to use a lot of CPU resources. For this reason, do NOT connect VS Code directly to the login nodes as your session will be killed. Please only connect to
Instead of typing your password every time you need to log in, you can also specify an ssh key.
Only do that on the computer you trust
Generate ssh key pair (terminal in Linux/Mac or cmd/WSL in Windows): https://www.ssh.com/ssh/keygen/
Note the path to ssh key files. Don't share key files with anybody - anybody with this key file can login to your account
Log into cluster using regular login/password and then add the content of generated public key file (the one with .pub) to $HOME/.ssh/authorized_keys on cluster
Next time you will log into cluster no password will be required.
You should ONLY use VS Code to connect to compute nodes in order to avoid high CPU usage on the login nodes, which will result in your session being killed.
Connecting to a compute node to requires several steps to properly route through Greene's login nodes to the compute nodes in use. Please follow these instructions to connect and run VSCode server on Greene compute node:
On Greene login node, submit a dummy Slurm job to sleep there, 1 CPU core and 1GB memory for 2 hours. This step will enable you to login to compute nodes you have jobs running there.
sbatch --time=02:00:00 --mem=1GB --wrap "sleep infinity"
After the job is running, please check the compute node this job is running there with squeue
[sw77@log-1 tmp]$ squeue -u sw77
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
23587213 cpu_gpu wrap sw77 R 18:29 1 gr070
In this example, the job is running on gr070
On your local computer, add this block to ~/.ssh/config file
Host greene-compute
HostName <Compute Node your Jupyter Notebook is using e.g. gr070>
User <NetID>
ProxyJump <NetID>@greene.hpc.nyu.edu
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
Here the ProxyJump is <NetID>@greene, if you are in campus, please change to YourNYUNetID@greene.hpc.nyu.edu. Please be sure to be connected to the NYU VPN (vpn.nyu.edu).
Set up ssh login to Greene with ssh key without password (see section above)
Now from VSCode, you can directly connect to greene-compute nodes with:
ssh greene-compute