Jupyter Notebook

This app replaces iPython notebook.
Please use our Linux Virtual Desktop (nyx5,6,7) to access a running notebook through a web-browser.

Overview

Jupyter Notebook is a web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document. We execute python commands and view the results in a web browser. The python commands execute remotely on the iCSF (where more memory and compute-power exists).

Jupyter Notebook version 5.0.0 is installed on the iCSF as part of the Anaconda3 4.2.0 package. This runs Python 3.5.2.

Restrictions on use

There are no restrictions accessing this software. However you must have an account on the nyx5 / nyx6 / nyx7 virtual desktop server from which you then access the iCSF. Please see X2GO virtual desktop for details. To request an account on nyx5,6,7 please email its-ri-team@manchester.ac.uk (we will set up your account on all of the nyx servers).

Set up procedure

The Jupyter Notebook software runs on one of the iCSF 256GB compute nodes (incline256.itservices.manchester.ac.uk nodes). However, we do not manually log in to the iCSF and run the Jupyter Notebook software directly. Instead we run a script on the nyx5/nyx6/nyx7 virtual desktop to manage the whole business of connecting to the iCSF and running the Jupyter Notebook software.

Hence you must first log in to the nyx5 or nyx6 or nyx7 virtual desktop service using the x2goclient software. See links for details.

Running the application

The following instructions assume you are logged in to the nyx5 virtual desktop (we use nyx5 in this example but you can also use nyx6 or nyx7).

Launching the Jupyter Notebook on to the iCSF

Note: we use nyx5 in this example but you can also use nyx6 or nyx7.

  1. On nyx5, open a shell window (e.g., using menu: Applications -> System Tools -> Terminal)
  2. In the terminal, run:
    jupyter-notebook-icsf
    
  3. Enter your iCSF password when prompted:
    Connecting to the iCSF to start a Jupyter Notebook...
    username@incline256's password:  type your UoM IT password
                                        (no characters will be displayed while you type)
    
  4. Make a note of the URL address given to you – e.g.:
    http://localhost:7777/?token=long-string-of-characters

    (the number 7777 may differ).

This will log you in to the iCSF (incline) and start the Jupyter Notebook server. Hence you will be asked for your iCSF password. Enter it when prompted.

For example, the complete output is:

[mabcxyz1@nyx5 ~]$ jupyter-notebook-icsf

===================== Use the URL given here ====================

 1. Enter your iCSF password when prompted below
 2. On nyx5 please start firefox and browse to:

           http://localhost:7777/?token=<long string of characters>

    (see below for the 'token' string to add to the above address)

Connecting to the iCSF to start a Jupyter Notebook...
mabcxyz1@incline256's password: <enter your iCSF password>

You will have been automatically logged in to the iCSF (on to one of the backend 256GB nodes). Notice the URL advertised to you:

http://localhost:7777/?token=long-string-of-characters

The 7777 port number may be different in your output. You should make a note of the URL, particularly the port number and long string of random characters (which acts like a random password that only you can see – it prevents other people from access your notebook on the iCSF). We will access this URL in a web browser shortly.

You will see some output from the Jupyter Notebook server and then the message:

======= ** IMPORTANT - YOU MUST DO THIS WHEN FINISHED WITH Jupyter ** =======
 Please use CTRL-C in this window to terminate Jupyter Notebook on incline21
 (PID 102924) ...

We will use this when shutting down the server at the end of our session (see below).

View the Jupyter Notebook in a Web Browser on nyx5

On the nyx5 virtual desktop:

  1. Start firefox (e.g., using menu: Applications -> Internet -> Firefox ESR)
  2. Now enter the following address in the browser address bar at the top:
    http://localhost:7777/?token=long-string-of-characters

    where 7777/?token=long-string-of-characters and is the number and string reported to you earlier when you ran jupyter-notebook-icsf in the command window. Your numbers may be different!

You should now see the Jupyter Notebook dashboard in your web browser. This has connected to the iCSF backend node running the Jupyter Notebook.

Example Notebook

Once you have connected to your notebook, try the following in your web-browser:

  1. Select New -- Python3 to start a new python notebook.
  2. Enter the following code in the first cell (see image below):
    import os
    file=os.getenv("JUPYTER_HOME")+"/example_job/mandelbrot.py"
    %load $file
    

    Load a python file in to a notebook

  3. Press the Run button twice – firstly to load the mandelbrot.py in to the notebook. Then secondly to execute the notebook code.
  4. You should see a Mandelbrot fractal image in your web-browser. The code was executed in the batch job running on the compute node!
    Mandelbrot notebook result

Stopping the Remote Notebook Server

As mentioned above, when you have finished using the Jupyter Notebook on the iCSF you must close it down. Otherwise server processes may be left running on the iCSF backend nodes.

  1. Press the ‘Logout’ button in the notebook’s web-page, or simply close your web-browser and, if you no longer want to connect back to the notebook
  2. Now type CTRL-C in the shell window that displayed the URL and message about pressing Ctrl+C. It will report that it has shut down the server. You will be automatically logged out of the iCSF, leaving the shell window back at the nyx5 prompt:
    ======= ** IMPORTANT - YOU MUST DO THIS WHEN FINISHED WITH Jupyter ** =======
     Please use CTRL-C in this window to terminate Jupyter Notebook on incline21
     (PID 102924) ...
    
    ....output while you were using the notebook in the web-browser....
    
    ^C     <-- here we pressed CTRL-C
    [C 18:03:17.113 NotebookApp] received signal 15, stopping
    [I 18:03:17.198 NotebookApp] Shutting down kernels
    [I 18:03:17.800 NotebookApp] Kernel shutdown: 25521668-a97f-444b-8cac-e3718c8213c8
    
    Terminated Jupyter Notebook on incline21 (PID 102924).
    If the command-prompt does not appear, press Ctrl+C again.
    
    Connection to incline256 closed.
    mabcxyz1@nyx5:~$ 
    
  3. That’s it, we’re back on nyx5 and the Jupyter Notebook server we were running on the iCSF has finished.

Further info

Updates

None.

Last modified on March 23, 2019 at 8:37 am by George Leaver