You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/access/vscode.md
+81-40Lines changed: 81 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
[](){#ref-access-vscode}
2
-
# Connecting with VSCode
2
+
# Connecting with VS Code
3
3
4
4
[Visual Studio Code](https://code.visualstudio.com/) provides flexible support for remote development.
5
-
VSCode's [remote tunnel feature](https://code.visualstudio.com/docs/remote/tunnels) starts a server on a remote system, and connects the editor to this server.
5
+
VS Code's [remote tunnel feature](https://code.visualstudio.com/docs/remote/tunnels) starts a server on a remote system, and connects the editor to this server.
6
6
There are two ways to set up the connection:
7
7
8
8
* using the code CLI: the most flexible method if using containers or uenv.
9
-
* using the VSCode interface: VSCode will connect onto the system, download and start the server
9
+
* using the VS Code interface: VS Code will connect onto the system, download and start the server
10
10
11
-
The main challenge with using VSCode is that the most convenient method for starting a remote session is to start a remote tunnel from the VS Code GUI.
11
+
The main challenge with using VS Code is that the most convenient method for starting a remote session is to start a remote tunnel from the VS Code GUI.
12
12
This approach starts a session in the standard login environment on that node, however this won't work if you want to be developing in a container, in a uenv, or on a compute node.
13
13
14
14
This process is also demonstrated in a webinar on [Interactive computing on "Alps"](https://www.cscs.ch/publications/tutorials/2025/video-of-the-webinar-interactive-computing-on-alps):
@@ -25,10 +25,10 @@ This process is also demonstrated in a webinar on [Interactive computing on "Alp
25
25
26
26
## Flexible method: remote server
27
27
28
-
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.
28
+
The most flexible method for connecting VS Code 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.
29
29
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
32
32
33
33
The first step is to download the VS Code CLI tool `code`, which CSCS provides for easy download.
34
34
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
45
45
tar -xf vscode_cli_alpine_x64_cli.tar.gz
46
46
```
47
47
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.
50
49
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.
52
51
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.
54
53
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].
57
55
56
+
!!! example "Installing VS Code for `x86_64` and `aarch64`"
58
57
In `~/.bashrc`, add the following line (you will need to log in again for this to take effect):
59
58
```
60
59
export PATH=$HOME/.local/$(uname -m)/bin:$PATH
@@ -66,27 +65,65 @@ After downloading, copy the `code` executable to a location in your PATH, so tha
66
65
mkdir -p $HOME/.local/$(uname -m)/bin
67
66
cp ./code $HOME/.local/$(uname -m)/bin
68
67
```
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`:
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.
69
105
70
106
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.
72
108
You will be asked to choose whether to log in to Microsoft or GitHub (we have tested with GitHub):
73
109
74
-
```
75
-
> code tunnel --name=$CLUSTER_NAME-tunnel
110
+
```console
111
+
$code tunnel --name=$CLUSTER_NAME-tunnel
76
112
...
77
113
? How would you like to log in to Visual Studio Code? ›
78
114
Microsoft Account
79
115
❯ GitHub Account
80
116
```
81
117
82
118
!!! tip
83
-
Give the tunnel a unique name using the `--name` flag, which will later be listed on the VSCode UI.
119
+
Give the tunnel a unique name using the `--name` flag, which will later be listed on the VS Code UI.
84
120
85
121
You will be requested to go to [github.com/login/device](https://github.com/login/device) and enter an 8-digit code.
86
-
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.
122
+
Once you have finished registering the service with GitHub, in VS Code 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.
123
+
124
+
!!! note "First time setting up a remote service"
125
+
If this is the first time you have followed this procedure, you may have to sign in to GitHub in VS Code.
87
126
88
-
!!! note "first time setting up a remote service"
89
-
If this is the first time you have followed this procedure, you may have to sign in to GitHub in VSCode.
90
127
Click on the Remote Explorer button on the left hand side, and then find the following option:
91
128
92
129
```
@@ -97,11 +134,12 @@ Once you have finished registering the service with GitHub, in VSCode on your PC
97
134
98
135
If you have not signed in to GitHub with VS Code editor, you will be redirected to the browser to sign in.
99
136
100
-
After signing in and authorizing VSCode, the open tunnel should be visible under REMOTES (TUNNELS/SSH) -> Tunnels.
137
+
After signing in and authorizing VS Code, the open tunnel should be visible under REMOTES (TUNNELS/SSH) -> Tunnels.
101
138
139
+
[](){#ref-vscode-uenv}
102
140
### Using with uenv
103
141
104
-
To use a uenv with VSCode, the uenv must be started before calling `code tunnel`.
142
+
To use a uenv with VS Code, the uenv must be started before calling `code tunnel`.
105
143
Log into the target system and start the uenv, then start the remote server, for example:
106
144
```
107
145
# log into daint (this could be any other Alps cluster)
@@ -118,15 +156,16 @@ ssh daint
118
156
uenv run --view=default prgenv-gnu/24.11:v1 -- code tunnel --name=$CLUSTER_NAME-tunnel
119
157
```
120
158
121
-
Once the tunnel is configured, you can access it from VSCode.
159
+
Once the tunnel is configured, you can access it from VS Code.
122
160
123
161
!!! warning
124
162
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.
125
163
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.
126
164
165
+
[](){#ref-vscode-compute-nodes}
127
166
### Running on a compute node
128
167
129
-
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.
168
+
If you plan to do computation using your VS Code, then you should first allocate resources on a compute node and set up your environment there.
130
169
131
170
!!! example "directly create the tunnel using srun"
132
171
You can directly execute the `code tunnel` command using srun:
@@ -137,7 +176,7 @@ If you plan to do computation using your VSCode, then you should first allocate
137
176
138
177
* `--uenv` and `--view` set up the uenv
139
178
* `-t120` requests a 2 hour (120 minute) reservation
140
-
* `-n1` requests a single rank - only one rank/process is required for VSCode
179
+
* `-n1` requests a single rank - only one rank/process is required for VS Code
141
180
* `--pty` allows forwarding of terminal I/O, required to sign in to Github
142
181
143
182
Once the job allocation is granted, you will be prompted to log into GitHub, the same as starting a session on the login node.
@@ -162,16 +201,13 @@ If you plan to do computation using your VSCode, then you should first allocate
162
201
```
163
202
164
203
* `-t120` requests a 2 hour (120 minute) reservation
165
-
* `-n1` requests a single rank - only one rank/process is required for VSCode
204
+
* `-n1` requests a single rank - only one rank/process is required for VS Code
166
205
* `--pty` allows forwarding of terminal I/O, for bash to work interactively
167
206
207
+
[](){#ref-vscode-containers}
168
208
### Using with containers
169
209
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.
175
211
176
212
```toml title="EDF file with image and mount paths"
177
213
image = "nvcr.io#nvidia/pytorch:24.01-py3"# example of PyTorch NGC image
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.
188
224
189
-
```bash title="Launch container and tunnel"
225
+
Log into the target system, and launch an interactive session with the container image:
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
197
235
```
198
236
199
-
## Connecting via VSCode UI
237
+
## Connecting via VS Code UI
200
238
201
239
!!! 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.
0 commit comments