Skip to main content

Use Visual Studio Code Tunnels for Development on Slurm

Using VS Code with SUNK to develop code on Compute nodes

With SUNK, development on Slurm Compute nodes can be conveniently handled by the Tunnel functionality in Visual Studio Code (VS Code).

With this method, you can connect to any Slurm-allocated Compute nodes using a VS Code Remote Tunnel, which you can manage through VS Code or the code Command Line Interface (CLI) on your workstation.

This guide will walk through the steps required to set up a VS Code Tunnel to connect to your Slurm Compute nodes.

Prerequisites

To follow along with this guide, you need:

  • An active CoreWeave account and an existing Slurm cluster
  • A GitHub or Microsoft account to connect to VSCode Tunnel.
  • If you would like to connect to the Compute node from a remote workstation, you will need the Microsoft Remote Tunnels extension installed and enabled in VS Code.

VS Code CLI

Download and install the VS Code CLI

Note

The commands in the following examples demonstrate the process for a GPU node with an Intel processor.

  1. Navigate to the Visual Studio Code Downloads page and select the appropriate option for your architecture. To download the code CLI as a standalone without the VS Code UI, select from the files on the line labeled CLI.

  2. Click the x64 download link for CLI in the Linux section. The file will download to your local workstation's download directory, but this copy can be ignored or deleted.

  3. Click the direct download link in the banner at the top of the screen and copy the URL. This is the URL you will paste into the curl command below.

  4. Navigate to your desired location in your cluster's shared storage, such as the home directory or /mnt/data.

    Example
    $
    cd /mnt/data
  5. Download the file with curl using the URL obtained from the direct download link in Step 3.

    Example
    $
    curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz
  6. Make a /bin directory in your $HOME folder, if it does not already exist.

    Example
    $
    mkdir -p $HOME/bin
  7. Unpack the file into the $HOME/bin directory.

    Example
    $
    tar -x --file=vscode_cli.tar.gz --directory=$HOME/bin
  8. Export $HOME/bin to your $PATH. This ensures that the code executable is in your system path every time you log in.

    Example
    $
    echo "export PATH=$PATH:$HOME/bin" >> ~/.bashrc

Connect to the Compute node with a Tunnel

Important

The Login node should only be used to gain access to the cluster, not to run Slurm commands. Always run resource-intensive commands on the Compute node.

  1. Log in to your Slurm cluster's Login node.

  2. Use srun to create an interactive session to a Compute node of your choice. The example below specifies one node in the h100 partition and launches bash.

    Example
    $
    srun -p h100 -N 1 --pty bash -i
    • -p h100 specifies the h100 partition.
    • -N 1 specifies one node as the target.
    • --pty bash -i launches bash with an interactive session on the specified Slurm node.
  3. Create the tunnel on the Compute node. Authenticate with your choice of GitHub or Microsoft, and provide a name for the machine. The default name is the name of the Compute node.

    Example
    $
    code tunnel

VS Code in browser

After running the code tunnel command demonstrated above, the CLI will return a URL to the remote machine, similar to the following:

Example
Open this link in your browser
https://vscode.dev/tunnel/slurm-h100-209-189

Click this URL to open VS Code in a client of your choice.

VS Code Desktop

After creating the tunnel with the code tunnel command, you can connect to it with VS Code from your local machine for ease of development. The Desktop version of VS Code requires the Microsoft Remote - Tunnels extension for VS Code to use this functionality.

You may interact with the Remote-Tunnels functionality through either the Remote Explorer tab or the Command Palette, to your preference.

Remote Explorer

You can view and connect to tunnels with the Remote Explorer in VS Code.

  1. Click the Remote Explorer icon on the VS Code Activity Bar.

  2. When prompted, specify whether you used GitHub or Microsoft to authenticate.

  3. After authenticating with the appropriate service, select the node you wish to connect to.

Command Palette

Access the Remote Tunnels functionality with VS Code's Command Palette.

  1. Open the Command Palette with Ctrl-Shift-P for Windows and Linux, or Shift-Command-P on Mac OS.

  2. Click Remote-Tunnels: Connect to Tunnel in the Command Palette.

  3. When prompted, specify whether you used GitHub or Microsoft to authenticate.

  4. After authenticating with the appropriate service, select the node you wish to connect to.