Skip to content

Using Visual Studio Code (VS Code)

Prerequisites

To work through these guides you must

  • Be a member of a project in the BriCS portal
  • Have followed the instructions in Getting Started to set up SSH login and create a valid SSH certificate for authenticating to BriCS facilities (using the clifton command line tool)

Additionally, a GitHub account is required when following the instructions connect to VS Code running on a compute node

Start an interactive VS Code session on a compute node

This guide outlines a procedure for starting a VS Code remote tunnel that allows a VS Code session on your computer (via a web browser or VS Code desktop application) to use a Grace Hopper Superchip on a compute node interactively.

Install VS Code CLI

Connect to a login node over SSH, following the instructions in the guide on logging in.

Download the VS Code standalone CLI, extracting the archive and placing the binary in a suitable location, e.g.

curl --location --output vscode_cli.tar.gz "https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-arm64"
mkdir -p ~/opt/vscode_cli
tar -C ~/opt/vscode_cli --extract --verbose --file vscode_cli.tar.gz

The code CLI should now be runnable, e.g.

$ ~/opt/vscode_cli/code --version
code 1.91.1 (commit f1e16e1e6214d7c44d078b1f0607b2388f29d729)

Submit a job to start a code tunnel

From the login node, submit a job which runs code tunnel on a compute node, e.g. using the submission script submit_example_vscode_code_tunnel.sh

submit_example_vscode_code_tunnel.sh
#!/bin/bash

#SBATCH --job-name=code_tunnel
#SBATCH --gpus=1            # this also allocates 72 CPU cores and 115GB memory
#SBATCH --time=1:00:00
#SBATCH --output=code_tunnel_%j.out

# Start named VS Code tunnel for remote connection to compute node
~/opt/vscode_cli/code tunnel --name "i-ai_compute"

and the sbatch command:

$ sbatch submit_example_vscode_code_tunnel.sh
Submitted batch job 16050

Once the job starts running, examine the output file (named code_tunnel_<JOB_ID>.out), e.g.

*
* 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).
*
[Timestamp] info Using GitHub for authentication, run `code tunnel user login --provider <provider>` option to change this.
To grant access to the server, please log into https://github.com/login/device and use code ABC1-DEF2

Open this link in your browser https://vscode.dev/tunnel/{your-tunnel-name}/lus/lfs1aip1/home/{your-project}/{your-user-name} 

The output indicates your remote VS Code server is up running and using GitHub for authentication (no need to run anything to change login provider).

Now go to https://github.com/login/device and use code given ("ABC1-DEF2" in the above example) to authenticate server access.

Connect VS Code in a web browser

At this point you can access the the VS Code server on the compute node using a web browser following the instructions in the job output file.

Open the vscode.dev link shown in the job output file (code_tunnel_<JOB_ID>.out) in a web browser and when prompted select "GitHub" as the type of account to connect

Screenshot of VS Code web connecting to tunnel

After you have authenticated yourself with GitHub account, you are set to work on VS Code in the browser

Screenshot of VS Code web connecting to tunnel

Connect VS Code desktop application

Additional prerequisites for desktop VS Code

In order to connect a desktop VS Code application (not browser-based) running on your computer to a remote VS Code tunnel on a compute node, please ensure that you have the latest version of Visual Studio Code installed with the Remote Tunnels extension. You can install this from the Extensions view (Ctrl+Shift+X or Cmd+Shift+X on Mac) by searching for "Remote - Tunnels".

It is also recommended to install the Remote Explorer, which provides the Remote Explorer view in VS Code where remote connections can be managed.

You can also set up a desktop VS Code application to access the compute node.

We recommend you first test connecting via a browser before trying desktop access.

To access your VS Code Server running on a compute node via the VS Code desktop application, please ensure you have a VS Code installation on your computer that meets the prerequisites outlined above. Then start a VS Code tunnel job noting the tunnel name you set up in your sbatch script, e.g. "i-ai_compute" in the example above. Once the vscode.dev link has been generated, follow these steps in your VS Code desktop application:

  1. Open Command Palette: In VS Code, press Ctrl+Shift+P (Cmd+Shift+P on Mac) to open the Command Palette.

  2. Connect to tunnel: Type Remote-Tunnel: Connect to Tunnel... and select GitHub from the dropdown box

    Screenshot of VS Code desktop connecting to tunnel

  3. Authenticate: If prompted, authenticate using your GitHub account for the tunnel.

    Screenshot of VS Code desktop authenticating with GitHub

    This step ensures a secure connection to your VS Code Server instance running on the worker node.

  4. Enter tunnel details: This will be your tunnel name, e.g. "i-ai_compute". Select this name to connect.

    Screenshot of VS Code desktop connected

  5. Establish Connection: VS Code should now connect to the remote environment via the tunnel, providing access to the remote file system and integrated terminal on the compute node.

Use VS Code empty profile for debugging issues

If you have problem connect, you can try using a empty profile, where you can start a VS Code without any extensions.

Happy coding!

Stop the interactive session

Once you have finished working interactively with VS Code on the compute node, please cancel the job to release resources for other users.

Connect to a login node over SSH, following the instructions in the guide on logging in.

Cancel the job using the job ID returned by the sbatch command used to submit the code tunnel job

scancel <JOB_ID>

substituting <JOB_ID> for the job ID output by the sbatch command used to the start the job.

Finding the job ID

To find the job IDs of your currently scheduled jobs, use squeue, e.g.

$ squeue --me
JOBID         USER PARTITION                     NAME ST TIME_LIMIT       TIME  TIME_LEFT NODES NODELIST(REASON)
17886 user.project     workq              code_tunnel PD    1:00:00       0:00    1:00:00     1 (Priority)