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:
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.)
Open VSCode
Make sure to have the “Remote - SSH” extension and the “Remote - Tunnels” extension installed.
Log in or confirm that you’re logged into your Microsoft account on VSCode
If you’re not signed in, click the account icon on the bottom left and “sign in to sync settings”
“Ctrl + Shift + p” and search “Remote-Tunnels: Connect to Tunnel
Choose the account you logged in with
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.
Open VSCode
Used Ctrl+Shift+P and clicked Remote-SSH: Connect to host... to connect to hpc2.storrs.hpc.uconn.edu
Entered your password
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.
Run module load vscode
Run tunnel
Select "Microsoft Account" to log in and use your UCONN email
Enter the code at the link provided
Open a NEW VSCode window
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