-
This site is deprecated and will be decommissioned shortly. For current information regarding HPC visit our new site: hpc.njit.edu
JupyterNotebooksAFS
Install Jupyter Notebook
Download and install Miniconda as described in Miniconda. To create a new environment and install Jupyter Notebook, use
login-1-105 ~ >: conda create --name jupyter python=3.7
Activate the new 'jupyter' environment
login-1-106 ~ >: conda activate jupyter (jupyter) login-1-107 ~ >:
Next, install Jupyter Notebook
(jupyter) login-1-107 ~ >: conda install jupyter notebook
Create the following script (jupyter.sh)
#!/bin/bash -l conda activate jupyter port=$(shuf -i 6000-9999 -n 1) cat<<EOF Jupyter server is running on: $(hostname) Job starts at: $(date) Step 1: Create SSH tunnel Open new terminal window, and run: (If you are off campus you will need VPN running) ssh -L $port:localhost:$port $USER@$HOSTNAME Step 2: Connect to Jupyter Keep the terminal in the previouse step open. Now open browser, find the line with Or copy and paste one of these URLs: the URL will be something like: http://localhost:${port}/?token=XXXXXXXX EOF jupyter notebook --no-browser --port $port --notebook-dir=$(pwd)
Next, create a script which will execute krenew (krenew.sh). krenew
is required as the AFS tokens expire at eight-hour intervals so that tokens can be renewed automatically to run the Jupyter Notebook process without any interruption. For details, see Krenew
krenew -t -b -K 60 -- bash -c "$PWD/jupyter.sh >> $PWD/output.log 2>&1"
To make the file krenew.sh executable, use
chmod +x krenew.sh
Then execute the krenew.sh
./krenew.sh
This will generate an output file output.log
. Now open the log file and copy the URL. The URL will be in the following format
http://localhost:${port}/?token=XXXXXXXX
To kill the Jupyter Notebook process, you need to use the following command first to see the currently running processes.
login-1-106 ~ >: top -u guest
Replace guest
with NJIT UCID. Once you execute the command, you will see the output something like the following
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20653 guest 20 0 33132 1440 1072 S 0.0 0.0 0:00.04 krenew 20654 guest 20 0 113284 1216 1040 S 0.0 0.0 0:00.00 bash 20655 guest 20 0 113288 1624 1368 S 0.0 0.0 0:00.00 jupyter.sh 20693 guest 20 0 482688 89112 13024 S 0.0 0.0 1:23.88 jupyter-noteboo 21752 guest 20 0 862064 56588 9084 S 0.0 0.0 0:33.90 python 21772 guest 20 0 126384 2164 1684 S 0.0 0.0 0:00.00 bash 26251 guest 20 0 184632 2504 1116 S 0.0 0.0 0:00.00 sshd 26252 guest 20 0 126252 2100 1636 S 0.0 0.0 0:00.00 bash 26294 guest 20 0 172940 2524 1648 R 0.0 0.0 0:00.14 top
Identify the process ID (PID) responsible for running Jupyter Notebook. In this above output, the PID is 20693. To kill the process, use
login-1-106 ~ >: kill -9 20693