Skip to content

Jupyter Notebooks

You can use a compute node to run a Jupyter notebook and access it from your local machine. We ask that you do not leave notebook jobs running idle for too long, as they exclude the use of computational resources other jobs could be taking advantage of.

Before you get started, you will need to be on campus or logged in to the Yale VPN and you will need to set up a Jupyter environment.

Set up an environment

We recommend you use Conda to manage your Jupyter environments. For example, if you want to create an environment with many commonly used scientific computing Python packages you would run:

module load miniconda
conda create -yn notebook_env anaconda python=3

You can then load this environment for Jupyter where we indicate below.

Open OnDemand

Once you have installed Jupyter and any other packages you want to use into a Conda environment, you can start a notebook server as a job via Open OnDemand.

We strongly encourage using Open OnDemand unless you have specific requirements otherwise.

Traditional Method

If you want finer control over your notebook job, you can manually configure a Jupyter notebook and connect manually.

The main steps are:

  1. Start a Jupyter notebook job.
  2. Start an ssh tunnel.
  3. Use your local browser to connect.

Start the Server

Here is a template for submitting a jupyter-notebook server as a batch job. You may need to edit some of the slurm options, including the time limit or the partition. You will also need to either load a module that contains jupyter-notebook or conda activate an environment if you're using Conda. Save your edited version of this script on the cluster, and submit it with sbatch.

#SBATCH --partition general
#SBATCH --nodes 1
#SBATCH --ntasks-per-node 1
#SBATCH --mem-per-cpu 8G
#SBATCH --time 1-0:00:00
#SBATCH --job-name jupyter-notebook
#SBATCH --output jupyter-notebook-%J.log

# get tunneling info
port=$(shuf -i8000-9999 -n1)
node=$(hostname -s)
cluster=$(hostname -f | awk -F"." '{print $2}')

# print tunneling instructions jupyter-log
echo -e "
For more info and how to connect from windows,

MacOS or linux terminal command to create your ssh tunnel
ssh -N -L ${port}:${node}:${port} ${user}@${cluster}

Windows MobaXterm info
Forwarded port:same as remote port
Remote server: ${node}
Remote port: ${port}
SSH server: ${cluster}
SSH login: $user
SSH port: 22

Use a Browser on your local machine to go to:
localhost:${port}  (prefix w/ https:// if using password)

# load modules or conda environments here
# uncomment the following two lines to use your conda environment called notebook_env
# module load miniconda
# source activate notebook_env

jupyter-notebook --no-browser --port=${port} --ip=${node}

Start the Tunnel

Once you have submitted your job and it starts, your notebook server will be ready for you to connect. You can run squeue -u${USER} to check. You will see an "R" in the ST or status column for your notebook job if it is running. If you see a "PD" in the status column, you will have to wait for your job to start running to connect. The log file with information about how to connect will be in the directory you submitted the script from, and be named jupyter-notebook-[jobid].log where jobid is the slurm id for your job.

MacOS and Linux

On a Mac or Linux machine, you can start the tunnel with an SSH command. You can check the output from the job you started to get the specifc info you need.


On a Windows machine, we recommend you use MobaXterm. See our guide on connecting with MobaXterm for instructions on how to get set up. You will need to take a look at your job's log file to get the details you need. Then start MobaXterm:

  1. Under Tools choose "MobaSSHTunnel (port forwarding)".
  2. Click the "New SSH Tunnel" button.
  3. Click the radio button for "Local port forwarding".
  4. Use the information in your jupyter notebook log file to fill out the boxes.
  5. Click Save.
  6. On your new tunnel, click the key symbol under the settings column and choose your ssh private key.
  7. Click the play button under the Start/Stop column.

Browse the Notebook

Finally, open a web browser on your local machine and enter the address http://localhost:port where port is the one specified in your log file. The address Jupyter creates by default (the one with the name of a compute node) will not work outside the cluster's network. Since version 5 of jupyter, the notebook will automatically generate a token that allows you to authenticate when you connect. It is long, and will be at the end of the url jupyter generates. It will look something like


If you run into trouble or need help, contact us.

Last update: July 30, 2020