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.
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 first, then connect VS Code to the allocated compute node.
Do not use X11 mode for VS Code
Use the default non-X11 mode:
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:
For more resources, pass Slurm options after --:
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:
The allocation remains active.
Cancel the allocation when finished
In non-X11 mode, exit does not stop the Slurm allocation.
When you are done, cancel it explicitly:
2. Generate the VS Code SSH config¶
After creating the allocation, print the VS Code SSH configuration snippet:
Copy the printed Host block into the SSH config file on your local computer:
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:
3. Connect from VS Code¶
On your local computer:
- Open Visual Studio Code.
- Open the command palette.
- Select Remote-SSH: Connect to Host....
- Choose the host name from the generated SSH config block.
- 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:
The output should be a compute node, for example:
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:
The compute node changed¶
Regenerate the config snippet and update your local ~/.ssh/config:
VS Code stopped working¶
Check whether the allocation is still active:
If it has ended, create a new allocation and regenerate the VS Code SSH config.
VS Code via Open OnDemand¶
As an alternative to creating an interactive session with or without X11 forwarding, you can also use Open OnDemand on Merlin7.
Open OnDemand provides web-based access to HPC resources and can be used to start graphical applications such as VS Code or MATLAB directly from a browser. Sometimes, this can be more convenient than setting up local SSH configuration, X11 forwarding, or VS Code Remote SSH manually.
Tip
If you mainly need a graphical VS Code or MATLAB session, Open OnDemand on Merlin7 is often the easiest option.
Warning
The same login-node rule still applies: do not run heavy interactive applications directly on login nodes.
Use either an interactive Slurm allocation, as described in this page, or the Open OnDemand web interface.