Jupyter Notebooks

Status
Yes

Jupyter Notebooks (on knot) - this is just for reference, you probably really want to run on knot7 or pod. Follow those directions here.

If you like using Jupyter notebooks, you can do so on Knot (if using Anaconda). First, make sure that jupyter is installed (if not, install by conda install jupyter). Then, submit a job to the queue (one node only!) using the following job submission script

#!/bin/bash
#PBS -l nodes=1:ppn=1
#PBS -l walltime=01:00:00
####PBS -N Jupyter
#PBS -V

cd $PBS_O_WORKDIR # Goto job submission directory

export PATH="/home/$USER/anaconda2/bin:$PATH"

## get tunneling info
XDG_RUNTIME_DIR=""
ipnport=$(shuf -i8000-9999 -n1)
ipnip=$(hostname -i)

## print tunneling instructions to jupyter.info
cat > jupyter.info << EOF
Paste ssh command in a terminal on your local host (i.e., laptop)
it may take a minute or two for it to be ready.
-------------------------Copy-----------------------------------
on Mac/Linux: ssh -N -L $ipnport:$ipnip:$ipnport $USER@knot.cnsi.ucsb.edu
On PC:  putty -ssh -N -L $ipnport:$ipnip:$ipnport $USER@knot.cnsi.ucsb.edu
----------------------------------------------------------------
After it asks for your password, then open a web browser on your
local host to the address below.
------------------------------------------------------------
localhost:$ipnport
EOF

## Launch jupyter server
jupyter-notebook --no-browser --port=$ipnport --ip=$ipnip
/bin/rm -f ./jupyter.info

Now submit this script by qsub.

After the job starts running, check the file jupyter.info, which will tell you how to ssh from your local computer. Basically you are opening a SSH connection from your laptop or desktop back to the jobon Knot. Through this SSH connection your laptop/desktop runs a web server that connects to knot, and that server (your laptop/desktop) is what you're connecting to!

Copy and paste that line to your terminal and execute it. After this step, open your browser on your local computer and type the address

localhost:XXXX

where XXX is the ipnport printed in jupyter info. Now you can use Jupyter notebook on the compute nodes of Knot!

The above script will let you use Jupyter notebook for 1 hour and then terminate. If you need more time, increase the walltime.