...
Visual Studio Code is usually started on a localhost, which results in starting a local application to interact with the GUI.
On Ares and Athena, we cannot easily expose the GUI to the external world, as calculations are done internally on a computing node, not visible from the Internet.
Therefore, in ACC Cyfronet we have prepared start-vscode-web
a script that can be used easily with the VSCode module. In this guide, we will explore how to use it to start a VSCode web session.
The trick is to start the VSCode webserver via a job submitted to a computing node and creating a create an SSH tunnel to access it on a local PC.
Create the following file:
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/bash
#SBATCH --partition plgrid
#SBATCH --nodes 1
#SBATCH --ntasks-per-node 6
#SBATCH --time 0:30:00
#SBATCH --job-name code-server
#SBATCH --output code-server-log-%J.txt
module load vscode/1.86.1
mkdir -p $SCRATCH/vscodedata
ln -s $TMPDIR /tmp/${SLURM_JOB_ID}
export TMPDIR=/tmp/${SLURM_JOB_ID}
## start an rserver instance
start-vscode-web --server-data-dir $SCRATCH/vscodedata |
...
Send job to queue using sbatch
command on the login node of Ares
Code Block | ||
---|---|---|
| ||
sbatch vscode-run.slurm |
Wait until your job enters the running state.
To check the status of the submitted job using using squeue
command
Code Block | ||
---|---|---|
| ||
squeue -j <JobID> |
or all jobs of the user
Code Block | ||
---|---|---|
| ||
squeue -u $USER |
which lists all current user jobs submitted to the queue ($USER
- is an environment variable).
...
PD - PENDING
- Job is awaiting resource allocation.R - RUNNING
- Job currently has an allocation and is running. CF - CONFIGURING
- Job has been allocated resources, but are is waiting for them to become ready for use (e.g. booting). On Ares Ares CF
state state could last for up to 8 minutes in case when nodes that have been in power save mode. CG - COMPLETING
- Job is in the process of completing. Some processes on some nodes may still be active.When the job will startstarts, it will create a file named code-server-log-<jobID>.txt
in the folder from which the sbatch command was called. Go to this directory and use cat
to see the contents of VSCode log file:
...
Code Block | ||
---|---|---|
| ||
Copy/Paste this in your local terminal to ssh tunnel with remote ----------------------------------------------------------------- ssh -o ServerAliveInterval=300 -N -L 9633:172.22.17.186:9633 plguser@ares.cyfronet.pl ----------------------------------------------------------------- Then use Web UI link located at the end of the log in your web browser: * * 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). * Web UI available at http://localhost:9633?tkn=ee8e3c6e34ad22ea267a9532635cabe8d1b5fbc59b8705e91737a6129a866b5b |
In At the top, we can see a command prepared for you to run in your local terminal.
Copy it and execute it in your local terminal:
Code Block | ||
---|---|---|
| ||
ssh -o ServerAliveInterval=300 -N -L 9633:172.22.17.186:9633 plguser@ares.cyfronet.pl |
...
To preserve the VSCode server data and VSCode environment, use the option --server-data-dir
pointing at some directory of your choice. The location should be the same each time to save configuration. In this example, we have used $SCRATCH/vscodedata
path as the storage location.
if If you wish to to end your sbatch, use scancel <JOBID>
command, where JOBID is your tunnel JOBID you can look it up with hpc-jobs
or squeue -u $USER
commands.
...
To check information about finished and historic jobs use hpc-jobs-history
command. For example with the option "-d 30" that command shows all user's jobs from the last 30 days. More info in hpc-jobs-history -h
.
...
To use on Athena supercomputer, you need to change --partition
to plgrid-gpu-a100
and name of the module to load: VSCode/1.85.0
.
Skrypt z tymi zmianami znajduje się poniżejThe script with those modifications can be found below:
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/bash
#SBATCH --partition plgrid-gpu-a100
#SBATCH --nodes 1
#SBATCH --ntasks-per-node 6
#SBATCH --time 0:30:00
#SBATCH --job-name code-server
#SBATCH --output code-server-log-%J.txt
module load VSCode/1.85.0
mkdir -p $SCRATCH/vscodedata
ln -s $TMPDIR /tmp/${SLURM_JOB_ID}
export TMPDIR=/tmp/${SLURM_JOB_ID}
## start an rserver instance
start-vscode-web --server-data-dir $SCRATCH/vscodedata |
Another way to use the VSCode remotely on the cluster is via a tunnel with a standard desktop GUI. Using this approach is similar with the one for setting up web browser access.
To begin with, we need to install the extension