Starting IDEs from command line

Learning objectives

  • Be able to start IDEs from the command-line

    • Jupyter

    • Spyder

    • VScode

Introduction

Recommended to run on compute node from interactive session

This session from command line - See last session how to start.

Next session from OnDemand.

The IDEs

  • Jupyter

  • Spyder

  • VScode

Prepare environment!

  1. Log in to a desktop (ThinLinc or OnDemand) (see Log in and other preparations)

  2. Start interactive session with 6 cores

Jupyter

Jupyter is web application that (among other things) allows literature programming for Python. That is, Jupyter allows to create documents where Python code is shown and run and its results shown, surrounded by written text (e.g. English).

Additionally, Jupyter allows to share files and hence includes a file manager.

Principles

Jupyter is:

  • started and run on a server, for example, an interactive node

  • displayed in a web browser, such as firefox.

Jupyter can be slow when using a remote desktop website (e.g. pelle-gui.uppmax.uu.se or kebnekaise-tl.hpc2n.umu.se).

Local notes

  • You can start Thinlinc and run Jupyter on a login node, or use a browser on your local computer with SSH tunneling which could be faster.

Through ThinLinc

  1. Login with ThinLinc (https://www.nsc.liu.se/support/graphics/)

    • Download the client matching your local computer’s OS and install it.

    • Start the ThinLinc client.

    • Change the “Server” setting to tetralith.nsc.liu.se.

    • Change the “Name” setting to your Tetralith username (e.g x_abcde).

    • Enter your cluster Tetralith password in the “Password” box.

    • Press the “Connect” button.

    • If you connect for the first time, you will see the “The server’s host key is not cached …” dialog.

  2. Load a JupyterLab module

    • Open a terminal

    • This is an example for JupyterLab 4.2.0

    $ module load buildtool-easybuild/4.8.0-hpce082752a2 GCC/13.2.0 Python/3.11.5 SciPy-bundle/2023.11 JupyterLab/4.2.0
    
  3. Start JupyterLab

    • Type jupyter-lab in the terminal

    • It will show some text, including telling you to open a url in a browser (inside ThinLinc/on Tetralith). If you just wait, it will open a browser with Jupyter.

    • It will look similar to this:

On your own computer through SSH tunneling

  1. Either do a regular SSH or use ThinLinc to connect to tetralith (change to your own username):

    ssh x_abcde@tetralith.nsc.liu.se

  2. Change to your working directory

    cd <my-workdir>

  3. Load a module with JupyterLab in (here JupyterLab 4.2.0)

    $ module load buildtool-easybuild/4.8.0-hpce082752a2 GCC/13.2.0 Python/3.11.5 SciPy-bundle/2023.11 JupyterLab/4.2.0
    
  4. Start jupyter with the no-browser flag

    • jupyter-lab --no-browser

    • You get something that looks like this:

Where I have marked a line with relevant info. Note that the port will change.

  1. Open a second terminal, on your home computer. Input this:

    • ssh -N -L localhost:88XX:localhost:88XX x_abcde@tetralith1.nsc.liu.se

    where you change 88XX to the actual port you got, and the name to your username. In my example it would be:

    • ssh -N -L localhost:8867:localhost:8867 x_birbr@tetralith1.nsc.liu.se

  2. Now grab the line that is similar to the one I marked in 4. and which has the same port as you used in 5.

    • Input that line (url with token) in a browser on your local machine. You wil get something similar to this:

Spyder

Spyder is a powerful and flexible IDE originally developed to be the main scripting environment for scientific Anaconda users. It is designed to enable quick and easily repeatable experimentation, with automatic syntax checking, auto-complete suggestions, a runtime variable browser, and a graphics window that makes plots easy to manipulate after creation without additional code.

To use Spyder on one of the HPC center resources, you must have a Thinlinc window open and logged into your choice of HPC resource. For personal use, it is relatively easy to install as a standalone package on Windows or Mac, and there is also the option of using Spyder online via Binder.

Principles

  • start an interactive session

  • load a Python or Spyder module

  • load your Spyder environment

  • start Spyder

Spyder is not available on Tetralith.

module load Miniforge/24.7.1-2-hpc1
export CONDA_PKG_DIRS=/proj/hpc-python-spring-naiss/$USER
export CONDA_ENVS_PATH=/proj/hpc-python-spring-naiss/$USER
source activate spyder-env
  • you can install packages with pip install from inside Spyder

  • Start Spyder:

spyder &
# or
spyder3 &
  • Keep open for next session!

VS Code

VS Code is a powerful and flexible IDE that is popular among developers for its ease of use and flexibility. It is designed to be a lightweight and fast editor that can be customized to suit the user’s needs. It has a built-in terminal, debugger, and Git integration, and can be extended with a wide range of plugins.

VS Code can be downloaded and installed on your local machine from the VS Code website. It is also available on the HPC center resources, but the installation process is different for each center.

However, VS Code is best used on your local machine, as it is a resource-intensive application that can slow down the ThinLinc interface. The VS Code Server can be installed on all the HPCs that give your the ability to run your code on the HPCs but edit it on your local machine. Similarly, you can also install your faviroute extensions on the HPCs and use them on your local machine. Care should be taken while assigning the correct installation directories for the extensions because otherwise they get installed in home directory and eat up all the space.

Installed on HPC clusters

  • Tetralith: VSCode/latest-bdist
    • Start with code

  • Bianca:VSCodium
    • Start with code

  • Pelle: VScode
    • Start with code

  • Cosmos: system-installed (no module needed)
    • Start with code

For the HPC slusters below you need to connect from a local VSCode client (works also for all clusters)

  • Dardel

  • Kebnekaise

On your own computer through SSH tunneling

Install VS Code on your local machine and follow the steps below to connect to the HPC center resources.

When you first establish the ssh connection to the cluster, your VSCode server directory .vscode-server will be created in your home folder /home/[username]. This also where VS Code will install all your extentions that can quickly fill up your home directory.

Exercises with step-by-step instructions

Use the instructions above.

Exercise 1: Start Jupyter on a compute node

Exercise 2: Start Spyder on a compute node

Exercise 3: Run VScode on a compute node (if it is there)

Exercise 4: Run VScode locally with a connection to a compute node