Jupyter Notebooks on Oscar
Installing Jupyter Notebook
The anaconda modules provide jupyter-notebook. Users can also use pip or anaconda to install jupyter notebook.
Running Jupyter Notebook on Oscar
There are a couple of ways to use Jupyter Notebook on Oscar. You can run Jupyter Notebook
in an OOD Desktop App (VNC)
using a batch job
in an interactive session
With the batch job or interactive session method, you use a browser on your machine to connect to your Jupyter Notebook server on Oscar.
Do not run Jupyter Notebook on login nodes.
In an OOD Desktop App VNC Session
Start an OOD Desktop App (VNC) session, and open up a terminal in the VNC session. To start a Jupyter Notebook, enter
jupyter-notebookThis will start the Jupyter Notebook server and open up a browser with the notebook.
Using a Batch Job
Submit an ssh tunnel to the server.
Set up an ssh tunnel to the server.
Open a browser to view the notebook.
Use
scancelto end the batch job when you are done.
1. Submit batch script
Here is an example batch script to start a Jupyter notebook server on an Oscar compute node. This script assumes that you are not using a Conda or a virtual environment.
If you are using a Conda environment, replace the last two lines with these lines:
This script can be found in ~/batch_scripts. Copy this example and submit this script with
2. Set up an ssh tunnel to the notebook server
In this example the jobID is 7239096. To view the notebook server information, use cat. For this example:
Open a terminal on your machine and copy and paste the ssh -N -L ........ line into the terminal.
{% hint style="info" %} If you are using Windows, follow the Tunneling into Jupyter with Windows documentation to complete this step. {% endhint %}
Enter your Oscar password. Note it will appear that nothing has happened.
3. Open a browser to view the notebook (Using Batch Job)
Open a browser on your local machine to the address given in cat jupyter-log-{jobid}.txt. For example localhost:9349 (prefixed with https:// if using a password). The notebook will ask for a token. Copy the token from jupyter-log-{jobid}.txt. Then your notebook will start.
{% hint style="warning" %} Remember to scancel {jobid} when you are done with your notebook session. {% endhint %}
In an Interactive Session
Start Jupyter Notebook in an interactive job.
Set up an ssh tunnel to the server.
Open a browser to view the notebook.
Use
scancelto end the batch job when you are done.
1. Start a Jupyter Notebook in an interactive job
Start an Interactive job and then in your interactive session enter the following:
An output similar to the one below indicates that Jupyter Notebook has started:
2. Setup an ssh tunnel to the server
Open a terminal on your machine and enter the following line (replace $ipnip and $ipnport with the values from the two echo commands in the previous step).
{% hint style="info" %} If you are using Windows, follow the Tunneling into Jupyter with Windows documentation to complete this step. {% endhint %}
Enter your Oscar password. Note it will appear that nothing has happened.
3. Open a browser to view the notebook (Interactive Session)
Open a browser on your local machine to the address localhost:$ipnport (prefixed with https:// if using a password). $ipnport should be the value printed to the console in Step 1 from the echo $ipnport command. The notebook will ask for a token. You can copy the token from the output from Step 2.
4. Press Ctrl+C twice to kill your Jupyter Notebook server
Once you finish and no longer need the Jupyter Notebook server, you can kill the server by pressing Ctrl+C twice in your interactive session.
Last updated
Was this helpful?