Skip to content

Using Jupyter Notebooks on MN5

This document describes a simple process for setting up a Jupyter Notebook on Mare Nostrum 5, allowing the user to access it on the web browser on their local machine.

Setup Environment

Since Mare Nostrum 5 does not allow users to connect to the internet for installing packages (e.g. using pip), we are going to create a Singularity container with all the necessary libraries locally and transfer it to MN5.

  • Clone this repository to your local machine

    git clone https://gitlab.acnca.pt/cnca/aif-pt/baif-quickstart.git
    
  • Navigate to the jupyter folder that contains the Singularity definition file and the requirements.txt

    cd baif-quickstart/example_files/jupyter
    
  • Build the Singularity container

    singularity build --fakeroot jup.sif singularity.def
    
  • Transfer the container file to MN5

    scp jup.sif <username>@transfer1.bsc.es:/path/to/cluster/folder
    

Allocate a node and run Jupyter

  • Connect to MN5

    ssh <username>@alogin1.bsc.es
    
  • Allocate an interactive session on a GPU node

    salloc -A <project_name> -n 1 -c 40 -t 02:00:00 -q acc_ehpc --gres=gpu:1
    
    Info

    You can find your <project_name> by running the command bsc_project list on MN5.

  • Take note of the hostname of the allocated node (e.g. as05r3b32)

    hostname
    
  • Load the Singularity module

    module load singularity
    
  • Open a shell in the Singularity container

    singularity shell jup.sif
    
  • Run Jupyter Lab

    jupyter lab --no-browser --port=8888 --ip=0.0.0.0
    
  • Copy the Jupyter Lab URL with the access token (e.g. http://127.0.0.1:8888/lab?token=8cc8d81...)

Create a Tunnel

  • Open another terminal on your local PC, while keeping the first one running

  • In this new terminal, type the following command, replacing <allocated_node> with the node name you took note previously:

    ssh -L 8888:<allocated_node>:8888 <username>@alogin1.bsc.es
    
    GPP vs ACC nodes

    If you allocated a GPP node instead of an ACC node, replace alogin1 with glogin1

Connect to Jupyter

On your local PC, go to your web browser and paste the Jupyter Lab URL you copied.

You should see the Jupyter Lab interface.

End Jupyter Lab Session

If you want to finish your session, go to the first terminal (the one that is running Jupyter Lab) and press ctrl c.

Then, type exit to leave the Singularity container. Type exit again to close your interactive session on the compute node.