VSCode

Creation date: 2/5/2024 5:20 PM    Updated: 1/22/2026 10:35 AM   code jupter vscode

VSCODE howto on the Hoffman2 Cluster


VSCODE version needed


If you are using Virtual Studio Code to connect to the cluster via the SSH Remote extension, the highest version of Code compatible with the Hoffman2 Cluster, as of January 2024, is: VSCode v. 1.85, available at:

Version 1_86 is also supported:


and disable automatic updates by following these instructions:

1) Open VS Code and go to File > Preferences > Settings
2) In the search bar, type update mode.
3) Under the Update: Mode dropdown, select the none option (also for the extension)
4) restart vscode


RUN VSCODE ON COMPUTE NODES HOW-TO


1. connect to Hoffman2 via terminal (you can use vscode if you so choose), run at the prompt this command:


run-vscode-compute-ssh-setup


and follow the instructions for the initial setup, in a nutshell write to your local $HOME/.ssh/config file (you can do so in VSCode via: Control/Command+Shift+P and type Configure SSH hosts - assuming that you have already installed the Remte-SSH VS code extension) the following:


Host h2compute

Hostname 127.0.0.1

User <YOUR-HOFFMAN2-ACCOUNTNAME>

Port 7022

IdentityFile ~/.ssh/id_rsa_pc2h2

ForwardX11Trusted yes

ForwardX11 yes


Host hoffman2

Hostname hoffman2.idre.ucla.edu

User <YOUR-HOFFMAN2-ACCOUNTNAME>

IdentityFile ~/.ssh/id_rsa_pc2h2

ForwardX11Trusted yes

ForwardX11 yes


WHERE: "~/.ssh/id_rsa_pc2h2" is the ssh key that you will have created according to the steps given by the output of "run-vscode-compute-ssh-setup". If you don't create a key you will need to enter your password (you may still decide to protect your key with a passphrase which is the preferred, more secure, way). If you don't create an ssh key pair you may want to remove the IdentityFile line.


2. on the terminal connected to Hoffman2 request the interactive session (qrsh ...) and run the command:



run-vscode-compute



and follow the information from the output, which basically will instruct you to open a terminal on your local machine and start the following SSH port forwarding:



ssh -N -L 7022:h2-node:22 hoffman2



WHERE: h2-node will be  the compute node on which your interactive session is running.


3. Open a new VS code window and connect to the h2compute host which will appear in your list of hosts


you should finally have your VSCode session open on the compute node.


RUN JUPYTER NOTEBOOKS IN VSCODE


Start a jupyter notebook via the h2jupynb script (see:https://www.hoffman2.idre.ucla.edu/Using-H2/Connecting/Connecting.html#connecting-via-jupyter-notebook-lab) and selecting the port 

h2jupynb -u <YOUR-HOFFMAN2-ACCOUNTNAME> -p 7022 #any other needed options

and then in vscode:

  -- on a vscode window go to "Show and Run Commands >" (generally Ctrl + shift + P or Command + shift + P) 

  -- select "Create New Jupyter Notebook" 

  -- navigate to "Select kernel"

  -- select "Existing Jupyter Server..."

  -- select "Enter the URL of the running Jupyter Server..." and enter the URL from the webpage on which your session has started

  -- when connected select the kernel you would like to connect to on the Hoffman2 Cluster