Jupyter notebook

It is possible to connect to the Hoffman2 cluster opening a Jupyter Notebook.

While you can connect to Hoffman2 with X11-Forwarding and run a jupyter notebook on a webbrowser instance opened on the Hoffman2 cluster, we find that running jupyter notebook on your local browser is a preferred strategy.

To run an jupyter notebook on the Hoffman2 cluster while displaying it on your local browser please follow the steps outlined here.



On your local machine (the client) you will need:

  1. a working python installation (version 2.6 or greater)
  2. a web browser
  3. an ssh client
    • Linux/Mac OSX/MacOS
      • A terminal and an ssh client installations which can be found in your $PATH. The ssh client program needs to be able to be invoked with the command name ssh
    • Windows
  4. the script h2jupynb (see below)

Setting up passwordless connection to localhost (on Hoffman2)

First time only: log onto the Hoffman2 cluster to make sure that you can passwordlessly connect to localhost. You will not need to repeat this operation unless you remove the $HOME/.ssh directory from your account on Hoffman2

At the Hoffman2 shell command prompt issue the following commands:

ssh localhost

if you are prompted for a password interrupt the command. Which you can do by pressing “Ctrl-c” on your keyboard (press the key “c” while pressing down the key “Ctrl” or “control”):

and generate ssh keys with the command:


add the newly generated public key:


to the bottom of the file:


with the command:

cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys

Note: unless you remove the file $HOME/.ssh/authorized_keys or the directory $HOME/.ssh or remove the key from the $HOME/.ssh/authorized_keys file you will not need to repeat this procedure again.

Starting a Jupyter Notebook on the Hoffman2 cluster & displaying it on your local webbrowser

On your local computer:

  1. Download the script, h2jupynb, available at: https://gitlab.idre.ucla.edu/dauria/jupyter-notebook.git (this script is adapted from:  https://github.com/pyHPC/ipynbhpc)
  2. Execute the script by issuing:
    python h2jupynb -u username

    where: username is your Hoffman2 username

  3. As soon as the interactive session is allocated on the Hoffman2 cluster a jupyter notebook will be opened on your default web browser, please notice:
    • unless you have set up passwordless authentication with the Hoffman2 cluster you will be prompted to enter your Hoffman2 password twice
    • the default settings are so that the remote jupyter notebook will be allowed to use up to 1GB of memory, one core and will run for up to 2 hours

To learn how to change the default options run:

h2jupynb -h


h2jupynb [-u <Hoffman2 user name>] [-t <time in hours>] [-m <memory in GB>] [-s <number of slots>] [-v <python version>] [-p <port>] [-d <dir>]

If no arguments are given to this script it is assumed that:
your Hoffman2 user name is the same as on your client machine
the time duration for your session is of 2 hours
the memory per slot for your session is of 1GB
the number of slots for your session is of 1
he python version for your notebook is 2.7.13
the port on which the server is started is 8789
the starting directory on Hoffman2 is your $HOME

Available kernels

As of 2017/05/03 Jupiter Notebook can be run on the Hoffman2 cluster with the following programming languages (kernels):

    • Python 2
    • Python 3
    • R

Notebook Extensions

To be able to use jupyter notebook extensions you will need to log on the hoffman2 cluster and issue:

module load python/<version>
jupyter contrib nbextension install --user

Report problems at hpc@ucla.edu

Report Typos and Errors