Set up VS Code on OpenMind compute node (Method 01) - sensein/ GitHub Wiki

First, have your VS Code ready on your local laptop.

Set up on openmind

Connect to openmind

For example:

ssh [email protected]

Request a compute node through SLURM

For example:

srun -n 12 --mem=64GB -t 300 --exclude node058,node055,node057,node056,node091 --pty bash

Change n_cpu (12 in this case), memory (64GB), and time (300min) settings based on your needs. Don't require resource more than you need :)

Get the compute node number (e.g., 094)

Set up on your local laptop

Modify config file

Go to your VS Code View->Command Palette -> Remote-SSH: Open SSH Configuration File... -> open your config file (e.g., Users/yibeichen/.ssh/config, add the following (User should be your username for openmind):

Host om
  User yibei
  IdentityFile ~/.ssh/id_rsa

Host omnode
  HostName node094
  ProxyJump om
  User yibei

Auto-update node number (e.g., 094) in your config file

Save the following script as (or whatever name you prefer)

#!/usr/bin/env python3

import sys
import os
import re

def backup_config_file(config_path):
    """Create a backup of the config file."""
    backup_path = config_path + ".backup"
    with open(config_path, "r") as src, open(backup_path, "w") as dst:
    print(f"Backup created at: {backup_path}")

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print("Usage: omnode <3-digit-code>")

    new_code = sys.argv[1]
    if len(new_code) != 3 or not new_code.isdigit():
        print("Usage: omnode <3-digit-code>")

    config_path = os.path.join(os.path.expanduser('~'), ".ssh", "config")
        # Create a backup before making changes

        # Read in the file
        with open(config_path, "r") as f:
            lines = f.readlines()

        # Update the relevant line
        updated = False
        for i, line in enumerate(lines):
            if "Host omnode" in line:
                for j in range(i+1, len(lines)):
                    if"HostName node\d{3}", lines[j]):
                        lines[j] = re.sub(r"node\d{3}", "node" + new_code, lines[j])
                        updated = True
            if updated:

        # Write the file out again
        with open(config_path, "w") as f:

    except FileNotFoundError:
        print(f"Error: File {config_path} not found.")
    except PermissionError:
        print(f"Error: No permission to read or write to {config_path}.")
    except Exception as e:
        print(f"Unexpected error: {e}")%

Run the script as

python 3-digits-omnode # for example python 094

Connect via VS Code

Go to your VS Code View->Command Palette -> Remote-SSH: Connect to Host... -> Choose omnode

Suppose there are no error messages, DONE! you've successfully connected to the openmind compute node!

Go to your folder on OpenMind

On VS Code, click Open, input your folder path.

More useful information:

  1. openmind
  2. from Harsha