VSCode on compute node with Remote Tunneling extension

To run Visual Studio Code (VS Code) on compute node, it needs to install The Visual Studio Code Remote - Tunnels extension that lets you connect to the compute node via a secure tunnel. You can connect from a VS Code client anywhere, without the requirement of SSH.

Do once: Download 'code' CLI to your home directory

Login the login node with any ssh client.  Then download 'code' CLI using the following command in your home directory.

% curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz
% tar -xf vscode_cli.tar.gz

Do once: Install Visual Studio Code on your local device

To begin, you'll need to install Visual Studio Code (VS Code) on your personal device. The installation process is typically straightforward, but it can vary depending on your operating system—whether you're using Linux, Windows, or macOS. 

You can find the VS Code downloads for all supported platforms via the following link: VS Code Download.

Install Remote-Tunnels extension in VS Code

Click "Extensions" in VS Code

Enter "remote - ssh" to search the extension and then click "Install".

 

Setup VS Code Tunneling

1. Create VS Code server and secure tunnel on SuperPOD compute node

Start an interactive session in the compute node. For the example below, this requests a session in normal partition with 1 GPU. You can provide the parameter  --partition=<partition> and --account=<account> to specify other partition and account if necessary.

$ srun --partition=normal --account=<youraccount> --gres=gpu:1 --pty $SHELL

Start secure tunnel from compute node as below:

$ ./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).
*
? How would you like to log in to Visual Studio Code? ›
❯ Microsoft Account
  GitHub Account

Choose Microsoft Account and follow the instruction to sign on with your ITSC account. After successful authentication, you need to provide a arbitrary name to identify this vode server in the VSCode client. 

*
* 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
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code HGBBETJU6 to authenticate.
✔ What would you like to call this machine? (dgx-55) › superpod

 

The tunnel is enabled and just leave the connection there.

2.Connect to secure tunnel from local workstation

Back to your workstation, open VS Code and click on the "><" icon "Open a remote window" at the bottom left corner and click "Connect to tunnel" as shown  

Select "Microsoft account".

Select a path where the program will save the SSH connection information. The suggested default path is the .ssh directory in your home folder on Windows. 

Your session is ready and you can work on compute node directly, you may click "Open Folder" to enable file explorer

3. Open Folder on Remote Server

In VScode, click Explorer > Open Folder.

The open folder search box will automatically start in home directory of your user account. Click "OK" to confirm the location.

All files and folders show under EXPLORER. Click the file to edit your code. 

 

Reference: https://code.visualstudio.com/docs/remote/tunnels