## Accessing Jupyter notebooks in the cluster

One can access jupyter notebooks on compute systems using SOCKS proxy and ssh through watgpu.cs.  From a (Linux/OSX) terminal ssh to watgpu.cs:

`ssh -D 7070 user@watgpu.cs.uwaterloo.ca`

On a browser on your local (client) system, configure traffic to use a SOCKS proxy at localhost port 7070. FoxyProxy for Firefox can make this configuration easy to set up and modify.

### Preliminaries: Create a conda environment that includes the jupyter server

Also add required conda packages for your working environment e.g. pytorch:

    conda create -y -n jupyter-server
    conda activate jupyter-server
    conda install -c conda-forge pytorch-gpu
    pip install jupyter
    conda deactivate

### Using jupyter notebooks with your environment

Make an interactive reservation with the SLURM scheduler:

    salloc --gres=gpu:1 --cpus-per-task=4 --mem=32G --time=1:00:00
Once the reservation starts, ssh to the allocated compute system e.g. watgpu208:

    ssh watgpu208
Activate your jupyter-server environment and start a  jupyter notebook:

    conda activate jupyter-server

    jupyter notebook --ip $(hostname -I | awk '{print $1}') --no-browser
    ...
    [I 2023-10-13 02:18:02.902 ServerApp] notebook | extension was successfully loaded.
    [I 2023-10-13 02:18:02.902 ServerApp] Serving notebooks from local directory: /u3/ldpaniak
    [I 2023-10-13 02:18:02.903 ServerApp] Jupyter Server 2.7.3 is running at:
    [I 2023-10-13 02:18:02.903 ServerApp] http://192.168.152.121:8888/tree?token=141a606c1ec9d9f76f65395bd1a4042fb3a5e04307283592
    [I 2023-10-13 02:18:02.903 ServerApp]     http://127.0.0.1:8888/tree?token=141a606c1ec9d9f76f65395bd1a4042fb3a5e04307283592
    [I 2023-10-13 02:18:02.903 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [C 2023-10-13 02:18:02.915 ServerApp] 
    
    To access the server, open this file in a browser:
        file:///u3/ldpaniak/.local/share/jupyter/runtime/jpserver-232011-open.html
    Or copy and paste one of these URLs:
        http://192.168.152.121:8888/tree?token=141a606c1ec9d9f76f65395bd1a4042fb3a5e04307283592
        http://127.0.0.1:8888/tree?token=141a606c1ec9d9f76f65395bd1a4042fb3a5e04307283592


Copy the link with the 8888 port to your broswer which has been configured to use SOCKSv4 proxy on localhost port 7070.
Your juptyer notebook will be available.

Be sure to shut down the server when done with Control-c.
