Files
caubet_m 95bc4f32cb
Build and deploy documentation / build-and-deploy-docs (push) Successful in 20s
fix empty space vscode
2026-04-27 14:45:30 +02:00

3.6 KiB

Visual Studio Code

Visual Studio Code can be used on Merlin7 with the Remote - SSH extension. The recommended workflow is to start a normal non-X11 interactive Slurm session and connect VS Code to the allocated compute node.

!!! danger "Do not run VS Code on login nodes" Do not start VS Code directly on Merlin7 login nodes.

Login nodes are not meant for CPU-intensive, memory-intensive, or long-running VS Code workloads.
Running VS Code there **can slow down the system for all users** and may lead to your session or
process **being terminated by administrators**.

Start an [interactive session](/merlin7/03-Slurm-General-Documentation/interactive-sessions/) first,
then connect VS Code to the allocated compute node.

!!! warning "Do not use X11 mode for VS Code" Use the default non-X11 mode:

```bash
interactive
```

Do **not** use `interactive --x11` for VS Code Remote SSH. X11 sessions are not detachable and are intended for foreground graphical applications.

VS Code via interactive sessions

1. Start an interactive session

From a Merlin7 login node, start a normal interactive session:

interactive

For more resources, pass Slurm options after --:

interactive -- --cpus-per-task=8 --mem=16G

!!! tip "Request resources with --cpus-per-task" For most VS Code workflows, request CPUs with --cpus-per-task.

Avoid requesting more CPUs or memory than needed for an editor, terminal, notebook, or compile session.

The allocation is detachable. You may leave the shell with:

exit

The allocation remains active.

!!! warning "Cancel the allocation when finished" In non-X11 mode, exit does not stop the Slurm allocation.

When you are done, cancel it explicitly:

```bash
interactive --cancel
```

2. Generate the VS Code SSH config

After creating the allocation, print the VS Code SSH configuration snippet:

interactive --print-vscode

Copy the printed Host block into the SSH config file on your local computer:

~/.ssh/config

!!! tip "Use --print-vscode after each new allocation" The allocated compute node may change whenever you create a new session.

Run this command again after creating a new allocation and update your local SSH config:

```bash
interactive --print-vscode
```

3. Connect from VS Code

On your local computer:

  1. Open Visual Studio Code.
  2. Open the command palette.
  3. Select Remote-SSH: Connect to Host....
  4. Choose the host name from the generated SSH config block.
  5. Open your working directory on Merlin7.

VS Code should now start its remote server on the allocated compute node.

To check, open a VS Code terminal and run:

hostname -f

The output should be a compute node, for example:

cn001.merlin7.psi.ch

!!! warning "Check where VS Code is running" If hostname -f shows a login node, disconnect and check your SSH configuration.

Troubleshooting

No active allocation found

Create one first:

interactive
interactive --print-vscode

The compute node changed

Regenerate the config snippet and update your local ~/.ssh/config:

interactive --print-vscode

VS Code stopped working

Check whether the allocation is still active:

interactive --status

If it has ended, create a new allocation and regenerate the VS Code SSH config.

VS Code via Open OnDemand

{% include-markdown "merlin7/06-Software-Support/includes/open-ondemand-alternative.md" %}