Jupyter Notebook
Setup jupyter notebook on compute note, and access it through local browser
With the help of Ondemand GPU, we have the VNC access to the compute node via browser, however, it is still not that easily to debug interactively.
So here is another solution: Running the jupyter notebook on the compute node, and then reverse tunnel it to the login node of the Kaya, and tunnel your local machine to the login node.

Three steps to achieve this:
Allocate compute nodes
Run jupyter notebook properly on allocated compute nodes
Setup tunnels, so can access jupyter notebook locally
Allocate compute nodes
As we described before, to allocate compute nodes, you will need to login to the login nodes, load the required modules include conda, etc. And then run a command to request the nodes.
salloc -p gpu --mem=16G -N 1 -n 8 --gres=gpu:v100:1

This means you have been allocated a GPU node.
Run jupyter lab
You can choose to run either jupyter notebook or jupyter lab. Either way works.
The environment setup process can be either on the compute nodes or login node, it does not matter.
You need to activate your own conda environment, for me I activate demo
environment.
Then install the jupyterlab
pip install jupyterlab
Then setup the password configuration
jupyter lab --generate-config
It will tell you where the configuration file is, normally it is in /home/youruserid/.jupyter/
jupyter_lab_config.py

Then if you want to use a password to access jupyter lab browser interface, you need to setup the password within the /home/youruserid/.jupyter/
jupyter_lab_config.py
The password should be hashed.

For example the UWANLP hashed password is:
argon2:$argon2id$v=19$m=10240,t=10,p=8$gSgvqt1Be1AojDo3V2Qreg$Aq7XS0IWjKXWFpnTcxvzEHkWVpuWekhbcrnO7PC4b0Q
Update the /home/youruserid/.jupyter/
jupyter_lab_config.py
and save it

Then run jupyter lab in background from your group directory on the compute node, like /group/projectid/myuserid
(this is because this is the designed folder for you to hold large files)
About the port selection
Then next you will need to start the jupyter notebook on a port, you can specifiy a port. But be aware, because we are on the same port, so if you revese tunnel from compute node to login node for port 9999, you will hold 9999 for login node, and then next person will have a node confilct.
So we have two things we need to pay attention here:
Select your own port and make it private, you can try very large numbers to be safe.
If two or three of you work together, you can have the same jupyter setup on compute node, and only do the setup tunnel from local machine to login node step for the rest people.
nohup jupyter lab --port 9999 --no-browser --ip='*' &
You should be able to check the logs via command
tail nohup.out
Setup tunnels
Setup reverse tunnel from compute node to login node
First, get the private ip for the login node, open a new terminal shell, login to login node, and then run command on login node
ifconfig

For me, it is 10.23.0.241
should be the same for everyone
Next go back to the allocated compute node shell, run the comand
ssh -R 9999:localhost:9999 [email protected]
And then type in your password.
Setup tunnel from local machine to login node
ssh -L localhost:9999:localhost:9999 [email protected]
Type in your password if you have not setup the automatically one.
Access via browser
In your local browser, type in http://localhost:9999/lab
Put the password UWANLP


Last updated