Jupyter notebooks

Jupyter Notebooks

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 ## 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 local host (i.e., laptop) -------------------------Copy----------------------------------- ssh -N -L $ipnport:$ipnip:$ipnport $USER@knot.cnsi.ucsb.edu Open this address in a browser on local host; see token below ------------------------------------------------------------ localhost:$ipnport EOF ## Launch jupyter server jupyter-notebook --no-browser --port=$ipnport --ip=$ipnip --NotebookApp.token=''

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


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.