Berzelius VS Code Guide

1. Introduction

Visual Studio Code (VS Code) is a lightweight, open-source code editor developed by Microsoft. It supports a wide range of programming languages and remote development extensions.

This guide describes three methods for using VS Code with the Berzelius supercomputer:

  1. Running VS Code directly on Berzelius via ThinLinc.
  2. Using the Remote-SSH extension to connect from your local VS Code.
  3. Running VS Code Server on Berzelius and accessing it from a web browser.
  4. Using VS Code Remote Tunnels to connect via browser or desktop client.

Methods 1, 3, and 4 allow you to run VS Code directly on a compute node.

2. Using VS Code via ThinLinc

This method runs VS Code directly in a graphical ThinLinc session.

We provide a module for VS Code on Berzelius. After logging in through ThinLinc, you can launch VS Code with:

module load VSCode/latest-bdist
XDG_RUNTIME_DIR=~/.vscode/runtime code /your/working/dir

Make sure that the directory ~/.vscode/runtime exists.

3. Using VS Code with Remote-SSH

This method connects your local VS Code to Berzelius using SSH.

3.1 Installing VS Code Locally

Follow the official installation guide to install VS Code on your computer.

3.2 Installing Remote-SSH Extension

Click the Extensions tab in the left side panel. Search for “Remote-SSH” and install the extension.

Once it’s installed a new tab (Remote Explorer) will appear on the side panel.

3.3 Setting up SSH Connection

Click the Remote Explorer tab in the left side panel.

Press the plus (+) in the Remote Explorer tab to add a new ssh connection to Berzelius.



Input the ssh connection command.



Update the SSH configuration file. Just hit enter to make the updates. You only need to do it once.



Click the refresh icon in the Remote Explorer and you will see the new SSH connection.



Click “Connect in Current Window..” and Input your password and verification code.



Now you are connected to Berzelius.

3.4 Editing Files on Berzelius

You can use the Explorer tab to open your directory on Berzelius.

Click Explorer → Open Folder → Input your directory path. You need to input your password and verification code again.



3.5 Open a Terminal

You can have a terminal on Berzelius by clicking Terminal → New Terminal on the top menu bar.

This terminal gives you access to a fully functional shell running on Berzelius. From here, you can load modules, run scripts and binaries, submit and monitor SLURM jobs, etc.

Tip: You can open multiple terminals (each with a different working directory or environment) by clicking the “+” button in the terminal panel.

3.6 Close the Connection

You can terminate the ssh connection by clicking File → Close Remote Connection on the top menu bar.

4. Using VS Code Server in a Browser

This method runs a full-featured VS Code Server on a login/compute node, accessible via browser.

4.1 Loading the VS Code Server Module

To load the VS Code Server Module:

module load VSCode-Server/latest-bdist

4.2 Starting VS Code Server

In an interactive job on a compute node (e.g., node0xy, which is the hostname), you can start the server with the following command:

code-server --bind-addr node0xy:9988 ./your/working/dir

To check your current hostname, you can run

hostname

The port 9988 is arbitrary. if it’s already in use, feel free to try another one (e.g., 9989, 9990, etc.).

4.3 Setting up a SSH Tunnel

From your local computer, create an SSH tunnel:

ssh -N -L localhost:9988:node0xy:9988 <your username>@berzelius1.nsc.liu.se

4.4 Connecting to VS Code Server

Open your favorite browser and go to:

http://localhost:9988

The VS Code Server password can be found at /home/<your username>/.config/code-server/config.yaml.

5. Using VS Code with Remote Tunnels

5.1 Starting VS Code Tunnel on Berzelius

Create an interactive session:

interactive --gpus 1 -t 120 -A <your project account>

Load the VS Code module and start the tunnel:

module load VSCode/latest-bdist
code tunnel

You will see:

[xuan@node083 ~]$ module load VSCode/latest-bdist
*************************************************** 
You have loaded VSCode 1.100.3 
*************************************************** 
 
[xuan@node083 ~]$ code tunnel
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*

Open this link in your browser https://vscode.dev/tunnel/node027

You can now connect to the VS Code client on Berzelius through the tunnel using one of two options:

  • Your local browser
  • The Remote-Tunnels extension in VS Code

5.2 Using a Web Browser

You can open the link in your local browser and follow the steps for authorization. You can use either your GitHub or Microsoft account.



The VS Code environment in the browser is very similar to the desktop client, offering a familiar user experience.



5.3 Using the Remote-Tunnels extension in VS Code

On your local VS Code client, install the Remote-Tunnels extension.



After installing the Remote-Tunnels extension on your local machine, click the green “><” icon in the bottom-left corner of VS Code. Select “Connect to Tunnel…”, follow the authorization steps, and then choose the tunnel session that was previously created.


User Area

User support

Guides, documentation and FAQ.

Getting access

Applying for projects and login accounts.

System status

Everything OK!

No reported problems

Self-service

SUPR
NSC Express