Visual Studio Code (VSCode) Guide

What is VSCode?

Visual Studio Code, commonly known as VSCode, is a highly popular, free and open-source code editor developed by Microsoft. It’s available for Windows, Linux and macOS. VSCode is widely recognized for its performance, versatility and user-friendly interface, making it a preferred choice for developers across various programming languages and frameworks.

Why use VSCode?

One of the key strengths of VSCode is its versatility. It supports a wide range of programming languages on install and its functionality is greatly expanded through a large marketplace of extensions. Just to name a few, the extensions offer support for additional languages, debuggers, and tools for software development.

In an HPC environment, VSCode is well-suited with its various build and scripting tools as well as its recent remote developments. It allows users to stay on VSCode and connect to the cluster to work directly on their code utilizing the resources available.

 

Notice for VSCode on Storrs HPC

A common method of using VSCode to access compute nodes on the HPC establishes a directly SSH connection, circumventing our standard SLURM job scheduling process. This violates the Storrs HPC Usage Policy and users who choose the method will have there processes terminated. The latter approach disrupts the equitable distribution of HPC resources. Below we provide an alternate method to connect approved by Storrs HPC Admins.

How to Use VSCode on Storrs HPC?

In short, we use the Remote Tunnels by VSCode to connect.

To start srun/fisbatch to start an interactive session:

(base) [jth12004@login6 ~]$ srun --ntasks=1 --nodes=1 --partition=general --time=6:00:00 --pty bash srun: job 5341738 queued and waiting for resources srun: job 5341738 has been allocated resources (base) [jth12004@cn590 ~]$

Next load the VSCode module:

(base) [jth12004@cn590 ~]$ module load vscode/

Start the tunnel:

[jth12004@cn566 ~]$ module load vscode Loading vscode/2024 Loading requirement: slurm/slurm/22.05.9 pre-module post-module [jth12004@cn566 ~]$ 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). * ? How would you like to log in to Visual Studio Code? › ❯ Microsoft Account Github Account

You may choose either Microsoft or Github to log in. You should be able to login to Microsoft with your UConn email securely.

Go to https://microsoft.com/devicelogin and enter the code given:

image-20240118-223618.png

Choose your account to login.

If it is your first time tunneling, you might be asked to name the session.

Finally, using the given link, you should be able to access VSCode on your browser!

Connecting to this session via your local VSCode application

This section assumes you have started the tunnel from an ssh client (putty/mobaxterm/etc.)

  1. Open VSCode

  2. Make sure to have the “Remote - SSH” extension and the “Remote - Tunnels” extension installed.

  3. Log in or confirm that you’re logged into your Microsoft account on VSCode

    1. If you’re not signed in, click the account icon on the bottom left and “sign in to sync settings”

    2. image-20240123-172432.png
  4. “Ctrl + Shift + p” and search “Remote-Tunnels: Connect to Tunnel

  1. Choose the account you logged in with

  2. You should now see any session names and the node names as well as the status (online/offline) for selection

Properly exit VSCode

To end the session:

“ctrl+c” in the interactive session and “exit” when done.

This is to prevent any lingering processes to stay on the node that might disrupt future users.

Initiating Slurm Job Within VSCode

Instead of starting the slurm job from an ssh client it is possible to start it within VSCode as well.

  1. Open VSCode

  2. Used Ctrl+Shift+P and clicked Remote-SSH: Connect to host... to connect to hpc2.storrs.hpc.uconn.edu

  3. Entered your password

  4. In the login node terminal, enter srun --ntasks=1 --nodes=1 --partition=general --time=6:00:00 --pty bash to start a new interactive session.

  5. Run module load vscode

  6. Run tunnel

  7. Select "Microsoft Account" to log in and use your UCONN email

  8. Enter the code at the link provided

  1. Open a NEW VSCode window

  2. Continue with the previous section in this new window

 

Jupyter Notebooks on VSCode

 

Check out our guide here: Jupyter on VSCode - Storrs HPC - UConn Knowledge Base

 

Happy VSCoding!

~

Storrs HPC

hpc@storrs.uconn.edu