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

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.

1. Login to a remote desktop

  • Alt1. Login to the remote desktop website at pelle-gui.uppmax.uu.se

  • Alt2. Login to your local ThinLinc client at pelle-gui.uppmax.uu.se

2. start an interactive session

Start a terminal on the remote desktop. Within that terminal, start an interactive session from the login node (change to the correct NAISS project ID)

$ interactive -A uppmax2025-2-393 -t 1:00:00

3. start Jupyter in the interactive session

Within your terminal with the interactive session, load a modern Python module:

$ ml JupyterLab/4.2.5-GCCcore-13.3.0

Then, start jupyter-lab :

jupyter-lab --ip 0.0.0.0 --no-browser
  • This will start a jupyter server session so leave this terminal open. The terminal will also display multiple URLs.

  • Copy the URL containing pXXX

4. Connect to the running Jupyter server

On ThinLinc

  • Start firefox from menu of ThinLinc.

  • browse to the URLs, which will be similar to http://p115.uppmax.uu.se:8888/lab?token=73178b5ec897ae9bed6ae4b1815137d83dff671562574989

  • Paste the url and it will start the Jupyter interface on ThinLinc and all calculations and files will be on Pelle.

On own computer Only Pelle

If you want to connect to the Jupyter server running on Pelle from your own computer, you can do this by using SSH tunneling. Which means forwarding the port of the interactive node to your local computer.

  • On Linux or Mac this is done by running in another terminal. Replace p115 with the actual node number you got in step 3. Make sure you have the ports changed if they are not at the default 8888.

$ ssh -L 8888:p115:8888 <username>@pelle.uppmax.uu.se
  • If you use Windows it may be better to do this in the PowerShell instead of a WSL2 terminal.

  • If you use PuTTY - you need to change the settings in “Tunnels” accordingly (could be done for the current connection as well).

  • On your computer open the URL you got from step 3. on your webbrowser but replace p115 with localhost i.e. you get something like this

http://localhost:8888/lab?token=73178b5ec897ae9bed6ae4b1815137d83dff671562574989 or http://127.0.0.1:8888/lab?token=73178b5ec897ae9bed6ae4b1815137d83dff671562574989

  • This should bring the jupyter interface on your computer and all calculations and files will be on Pelle.

Warning

Running Jupyter in a virtual environment

You could also use jupyter (-lab or -notebook) in a virtual environment.

If you decide to use the –system-site-packages configuration you will get jupyter from the python modules you created your virtual environment with. However, you won’t find your locally installed packages from that jupyter session. To solve this reinstall jupyter within the virtual environment by force:

$ pip install -I jupyter

and run:

$ jupyter-notebook

Be sure to start the kernel with the virtual environment name, like “Example”, and not “Python 3 (ipykernel)”.

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.

VS Code is available on ThinLinc on UPPMAX and LUNARC only. On HPC2N and NSC, you will have to install it on your own laptop. At UPPMAX(Rackham) load it using module load VSCodium, this is an open source version of VS Code. At LUNARC(Cosmos) you can find it under Applications->Programming->Visual Studio Code.

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:VSCode/latest-bdist
    • 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

Exercise 1: Start Jupyter on a compute node

Exercise 2: Start Spyder on a compute node

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