Using Jupyter Notebooks via SSH Tunnelling
Using Jupyter notebooks interactively on compute nodes is straightforward if you take the following steps:
Ensure that your python environment has the Jupyter package installed: e.g.,
pip install jupyterIf you would like to setup a re-usable password (alternative to the one-time, randomly generated tokens) for your notebooks, you can run
jupyter notebook --generate-config jupyter notebook passwordand then add/uncomment the following to your
~/.jupyter/jupyter_notebook_config.py:c.NotebookApp.open_browser = False c.NotebookApp.port = 8888 # (default port - you can choose any four-digit integer)In a job script or interactive session on a compute node, run
jupyter notebook --no-browser --port YOUR_PORT --ip $(hostname -f)
Once your job/notebook starts, check your job output (cat/ tail the SLURM output file of your job):
On your local machine, run:
ssh -N -L YOUR_PORT:YOUR_COMPUTE_NODE:YOUR_PORT YOUR_USERNAME@LOGIN_NODEIn a browser on your local machine, navigate to the link from your job output that starts with
http://127.0.0.1… (if there is no generated token, you must enter your password from step 2).
Once connected, you can create, run, and modify Jupyter notebooks running on the compute node directly from your local machine. If your internet connection is disrupted on your local machine, you can reconnect to the notebook by running step 3 again when your connection becomes stable.