Run Jupyter Notebooks in an Interactive Session

Overview:

  • Teaching: 0 min
  • Exercises: 0 min

Questions

  • How can I test my code using Jupyter notebooks on Balena

Objectives

  • Understand how to set-up and access Jupyter notebooks from an interactive session on Balena

Login to Balena

First of all you will need to login to Balena.

Once you are logged in you can launch an interactive job using the command sint. If you want to configure your interactive job then refer to the help sint --help.

Use of interactive sessions

Please take note of the login message on Interactive nodes:

=================== Welcome to the Balena ITD service ===================

This is an Interactive Test and Development node and SHOULD NOT
be used for running any production workloads. Please refer our
'Good User' guide for usage policy:-

https://wiki.bath.ac.uk/display/BalenaHPC/Policies#Policies-GoodUserGuide

============================= Thank you =================================

If you want to run large or long jobs please refer to the following episode on running Jupyter notebooks from the batch service. Running workloads on this shared service is likely to be inefficient as other users may be testing parallel codes and performance is likely to be poor.

You now need to load the python/anaconda module you want to use:

module load python3/2019.x

If this is the first time using Jupyter notebooks on Balena you will need to run

jupyter notebook --generate-config

and set a password so that only you can access the server:

jupyter notebook password

This will prompt you to enter and verify your password:

Enter password:
Verify password:

Note that, as when you log in to Balena, the cursor will not move and no *s will print to the screen when you enter the password.

We are going to launch the Jupyter notebook server on the interactive node, and access this from a web browser on our local machine. In order to do this we need to know the ip address of the node and the port that the server users. We can get the first using the command:

host $(hostname)

which will produce an output similar to:

itd-ngpu-01.cm.balena has address 172.30.6.201

Make sure that you run this in your own interactive session!

Now we can launch the Jupyter notebook server:

jupyter notebook --ip="*" --no-browser &

This will produce several lines of output. We need the line which contains output similar to:

[I 17:58:48.994 NotebookApp] http://[all ip addresses on your system]:8888/

You can now access the notebook server by opening a web browser on your local machine and, in this case above entering the address:

http://172.30.6.201:8888

If you have follwed the tutorial successfully you should be prompted for the password you entered earlier and be launched into the familar Jupyter notebooks environment.

Key Points:

  • You can run Jupyter notebooks from an interactive session on Balena
  • You can then access the notebook server from a browser on your local machine