Skip to content

Commit c4ef1be

Browse files
committed
improve VS Code docs when using more than one cluster
1 parent 8871039 commit c4ef1be

File tree

2 files changed

+67
-25
lines changed

2 files changed

+67
-25
lines changed

docs/access/vscode.md

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ This process is also demonstrated in a webinar on [Interactive computing on "Alp
2727

2828
The most flexible method for connecting VSCode is to log in to the Alps system, set up your environment (start a container or uenv, start a session on a compute node), and start the remote server in that environment pre-configured.
2929

30-
!!! note
31-
This approach requires that you have a GitHub account, and that the GitHub account is configured with your VS Code editor.
30+
[](){#ref-vscode-install}
31+
### Installing the server
3232

3333
The first step is to download the VS Code CLI tool `code`, which CSCS provides for easy download.
3434
There are two executables, one for using on systems with x86 or ARM CPUs respectively.
@@ -45,16 +45,15 @@ There are two executables, one for using on systems with x86 or ARM CPUs respect
4545
tar -xf vscode_cli_alpine_x64_cli.tar.gz
4646
```
4747

48-
!!! note
49-
See the guide on how to manage [architecture-specific binaries][ref-guides-terminal-arch] if you plan to use VScode on both x86 and ARM clusters.
48+
After downloading, copy the `code` executable to a location in your PATH, so that it is available for future sessions.
5049

51-
Alternatively, download the CLI tool from the [VS Code site](https://code.visualstudio.com/Download) -- take care to select either x86 or Arm64 version that matches the target system.
50+
Clusters on Alps share a common [home][ref-storage-home] path `HOME=/users/$USER` that is mounted on all clusters.
5251

53-
After downloading, copy the `code` executable to a location in your PATH, so that it is available for future sessions.
52+
If you want to use VS Code on multiple clusters, possibly with different CPU architectures (Daint, Clariden and Santis use `aarch64` CPUs, and [Eiger][ref-cluster-eiger] uses `x86_64` CPUs), you need to take some additional steps to ensure that VS Code installation and configuration is separated.
5453

55-
??? note "guidance on where to put architecture-specific executables"
56-
The home directory can be shared by multiple clusters that might have different micro-architectures, so it is important to separate executables for x86 and aarch64 (ARM) targets.
54+
First, install the `code` executable in an [architecture-specific path][ref-guides-terminal-arch].
5755

56+
!!! example "Installing VS Code for `x86_64` and `aarch64`"
5857
In `~/.bashrc`, add the following line (you will need to log in again for this to take effect):
5958
```
6059
export PATH=$HOME/.local/$(uname -m)/bin:$PATH
@@ -66,13 +65,50 @@ After downloading, copy the `code` executable to a location in your PATH, so tha
6665
mkdir -p $HOME/.local/$(uname -m)/bin
6766
cp ./code $HOME/.local/$(uname -m)/bin
6867
```
68+
Repeat this for both `x86_64` and `aarch64` binaries.
69+
70+
By default VS Code will store configuration, data and executables in `$HOME/.vscode-server`.
71+
To use VS Code on multiple clusters, it is strongly recommended that you create separate `vscode-server` path for each cluster
72+
by adding the following environment variable definitions to your `~/.bashrc`:
73+
74+
```bash
75+
export VSCODE_AGENT_FOLDER="$HOME/.vscode-server/$CLUSTER_NAME-tunnel/.vscode-server"
76+
export VSCODE_CLI_DATA_DIR="$VSCODE_AGENT_FOLDER/cli"
77+
```
78+
79+
!!! warning
80+
You will need to log out and back in after updating `$HOME/.bashrc`, before trying to start the VS Code server for the first time.
81+
82+
[](){#ref-vscode-update}
83+
### Updating VS Code server
84+
85+
VS Code is continuously being updated, and the version of VS Code on your laptop will most likely be more recent than the version provided by CSCS.
86+
87+
Once you have installed the server, you can easily update it to the latest version:
88+
89+
```console title="Updating VS Code server"
90+
$ code --version
91+
code 1.97.2 (commit e54c774e0add60467559eb0d1e229c6452cf8447)
92+
$ code update
93+
Successfully updated to 1.101.0 (commit dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1)
94+
$ code --version
95+
code 1.101.0 (commit dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1)
96+
```
97+
98+
It is good practice to periodically update code to keep it in sync with the version on your laptop.
99+
100+
[](){#ref-vscode-starting}
101+
### Starting and configuring the server
102+
103+
!!! note
104+
You need to have a GitHub account to connect a remote tunnel to VS Code.
69105

70106
To set up a remote server on the target system,
71-
run the `code` executable that you downloaded the `tunnel` argument.
107+
run the `code` executable that you downloaded with the `tunnel` argument.
72108
You will be asked to choose whether to log in to Microsoft or GitHub (we have tested with GitHub):
73109

74-
```
75-
> code tunnel --name=$CLUSTER_NAME-tunnel
110+
```console
111+
$ code tunnel --name=$CLUSTER_NAME-tunnel
76112
...
77113
? How would you like to log in to Visual Studio Code? ›
78114
Microsoft Account
@@ -85,8 +121,9 @@ You will be asked to choose whether to log in to Microsoft or GitHub (we have te
85121
You will be requested to go to [github.com/login/device](https://github.com/login/device) and enter an 8-digit code.
86122
Once you have finished registering the service with GitHub, in VSCode on your PC/laptop open the "remote explorer" pane on the left hand side of the main window, and the connection will be visible under REMOTES (TUNNELS/SSH) -> Tunnels.
87123

88-
!!! note "first time setting up a remote service"
124+
!!! note "First time setting up a remote service"
89125
If this is the first time you have followed this procedure, you may have to sign in to GitHub in VSCode.
126+
90127
Click on the Remote Explorer button on the left hand side, and then find the following option:
91128

92129
```
@@ -99,6 +136,7 @@ Once you have finished registering the service with GitHub, in VSCode on your PC
99136

100137
After signing in and authorizing VSCode, the open tunnel should be visible under REMOTES (TUNNELS/SSH) -> Tunnels.
101138

139+
[](){#ref-vscode-uenv}
102140
### Using with uenv
103141

104142
To use a uenv with VSCode, the uenv must be started before calling `code tunnel`.
@@ -124,6 +162,7 @@ Once the tunnel is configured, you can access it from VSCode.
124162
If you plan to do any intensive work: repeated compilation of large projects or running python code in Jupyter, please see the guide to running on a compute node below.
125163
Running intensive workloads on login nodes, which are shared resources between all users, is against CSCS [fair usage][ref-policies-fair-use] of Shared Resources policy.
126164

165+
[](){#ref-vscode-compute-nodes}
127166
### Running on a compute node
128167

129168
If you plan to do computation using your VSCode, then you should first allocate resources on a compute node and set up your environment there.
@@ -165,13 +204,10 @@ If you plan to do computation using your VSCode, then you should first allocate
165204
* `-n1` requests a single rank - only one rank/process is required for VSCode
166205
* `--pty` allows forwarding of terminal I/O, for bash to work interactively
167206

207+
[](){#ref-vscode-containers}
168208
### Using with containers
169209

170-
This will use CSCS's **[Container Engine][ref-container-engine]**.
171-
Using this workflow, one can pull a container from a registry like DockerHub.
172-
Note that this process also requires that you have a GitHub account, with an authentication and authorization step as described earlier.
173-
174-
This will also use the Remote Tunnel extension and the VS Code connected to the GitHub account (see above).
210+
This will use CSCS's [Container Engine][ref-container-engine], to launch the container on a compute node and start the VS Code server.
175211

176212
```toml title="EDF file with image and mount paths"
177213
image = "nvcr.io#nvidia/pytorch:24.01-py3" # example of PyTorch NGC image
@@ -184,19 +220,24 @@ workdir = "default/working/dir/path"
184220

185221
!!! note
186222
Ensure that the `code` executable is accessible in the container.
187-
It can either be contained in the image, or in one of the mounted folders.
223+
It can either be contained in the image, or you can [install][ref-vscode-install] and [update][ref-vscode-update] the server in a path that you [mount][ref-ce-edf-reference-mounts] inside the container in the `mounts` field of the EDF file.
188224

189-
```bash title="Launch container and tunnel"
225+
Log into the target system, and launch an interactive session with the container image:
226+
```console
190227
# launch container on compute node
191-
srun -N 1 --environment=/absolute/path/to/tomlfile.toml --pty bash
192-
193-
# start tunnel
228+
$ srun -N 1 --environment=/absolute/path/to/tomlfile.toml --pty bash
229+
```
194230

195-
cd path/for/code/executable/in/container
196-
./code tunnel --name=$CLUSTER_NAME-tunnel
231+
Then on the compute node, you can start the tunnel manually, following the prompts to log in via GitHub:
232+
```console
233+
$ cd path/for/code/executable/in/container
234+
$ ./code tunnel --name=$CLUSTER_NAME-tunnel
197235
```
198236

199237
## Connecting via VSCode UI
200238

201239
!!! warning
202-
This approach is not recommended, because while it may be easier to connect via the VS Code UI, it is much more difficult to configure the connection so that you can use uenv, containers or compute nodes.
240+
This approach is not recommended, and is not supported by CSCS.
241+
242+
It is relatively easy to connect to a log in node using the "Connect to Host... (Remote-SSH)" option in the VS Code GUI on your laptop.
243+
However, it is complicated and difficult to configure the connection so that the environment used by the VS Code session is in a uenv/container or on a compute node.

docs/software/container-engine/edf.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ If false, the container filesystem is read-only.
119119
writable = true
120120
```
121121

122+
[](){#ref-ce-edf-reference-mounts}
122123
### `mounts`
123124

124125
| | |

0 commit comments

Comments
 (0)