Development/VS Code: Difference between revisions
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
== Visual Studio Code == |
== Visual Studio Code == |
||
Visual Studio Code (VS Code) is a lightweight, extensible code editor from Microsoft that supports many programming languages and features like |
Visual Studio Code (VS Code) is a lightweight, extensible code editor from Microsoft that supports many programming languages and features like debugging, and integrated Git. It offers a rich extension marketplace to add language support, themes, and tools tailored to your workflow. VS Code runs on Windows, macOS, and Linux and is popular for its speed, customizability, and strong community ecosystem. |
||
=== Using AI agents === |
=== Using AI agents === |
||
| Line 51: | Line 51: | ||
=== Access to Compute Nodes === |
=== Access to Compute Nodes === |
||
The workflow described above does not allow debugging on compute nodes that have been requested via an interactive Slurm job, for example |
The workflow described above does not allow debugging on compute nodes that have been requested via an interactive Slurm job, for example. Debugging GPU codes is therefore also not possible, since this kind of resource is only accessible within Slurm jobs. |
||
We strongly discourage using the Code Tunnel application, as it violates our access policies. In this scenario, an application running on the compute node connects to a Microsoft or GitHub server. The locally running VS Code then connects to the compute nodes via these external servers, thereby bypassing the login nodes. |
|||
<!-- |
|||
Access the compute nodes via VS Code and the Remote-SSH plugin is only possible, if you start a temporarily running SSH service on the compute node which listens to an unprivileged port. By tunneling this port to your local computer, you can connect VS code to it. |
|||
--> |
|||
== Code-Server == |
== Code-Server == |
||
The application [https://github.com/cdr/code-server code-server] allows to run the server part of VS Code on any machine, it can be accessed in the web browser. This enables, for example, development and debugging on compute nodes. |
The application [https://github.com/cdr/code-server code-server] allows to run the server part of VS Code on any machine, it can be accessed in the web browser running on your local computer. This enables, for example, development and debugging on compute nodes. |
||
Code-server runs a web server which |
Code-server runs a web server which serves on an unprivileged port. In order to connect your web browser to the remotely running code server, you have to forward this port via a SSH tunnel. |
||
[[File:code-server.png|thumb|code-server.png|VS Code in web browser: code-server, Source: https://github.com/cdr/code-server">https://github.com/cdr/code-server|400px]] |
[[File:code-server.png|thumb|code-server.png|VS Code in web browser: code-server, Source: https://github.com/cdr/code-server">https://github.com/cdr/code-server|400px]] |
||
Revision as of 09:31, 21 April 2026
Overview
Visual Studio Code (VS Code) is an open source source-code editor from Microsoft. It has become one of the most popular IDEs according to a stackoverflow survey. The functionality of VS Code can easily be extended by installing extensions. These extensions allow for almost arbitrary language support, debugging or remote development. You can install VS Code locally and use it for remote development.
Visual Studio Code
Visual Studio Code (VS Code) is a lightweight, extensible code editor from Microsoft that supports many programming languages and features like debugging, and integrated Git. It offers a rich extension marketplace to add language support, themes, and tools tailored to your workflow. VS Code runs on Windows, macOS, and Linux and is popular for its speed, customizability, and strong community ecosystem.
Using AI agents
When deploying AI agents on the bwHPC clusters, users must exercise extreme caution and maintain full oversight of the agent's activities. You are fully responsible for all actions initiated by an agent, including any security breaches or system disruptions it may cause. It is mandatory to strictly monitor resource usage on login nodes, as these are shared resources intended only for lightweight tasks. Any agent found consuming excessive CPU or memory on a login node will be terminated immediately to ensure stability for other users. To comply with usage policies, all AI-driven workloads which generate heavy load must be submitted to the Slurm batch queues rather than running directly on the login nodes.
Extension: Remote-SSH
In order to remotely develop and debug code at HPC facilities, you can use the Remote - SSH extension. The extension allows you to connect your locally installed VS Code with the remote servers. So in contrast to using graphical IDEs within a remote desktop session (RDP, VNC), there are no negative effects like e.g. laggy reactions to your input or blurred display of fonts.
Installation and Configuration
![]()
In order to install the Remote - SSH extension, just click on the Extensions (Erweiterungen) button in the left side bar and enter “remote ssh” in the search field. Choose Remote - SSH from the occurring list and click on Install.
![]()
In order to configure remote connections, open the Remote-Explorer extension. On Linux Systems, the file ~/.ssh/config is automatically evaluated. The targets within this file already appear in the left side bar.
![]()
If there are no remote ssh targets defined within this file, you can easily add one by clicking on the + symbol. Make sure that “SSH Targets” is active in the drop down menu of the Remote-Explorer. Enter the connection details <user>@<server>. You will be asked, whether the file ~/.ssh/config should be modified or if another config file should be used or created.
A minimal entry within ~/.ssh/config in order to have a remote target to be listed there could look like this:
$ cat ~/.ssh/config Host uc3.scc.kit.edu HostName uc3.scc.kit.edu User xy_ab1234
Connect to Login Nodes
![]()
In order to connect to a remote SSH target, open the Remote-Explorer. Right-click a target and connect in the current or a new window. TOTP and password can be entered in the corresponding input fields that open.
You are now logged in on the remote server. As usual, you can open a project directory with the standard key binding Ctrl+k Ctrl+o. You can now edit and debug code.
Attention: Please remember that you are running and debugging the code on a login node. Do not perform resource-intensive tasks. Furthermore, no GPU resources are available to you.
Extensions, which are installed locally, are only usable on your local machine and are not automatically installed remotely. However, as soon as you open the Extensions-Explorer during a remote session, VS Code proposes to install the locally installed extensions remotely.
Disconnect from Login Nodes
![]()
If you want to end your remote session, click the green box in the lower left corner. In the input box that opens, select the “Close Remote Connection” option. If you simply close your VS Code window, some server-side components of VS Code will continue to run remotely.
Access to Compute Nodes
The workflow described above does not allow debugging on compute nodes that have been requested via an interactive Slurm job, for example. Debugging GPU codes is therefore also not possible, since this kind of resource is only accessible within Slurm jobs. We strongly discourage using the Code Tunnel application, as it violates our access policies. In this scenario, an application running on the compute node connects to a Microsoft or GitHub server. The locally running VS Code then connects to the compute nodes via these external servers, thereby bypassing the login nodes.
Code-Server
The application code-server allows to run the server part of VS Code on any machine, it can be accessed in the web browser running on your local computer. This enables, for example, development and debugging on compute nodes. Code-server runs a web server which serves on an unprivileged port. In order to connect your web browser to the remotely running code server, you have to forward this port via a SSH tunnel.
Install Code-Server
Code-server is pre-installed on bwUniCluster and accessible via an Lmod module:
module load devel/code-server
On clusters with no code-server module, the application can easily be installed with the description available on the official GitHub page.
Start Code-Server
Code-server can be run on either login nodes or compute nodes. In the example shown, an interactive job is started on a GPU partition to run code-server there.
$ salloc -p accelerated --gres=gpu:4 --time=30:00 # Start interactive job with 1 GPU
$ module load devel/code-server # Load code-server module
When code-server is started, it opens a web server listening on a certain port. The user has to specify the port. It can be chosen freely in the unprivileged range (above 1024). If a port is already assigned, e.g. because several users choose the same port, another port must be chosen.
By starting code-server, you are running a web server that can be accessed by anyone logged in to the cluster. To prevent other people from gaining access to your account and data, this web server is password protected. If no variable PASSWORD is defined, the password in the default config file ~/.config/code-server/config.yaml is used. If you want to define your own password, you can either change it in the config file or export the variable PASSWORD.
$ PASSWORD=<mySecret> \
code-server \
--bind-addr 0.0.0.0:8081 \
--auth password # Start code-server on port 8081
| Security implications
Please note that by starting
|
Connect to code-server
As soon as code-server is running, it can be accessed in the web browser. In order to establish the connection, a SSH tunnel from your local computer to the remote server has to be created via:
$ ssh -L 8081:<computeNodeID>:8081 <userID>@uc3.scc.kit.edu
You need to enter the computeNodeID of the node on which the interactive Slurm job is running. If you have started code server on a login node, just enter localhost. Now you can open http://127.0.0.1:8081 in your web browser. Possibly, you have to allow your browser to open an insecure (non-https) site. The login site looks as follows:
Enter the password from ~/.config/code-server/config.yaml or from the PASSWORD variable. After clicking the “Submit” button, the familiar VS Code interface will open in your browser.
End code-server session
If you want to temporarily log out from your code-server session you can open the “Application Menu” in the left side bar and click on “Log out”. To terminate the code-server session, you have to cancel it in the interactive Slurm job by pressing ++ctrl+c++.