This guide explains how you can run Jupyter Notebook on the Discovery cluster.

This can be carried out in three different ways:

  • Using Open OnDemand

  • Running the web app interactively with srun.

  • Submitting a batch script with SBATCH

Running Jupyter Notebook

Using Open OnDemand(Easier and Faster way)

  • Open OnDemand provides an easier and faster way of launching the Jupyter Notebook through an interactive session on the compute node.

  • Users simply need to fill a form in OnDemand web portal to request the resources and access the Jupyter notebook, thus eliminating the need of running a series of bash commands to launch Jupyter notebook from the terminal.

  • For more information on how to launch Jupyter Notebook via Open OnDemand, refer the link → Launching Jupyter Notebook using Open OnDemand.

Using srun (Interactively)

  1. Open a new terminal session and connect to Discovery

  2. Launch tmux.


    Starting srun within tmux is recommended because it helps persist the program’s activity even when your connection to Discovery’s login node is terminated. For more handy commands visit → tmux cheatsheet website.

  3. Load Anaconda

    module purge
    module load anaconda
  4. Execute the srun command with the following parameters

    srun --time=02:00:00 --ntasks=1 --cpus-per-task=2 --mem-per-cpu 4g jupyter notebook --no-browser --ip=




    Notice the value of ntasks is 1. Specifying more than one ntasks may not work for Jupyter notebook.


    Prevents the browser window from launching on the remote server.


    Set the default network.

    jupyter notebook

    The web application to launch.

    In less than 5 seconds you will get an output similar to the one below on your console.

    [I 19:07:44.422 NotebookApp] Writing notebook server cookie secret to /home/vaduaka/.local/share/jupyter/runtime/notebook_cookie_secret
     [I 19:07:48.089 NotebookApp] JupyterLab extension loaded from /software/anaconda/anaconda3/lib/python3.7/site-packages/jupyterlab
     [I 19:07:48.089 NotebookApp] JupyterLab application directory is /software/anaconda/anaconda3/share/jupyter/lab
     [I 19:07:48.094 NotebookApp] Serving notebooks from local directory: /home/vaduaka
     [I 19:07:48.094 NotebookApp] The Jupyter Notebook is running at:
     [I 19:07:48.094 NotebookApp] http://discovery-c7.cluster.local:8888/?token=8149d1db4034d604e8681f457c3e23fef2f0b5dccab1b413
     [I 19:07:48.094 NotebookApp]  or
     [I 19:07:48.094 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
     [C 19:07:48.101 NotebookApp]
         To access the notebook, open this file in a browser:
         Or copy and paste one of these URLs:

    From the output above you can see that Jupyter notebook is running on host: discovery-c7.cluster.local port: 8888 and the generated token:8149d1db4034d604e8681f457c3e23fef2f0b5dccab1b413

    At this point neither nor http://discovery-c7.cluster.local:8888 addresses would work. This is because the connection needs to be tunneled through the login node and redirect the port.

  5. To access Jupyter notebook’s web interface, open a new terminal session and connect to Discovery.

    1. Open a new terminal

    2. Connect to Discovery via SSH with the following parameters

      ssh -N -L 8888:discovery-c7:8888

      Basically, the -N flag is required for just forwarding ports and prevents the shell from executing a remote command. The -L flag specifies that the given port 8888: on the local (client) host is to be forwarded to discovery-c7 on port :8888 via Discovery’s login node

    3. On your client machine, open your browser(Chrome, Firefox, IE), go to the following → http://localhost:8888 or and you will be presented with Jupyter notebook’s login page.

    4. Now copy and paste the generated token from the previous terminal (from step 4) and paste into the password or token text box and click log in. Copying and pasting the full address(with the token ID) bypasses the log in page and signs you in automatically.

    5. Next, Open and run the Jupyter notebook project file located in my home directory.

  6. Logout: Next, when you are done interacting with Jupyter notebook and want to end the session, please navigate to the Jupyter notebook’s home page and click on the Quit button to shutdown the Jupyter server and kill the running job.


    Finally, on the second terminal use Ctrl + C to quit the port forwarding.

    It’s crucial that you use the Quit button rather than the Logout button to kill your interactive session with Jupyter notebook. Otherwise, you’d still be consuming resources on the Discovery cluster even when you are done with your intended task.

Using SBATCH script

  1. Open a new terminal session and connect to Discovery

  2. Create a new batch script and make it executable

    vi && chmod +x
  3. Copy, paste and save the script below in the file

    #SBATCH --job-name=jupyterTest
    #SBATCH --ntasks=1
    #SBATCH --cpus-per-task=2
    #SBATCH --mem-per-cpu=1g
    #SBATCH --time=2:00:00
    # Load necessary modules
    module purge
    module load anaconda
    # Start the notebook
    srun jupyter notebook --no-browser --ip=
  4. Submit the batch script



    Submitted batch job 115243
  5. Check output file for the node and port information.

    tail -f slurm-115243.out


        To access the notebook, open this file in a browser:
     Or copy and paste one of these URLs:

    Now take note of the host: discovery-c1.cluster.local port: 8888 and the generated token:d0729c0a802e08856109ef837b871fb6ddfd5e5791453e83

  6. Finally, carry out step 5 process of Running Jupyter Notebook - Using srun (Interactively) and replace the host: discovery-c1, port: 8888 and token: d0729c0a802e08856109ef837b871fb6ddfd5e5791453e83 where necessary.