VS Code Server on HPC
One-time Setup
Install code-server
If you followed our software setup using pixi, install code-server with:
pixi global install code-server -c conda-forge
Alternatively, ask your IT admin to install code-server as a module, then load it with module load code-server (or similar) before running the script.
Usage
Submit the VS Code Server job and follow the prompts to connect. To do so, download the script to your home directory:
curl -O https://wanggroup.org/scripts/vscode_cumc_cloud.sh
Then modify the script as needed:
- Adjust memory and wall time requirements: Default to 15GB memory running 18 hours which typically works for moderate scale of computing.
- Add bash configurations before the launch command (e.g., custom paths from your
~/.bashrcor simply addsource ~/.bashrc).
And then submit the job:
bash vscode_cumc_cloud.sh -i <hpc_ip>
Note: Run the script with
bash(notsbatch) to validate inputs on the head node before job submission. This gives immediate feedback if code-server is not installed.
Connect
After the job starts, check the job output file for connection info:
cat vscode_<JOBID>.out
Replace <JOBID> with your actual job ID. You’ll see instruction like:
========================================
VS Code Server - Job 12345678
========================================
On your LOCAL machine, run:
ssh -N -L 9234:ondemand-dy-cpu2mem16a-2:9234 username@hpc_ip
Then open: http://127.0.0.1:9234
To stop: scancel 12345678
========================================
Extensions: /home/username/vscode-status/extensions
User data: /home/username/vscode-status/data
For a fresh start: rm -rf /home/username/vscode-status
Run the SSH tunnel command on your local machine, then open http://127.0.0.1:9234 in your browser.
Persistent Data
VS Code Server stores your settings and extensions in ~/vscode-status/:
| Directory | Contents |
|---|---|
data/ |
User settings, workspace state |
extensions/ |
Installed VS Code extensions |
job_<JOBID>/ |
Job-specific config files |
Extensions and settings persist across sessions. For a fresh start, remove the entire directory:
rm -rf ~/vscode-status
VS Code SSH Login Failure
If your HPC requires a one-time code (e.g., Authenticator or similar MFA) each time you connect, VS Code may fail to connect because it does not show the login prompt by default. To fix this, add the following line to your local VS Code settings.json:
"remote.SSH.showLoginTerminal": true
This ensures the terminal is automatically displayed when connecting via SSH, so you can type the one-time code when prompted.
Notes
- Cost: Terminate when done:
scancel <JOBID> - Extensions: Install extensions from the Extensions panel - they persist in
~/vscode-status/extensions/ - Python/R support and other user tips: Install the Python and R extensions for language support, then select your pixi environment as the interpreter. See also this page for other tips.