Prepping / Installing Jupyter
To begin running Jupyter on the HPC you must first load a python or conda module. If you wish to import research-specific python modules into your notebook, then it is recommended to create/source your own conda environment first, and then install Jupyter through pip.
Example 1: Installing Jupyter with no environment sourced
module load python/python3/3.9.6
pip install jupyter
To use this build of Jupyter, you must load the appropriate python module prior to launching Jupyter.
For example: module load python/python3/3.9.6
Example 2: Install Jupyer with a newly created sourced environment (conda)
source /share/apps/modulefiles/conda_init.sh
conda create -n myenv -c conda-forge python
conda activate myenv
pip install jupyter
To use this build of Jupyter, you must source your conda enviroment prior to launching Jupyter.
For example: source /share/apps/modulefiles/conda_init.sh && conda activate myenv
Running Jupyter
Open 2 terminals and a browser on your machine.
Terminal #1
We must start an interactive session on a compute node.
Run (tweak as needed):srun -p main --qos main --time=02:00:00 --ntasks-per-node 1 --cpus-per-task 4 --mem-per-cpu 4G --pty bash
Launch Jupiter on the node.
jupyter notebook --no-browser --ip=0.0.0.0
The resulting output should look similar to:
[I 13:09:24.391 NotebookApp] Serving notebooks from local directory: /home/<USERNAME>
[I 13:09:24.391 NotebookApp] Jupyter Notebook 6.4.11 is running at:
[I 13:09:24.391 NotebookApp] http://<COMPUTE_NODE>.local:8888/?token=<TOKEN>
[I 13:09:24.392 NotebookApp] or http://127.0.0.1:8888/?token=<TOKEN>
[I 13:09:24.392 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:09:24.415 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/<USERNAME>/.local/share/jupyter/runtime/nbserver-86752-open.html
Or copy and paste one of these URLs:
http://<COMPUTE_NODE>.local:8888/?token=<TOKEN>
or http://127.0.0.1:8888/?token=<TOKEN>
Take note of the assigned port number. It is highlighted in red, bolded, and italicized (let us call this variable <PORT#>).
Terminal #2
Log in with the following command (in this example, we are using UAHPC, however, these instructions should work fine with CHPC). Be sure to replace <PORT#> with the port number you specified/got in Terminal #1, and replace <COMPUTE_NODE> with the compute node your interactive job landed on:
ssh -N -L 9999:<COMPUTE_NODE>:<PORT#> <USERNAME>@uahpc.ua.edu
This binds <PORT#> to your local computer’s port 9999.
Lastly, from Terminal #1, copy the line that says:
http://127.0.0.1:<PORT#>/?token=<whatever_token_that_is_unique>
Paste this your browser’s URL and replace <PORT#> with your bound computer port. In this example, we used 9999.
http://127.0.0.1:9999/?token=<unique_token>