You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Current »

This is a short guide to describe how to use jupyter nootebook on Izar through ssh port forwarding.

Installing IPython and Jupyter

The key to successfully installing the tools is using python virtual environments.

  1. Load the compiler you want to use and python using modules

    $ module load gcc
    $ module load python
    $ module load intel
    $ module load python
  2. Create a virtual environment

    In the following, we use GCC but the same procedure applies to Intel compiler. In your home folder, create a virtual environment:

    $ virtualenv -p python3 --system-site-packages opt/venv-gcc
    Running virtualenv with interpreter /ssoft/spack/arvine/v1/opt/spack/linux-rhel7-skylake_avx512/gcc-8.4.0/python-3.7.7-drpdlwdbo3lmtkcbckq227ypnzno4ek3/bin/python3
    Already using interpreter /ssoft/spack/arvine/v1/opt/spack/linux-rhel7-skylake_avx512/gcc-8.4.0/python-3.7.7-drpdlwdbo3lmtkcbckq227ypnzno4ek3/bin/python3
    Using base prefix '/ssoft/spack/arvine/v1/opt/spack/linux-rhel7-skylake_avx512/gcc-8.4.0/python-3.7.7-drpdlwdbo3lmtkcbckq227ypnzno4ek3'
    New python executable in /home/user/opt/venv-gcc/bin/python3
    Also creating executable in /home/user/opt/venv-gcc/bin/python
    Installing setuptools, pip, wheel...
  3. Activate virtual environment

    $ source opt/venv-gcc/bin/activate
    (venv-gcc) [user@izar ~]$
  4. Install Jupyter

    (venv-gcc) [user@izar ~]$ pip install jupyter
    Collecting jupyter
  5. Set passwordless access to Izar by using ssh key and have the following in your ~/.ssh/config file on your personal computer (How to generate an SSH key). It is assumed that you are inside the EPFL network (or connected through VPN).

    Host izar
       User [username]
    Host i*.izar
       ProxyCommand ssh -W $(echo "%h" | sed -e 's/.izar//'):%p izar
  6. Run jupyter notebook on Izar.
    The script below is a template that allows you to start jupyter notebook on a compute node of Izar. You can copy it in a file called for example. It has to be placed in your home (or you have to modify it accordingly). Note that all the modules that jupyter may need have to be loaded here. As an example, here, we loaded the modules that allow us to use TensorFlow in the notebook.
    #!/bin/bash -l
    #SBATCH --job-name=ipython-trial
    #SBATCH --nodes=1
    #SBATCH --exclusive
    #SBATCH --time=01:00:00
    #SBATCH --output jupyter-log-%J.out
    module load gcc mvapich2 py-tensorflow
    source opt/venv-gcc/bin/activate
    ipnport=$(shuf -i8000-9999 -n1)
    jupyter-notebook --no-browser --port=${ipnport} --ip=$(hostname -i)

    Launch your job as usual:


    Once the job is running analyze the output jupyter-log-[SLURM_ID].out. Then, look for a line like the following:

        Or copy and paste one of these URLs:

    It has the form:

    http://<IP ADDRESS>:<PORT NUMBER>/?token=<TOKEN>
  7. On your local machine do the following with the information provided by the above step

    ## Or if you created the ssh config from step 5
    ssh -L <PORT NUMBER>:<IP ADDRESS>:<PORT NUMBER> izar -f -N

    For our example, this gives:

    ssh -L 8504: -l user -f -N
    ## with config
    ssh -L 8504: izar -f -N
  8. Now you should be able to access to Izar compute node through the web browser by pasting the following address

    http://localhost:<PORT NUMBER>/?token=<TOKEN>

    For our example, this gives:


Here is a screenshot of a jupyter session running a simple TensorFlow example. The computations are run on the cluster node, but you access the results directly from your browser.

If you wish to use tensorboard you must open a second connection as follow

ssh -L <PORT NUMBER>localhost:<PORT NUMBER> -o ProxyCommand="ssh -W %h:%p" -l <USERNAME> <NODE ALLOCATED>

## OR if you created the config from step 5

For example

ssh -L 6006:localhost:6006 -o ProxyCommand="ssh -W %h:%p" -l user i39

## with config
ssh -L 6006:localhost:6006 i39.izar

  • No labels