Running Visual Studio (VS) Code on Slurm Compute Nodes via VS Code Tunnel

Running Visual Studio (VS) Code on Slurm Compute Nodes via VS Code Tunnel

 

Overview

This workflow allows users to run VS Code entirely on a Slurm-allocated compute node, instead of running the VS Code Server on the login node.

Architecture:

Windows/Linux/macOS Laptop (VS Code Desktop or vscode.dev) HTTPS (TLS) Microsoft VS Code Tunnel Service Slurm Compute Node (Allocated Job) ------------------------------------------- VS Code CLI VS Code Server Extension Host Integrated Terminal Python / C++ / Git / Debugger

Advantages:

  • VS Code Server runs on the compute node.

  • No .vscode-server processes run on the login node.

  • CPU and memory usage are charged to the Slurm job.

  • Users still get IntelliSense, Git, debugging, terminals, extensions, and AI assistants.

Step 1. Request an Interactive Slurm job

Request an interactive compute node from Slurm.

HPC Cluster:

srun \ --partition=batch \ --nodes=1 \ --time=04:00:00 \ --cpus-per-task=4 \ --mem=4G \ --propagate=NONE \ --pty bash -l

Note: Please adjust the time, CPU count and memory allocation as needed.

DGX Cluster:

Request an interactive GPU node from Slurm.

srun \ --propagate=NONE \ --gres=gpu:1 \ --cpus-per-task=4 \ --time=04:00:00 \ --mem=80G \ --pty $SHELL -i

Please adjust the job runtime, CPU count, GPU count, and memory allocation as needed. The maximum job runtime on the DGX cluster is 7 days (168 hours), and the maximum number of GPUs that can be requested per job is 8.

Verify that you're on a compute node

Run:

hostname echo $SLURM_JOB_ID

Example output:

uagc25-02 349876

If a compute node hostname and a valid Slurm job ID are displayed, the interactive job has started successfully.

Step 2. Download the Standalone VS Code CLI (One-Time Setup)

Create a directory for the CLI.

mkdir -p /network/rit/lab/<your lab folder>/software/vscode-cli cd /network/rit/lab/<your lab folder>/software/vscode-cli

Download the standalone CLI.

curl -L \ 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' \ --output vscode_cli.tar.gz

Extract it.

tar -xf vscode_cli.tar.gz

Verify installation.

./code --version

Step 3. Start a VS Code Tunnel

Run

./code tunnel --accept-server-license-terms

The CLI will ask:

How would you like to log in? Microsoft Account GitHub Account

Use up-down arrow to choose. Here, for example:

GitHub

Step 4. Authenticate

Open the URL displayed by the CLI, for example

https://github.com/login/device

Complete GitHub authentication.

After authentication, the CLI asks for a tunnel name.

Example:

What would you like to call this machine? vscode-slurm

You could input any name you like but machine names must be 20 characters or fewer.

Step 5. Tunnel Starts

The CLI prints something similar to

Visual Studio Code Tunnel Tunnel: vscode-slurm Open: https://vscode.dev/tunnel/vscode-slurm/...

Keep this process running.

Do not close the Slurm job or press Ctrl+C.

Step 6: Connect VS Code

There are two different connections. One is the VS Code Web, the other is the VS Code Desktop.

Step 6A. Connect Using VS Code Web

Open the URL printed by the CLI in your browser.

Example:

https://vscode.dev/tunnel/vscode-slurm/...

The browser asks

What type of account did you use to start this tunnel?

Choose

GitHub

Sign in with the same GitHub account used when creating the tunnel.

After authentication, the VS Code Web interface opens and connects directly to the compute node.

Step 6B. Connect Using VS Code Desktop (Recommended)

Step 1. Install the Remote - Tunnels Extension

Open Extensions (Ctrl+Shift+X).

Search for

Remote - Tunnels

Install the extension.

Step 2. Sign in to GitHub

If VS Code is not already signed in, click the Accounts icon (bottom-left corner).

Select:

Sign in to use GitHub Copilot...

Although it mentions Copilot, this signs VS Code into your GitHub account, which is also used by the Remote - Tunnels extension.

Important: Use the same GitHub account that was used to run code tunnel on the compute node.

After signing in, restart VS Code Desktop if necessary.

Step 3. Connect to the Tunnel

Press

Ctrl+Shift+P

Search for:

Remote Tunnels

or

Connect to Tunnel

You should see the tunnel you created:

vscode-slurm

Select it.

VS Code Desktop will connect directly to the compute node.

Step 7. Open a Terminal

In either VS Code Web or Desktop:

Terminal → New Terminal

or press

Ctrl + Shift + `

The terminal opens on the compute node.

Example prompt:

(base) bash-5.1$

Step 8. Navigate to Your Project

The terminal behaves like any Linux terminal.

Examples:

pwd ls cd .. cd ~/project

Step 9. Open a Different Folder

The Explorer does not automatically follow the terminal.

To change the workspace:

File → Open Folder...

or

Ctrl+Shift+P File: Open Folder...

Choose your project directory, for example

/network/rit/lab/<your lab folder>/head01

The Explorer will now show the selected project.

Step 10. Verify You're on the Compute Node

Run

hostname echo $SLURM_JOB_ID pwd

You should see

uagc25-02 349876 /network/rit/lab/<your lab folder>/openclaw_test

confirming that the terminal is executing on the Slurm compute node.