VSCode: Difference between revisions

From CMU -- Language Technologies Institute -- HPC Wiki
Jump to navigation Jump to search
Gneubig (talk | contribs)
Line 25: Line 25:


=== Alternative  Option ===
=== Alternative  Option ===
Another option is to use the remote-ssh functionality of VSCode to connect directly to a compute node. This requires an active job on the compute node. To set up the SSH configuration for connecting to the compute node, follow these steps:


1. Obtain the IP address of the compute node using the <code>ifconfig</code> command.
Another option is to use the remote-ssh functionality of VSCode to connect directly to a compute node.
This requires that you first create an active job on the compute node, then use an ssh proxy to ssh through a login node to the compute node.
To set up the SSH configuration for connecting to the compute node, follow these steps:


2. Update your SSH configuration file (<code>~/.ssh/config</code>) with the following entries:
1. If you have not already, set up [http://Connecting_to_the_Cluster#Passwordless_Login passwordless login] using a public/private key pair. Take a note of the location on your local machine of the ssh private key (e.g. <code>~/.ssh/id_rsa</code>) that you are using for passwordless login, we will call it <code>identity_file</code> below.
 
2. Run a job that allocates the resources that you need for vscode development (including a GPU if you need a GPU machine). Here is an example: <code>srun --cpus-per-task 2 --mem=8000 --wait=0 -t 02:00:00 -n 1 --pty bash --partition debug</code>. Take a note of what machine it is running on, we will call this <code>node_id</code>.
 
3. On your local machine, update your SSH configuration file (<code>~/.ssh/config</code>) with the following entries. :


   Host babel
   Host babel
     HostName babel.lti.cs.cmu.edu
     HostName babel.lti.cs.cmu.edu
     User <username>
     User <andrew_id>
     IdentityFile <identityfile>
     IdentityFile <identity_file>
     ForwardAgent yes
     ForwardAgent yes


   Host babel-compute-node
   Host babel-compute-node
     HostName <node ip addr/ node-name (babel-1-10)>
     HostName <node_id>
     User <username>
     User <andrew_id>
     IdentityFile <identityfile>
     IdentityFile <identity_file>
     ProxyJump babel
     ProxyJump babel
     StrictHostKeyChecking no
     StrictHostKeyChecking no
Line 46: Line 51:
     LogLevel ERROR
     LogLevel ERROR


3. After configuring SSH, run VSCode natively on your local machine and use the command palette to type `Remote-SSH: Connect to Host....` Select `babel-compute-node` from the list.
4. After configuring SSH, run VSCode natively on your local machine and use the command palette to type `Remote-SSH: Connect to Host....` Select `babel-compute-node` from the list.


== Connecting to a Compute Node ==
== Connecting to a Compute Node ==

Revision as of 13:04, 5 March 2024

Note: [VSCodium](https://github.com/VSCodium/vscodium) is an open-source variant of Visual Studio Code that provides the same powerful features and extensibility, but without the telemetry and branding associated with the official version.

Using VSCode

When developing on VSCode, it’s important to be cautious about its CPU usage, especially when working on the login node, as it can be CPU-intensive. Certain extensions, such as the GitHub co-pilot extension, can significantly increase CPU usage. To monitor and limit CPU usage while developing on the login node, you can refer to the following articles (1, 2, 3).

Alternatively, you can host a VSCode server on a compute node and establish an SSH tunnel to access it. This approach mostly avoids over consumption on the login node. To set this up, follow these steps:

1. Download the VSCode server release here and extract it in your home directory on the login node.

2. Run the following command on the login node:

 $ srun -c 8 --mem 32G --time 1-00:00:00 vscode-server-linux-x64-web/bin/code-server --accept-server-license-terms

3. Once the server starts, take note of the compute node your job lands on (e.g., babel-x-y)and the URL shown (e.g., **http://localhost:port/?tkn=...)**.

4. On the cluster login node, run the following command:

 $ ssh -NL <an available port>:0.0.0.0:port babel-x-y

5. On your local machine, run the following command:

 $ ssh -NL port:0.0.0.0:<an available port> babel

6. Open your browser and navigate to **http://localhost:port/?tkn=...** to access the VSCode server running on the compute node.

Alternative Option

Another option is to use the remote-ssh functionality of VSCode to connect directly to a compute node. This requires that you first create an active job on the compute node, then use an ssh proxy to ssh through a login node to the compute node. To set up the SSH configuration for connecting to the compute node, follow these steps:

1. If you have not already, set up passwordless login using a public/private key pair. Take a note of the location on your local machine of the ssh private key (e.g. ~/.ssh/id_rsa) that you are using for passwordless login, we will call it identity_file below.

2. Run a job that allocates the resources that you need for vscode development (including a GPU if you need a GPU machine). Here is an example: srun --cpus-per-task 2 --mem=8000 --wait=0 -t 02:00:00 -n 1 --pty bash --partition debug. Take a note of what machine it is running on, we will call this node_id.

3. On your local machine, update your SSH configuration file (~/.ssh/config) with the following entries. :

 Host babel
   HostName babel.lti.cs.cmu.edu
   User <andrew_id>
   IdentityFile <identity_file>
   ForwardAgent yes
 Host babel-compute-node
   HostName <node_id>
   User <andrew_id>
   IdentityFile <identity_file>
   ProxyJump babel
   StrictHostKeyChecking no
   UserKnownHostsFile /dev/null
   LogLevel ERROR

4. After configuring SSH, run VSCode natively on your local machine and use the command palette to type `Remote-SSH: Connect to Host....` Select `babel-compute-node` from the list.

Connecting to a Compute Node

You can also ssh directly to a compute node where you have a job already running by doing:

ssh -J babel babel-X-XX