Connect to a remote jupyter lab server
In this tutorial you will learn:
- how to setup a jupyter lab server on the Rysy cluster.
- how to connect to it from your home pc.
Login to rysy
Open your terminal, login to the Rysy cluster and launch an interactive job.
bash-4.2$ salloc -N1 -n10 --account=GXX_YY --gres=gpu:1 --time=08:00:00
bash-4.2$ srun --pty /bin/bash -l
Prepare the enviroment
Create a virtual enviroment to install python's packages.
If you have already done so, then just activate the enviroment source jupyterlab_env/bin/activate
.
bash-4.2$ python3 -m venv jupyterlab_env
bash-4.2$ source jupyterlab_env/bin/activate
(jupyterlab_env) bash-4.2$ pip install --upgrade pip
(jupyterlab_env) bash-4.2$ pip install -r requirements.txt
The content of the $ cat requirements.txt
shall include
jupyterlab
ipympl
ipywidgets
ipynb
numpy
numba
sympy
scipy
matplotlib
pandas
Run the jupyter lab server
Check the name of your computational node on the cluster:
(jupyterlab_env) bash-4.2$ hostname
rysy-n5.icm.edu.pl
Run the jupyter lab server on non standard port (other than 8888). This is required to avoid collisions with other users. In this tutorial we will use port 1234, but please choose another number.
(jupyterlab_env) bash-4.2$ jupyter lab --port=1234 --ip=*
You shall see the following:
Copy the link and modify it, for example
# from
http://rysy-n5.icm.edu.pl:1234/lab?token=63c655fd77172deae9991f66fa1e35a1d96622e08b4b82b0
# to
http://localhost:8888/lab?token=63c655fd77172deae9991f66fa1e35a1d96622e08b4b82b0
Create a ssh tunel from your local computer
Open another terminal and create the ssh tunel.
Make sure that you replaced rysy-n5.icm.edu.pl:1234
with correct pair hostname and port (see above).
ssh -L <local port>:<remote ip address>:<remote port> <public ssh server ip address>
(john@home_pc)$ ssh -L 8888:rysy-n5.icm.edu.pl:1234 -v -J hpc.icm.edu.pl rysy
Paste
http://localhost:8888/lab?token=63c655fd77172deae9991f66fa1e35a1d96622e08b4b82b0
to your browser. Enjoy.
References
If phrases such as 'ssh local and remote port forwarding' and 'ssh jump host' sounds unfamiliar to you, feel free to google them, for example: