Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


(under development)

Table of Contents

Introduction

...

No Format
ssh -N -f -L 8889:gc-prd-hpcn002:8889 snumber@gc-prd-hpclogin1.rcs.griffith.edu.au
#e.g: ssh -N -f -L 8890:gc-prd-hpcn002:8890 s123456@gc-prd-hpclogin1.rcs.griffith.edu.au

...

On 

...

a 

...

windows 

...

computer, 

...

 

...

Open 

...

a 

...

Command 

...

Prompt 

...

terminal 

...

by 

...

searching 

...

“Command 

...

Prompt” in the

...

Window 

...

search 

...

bar 

...

at 

...

the 

...

bottom 

...

left 

...

of 

...

your 

...

screen. 

...

In 

...

the 

...

command

...

line, 

...

type 

...

ssh 

...

-N 

...

-f 

...

Lastly, open a web browser on your laptop/desktop and copy and paste the URL from the previous output:

No Format
http://127.0.0.1:8889/?token=61f8a2aa8ad5e469d14d6a1f59baac05a8d9577916bd7eb0
Another example:

http://127.0.0.1:8890/?token=8df8a9a79c00f0813055d48dfc79785c8ff6597cc0b1c456

Choose "New" then "Python 3" to launch a new notebook. Note that Jupyter may use a port that is different than the one you specified. This is why it is important to copy and paste the URL. 
When you are done, terminate the ssh tunnel on your local machine (desktop/laptop) by running lsof -i tcp:8889 to get the PID and then kill -9 <PID> (e.g., kill -9 6010).

...

The second way of running Jupyter on the cluster is by submitting a job via pbs that launches Jupyter on the compute node

In order to do this we need a submission script like the following called jupyter.pbs

No Format
#!/bin/bash
#PBS -N jupyterNotebook
#PBS -m abe
#PBS -M myEmail@griffithuni.edu.au
#PBS -q workq
#PBS -l select=1:ncpus=1:mem=12gb,walltime=5:00:00
module load anaconda3/2021.11

# get tunneling info
XDG_RUNTIME_DIR=""
node=$(hostname -s)
user=$(whoami)
cluster="gc-prd-hpclogin1"
port=8889

# print tunneling instructions jupyter-log
echo -e "
Command to create ssh tunnel:
ssh -N -f -L ${port}:${node}:${port} ${user}@${cluster}.rcs.griffith.edu.au

Use a Browser on your local machine to go to:
localhost:${port}  (prefix w/ https:// if using password)"
cd  $PBS_O_WORKDIR
# load modules or conda environments here
module load anaconda3/2020.11
source activate myenv
# Run Jupyter
jupyter-notebook --no-browser --port=${port} --ip=${node}

This job launches Jupyter on the allocated compute node and we can access it through an ssh tunnel as we did in the previous section.

First, from the head node, we submit the job to the queue:

...

Once the job is running, a log file will be created that is called jupyter-notebook-<jobid>.log. The log file contains information on how to connect to Jupyter, and the necessary token.

In order to connect to Jupyter that is running on the compute node, we set up a tunnel on the local machine as follows:

No Format
ssh -N -f -L 8889:gc-prd-hpcn002:8889 <YourNetID>@tigercpu.princeton.edu

where gc-prd-hpcn002 is the name of the node that was allocated in this case.

In order to access Jupyter, navigate to http://localhost:8889/ In the directions on this page, the only packages that are available to the user are those made available by loading the anaconda3 module. If you have created your own Conda environment then you will need to activate it (e.g source activate myenv)

Aside on ssh

Looking at the man page for ssh, the relevant flags are:

...

Aside on Open Ports

Jupyter will automatically find an open port if you happen to specify one that is occupied. If you wish to do the scanning yourself then run the command below:

netstat -antp | grep :88 | sort

...

Internet access is available when running Jupyter on a OnDemand node (currently only n059,rcs,griffith.edu.au). There is no job scheduler on the onDemand nodes. Be sure to use these nodes in a way that is to fair all users.

No Format
# from behind VPN if off-campus or on wireless
ssh -Y snumber@n059,rcs,griffith.edu.au
module load anaconda3/2020.11
source activate snumber-tf-cpu #e.g source activate s123456-tf-cpu
jupyter-notebook --no-browser --port=8889 --ip=127.0.0.1
# note the last line of the output which will be something like
http://127.0.0.1:8889/?token=61f8a2aa8ad5e469d14d6a1f59baac05a8d9577916bd7eb0
# leave the session running

Then in a new terminal on your laptop,

No Format
-L 8889:gc-prd-hpcn002:8889 snumber@gc-prd-hpclogin1.rcs.griffith.edu.au and click enter

Note that we selected the Linux port 8889 to connect to the notebook. If you don't specify the port, it will default to port 8888 but sometimes this port can be already in use either on the remote machine or the local one 
(i.e., your laptop). If the port you selected is unavailable, you will get an error message, in which case you should just pick another one. It is best to keep it greater than 1024.
Consider starting with 8888 and increment by 1 if it fails, e.g., try 8888, 8889, 8890 and so on. If you are running on a different port then substitute your port number for 8889.

Lastly, open a web browser on your laptop/desktop and copy and paste the URL from the previous output:

No Format
http://127.0.0.1:8889/?token=61f8a2aa8ad5e469d14d6a1f59baac05a8d9577916bd7eb0
Another example:

http://127.0.0.1:8890/?token=8df8a9a79c00f0813055d48dfc79785c8ff6597cc0b1c456

Choose "New" then "Python 3" to launch a new notebook. Note that Jupyter may use a port that is different than the one you specified. This is why it is important to copy and paste the URL. 
When you are done, terminate the ssh tunnel on your local machine (desktop/laptop) by running lsof -i tcp:8889 to get the PID and then kill -9 <PID> (e.g., kill -9 6010).


Running it as a PBS job


The second way of running Jupyter on the cluster is by submitting a job via pbs that launches Jupyter on the compute node

In order to do this we need a submission script like the following called jupyter.pbs

No Format
#!/bin/bash
#PBS -N jupyterNotebook
#PBS -m abe
#PBS -M myEmail@griffithuni.edu.au
#PBS -q workq
#PBS -l select=1:ncpus=1:mem=12gb,walltime=5:00:00

# get tunneling info
XDG_RUNTIME_DIR=""
node=$(hostname -s)
user=$(whoami)
cluster="gc-prd-hpclogin1"
port=8889
##choose your own unique port between 8000 and 9999

cd  $PBS_O_WORKDIR
# print tunneling instructions to tunnel.$PBS_JOBID.txt
JJID=`echo $PBS_JOBID|sed 's/\.gc-prd-hpcadm//g'`
echo -e "
Command to create ssh tunnel:
ssh -N -f -L ${port}:${node}:${port} ${user}@${cluster}.rcs.griffith.edu.au

Use a Browser on your local machine to go to:
localhost:${port}  (prefix w/ https:// if using password)" >tunnel.$JJID.txt
# load modules or conda environments here
module load anaconda3/2021.11
source activate snumber-tf-cpu
# Run Jupyter
jupyter-notebook --no-browser --port=${port} --ip=${node} 2>&1 | tee jupnote.$JJID.log


This job launches Jupyter on the allocated compute node and we can access it through an ssh tunnel as we did in the previous section.

First, from the head node, we submit the job to the queue:

qsub jupyter.pbs

Once the job is running, a log file will be created that is called jupnote.<jobid>.log. The log file contains information on how to connect to Jupyter, and the necessary token.

In order to connect to Jupyter that is running on the compute node, we set up a tunnel on the local machine as follows:

No Format
ssh -N -f -L 8889:gc-prd-hpcn002:8889 s123456@gc-prd-hpclogin1.rcs.griffith.edu.au

Have a look at the file named tunnel.$PBS_JOBID.txt for exact syntax. Copy and paste that on a laptop (if running linux or mac). On a windows computer,  Open a Command Prompt terminal by searching “Command Prompt” in the
Window search bar at the bottom left of your screen. In the command
line, type ssh -N -f -L 8889:gc-prd-hpcn002:8889 snumber@gc-prd-hpclogin1.rcs.griffith.edu.au and click enter

where gc-prd-hpcn002 is the name of the node that was allocated in this case.

In order to access Jupyter, have a look at the file named "jupnote.$JJID.log" and copy and paste one of these URLs. As an example:

http://127.0.0.1:8889/?token=2ac632f932d17059377fcfe25afc9d52fd29bf83ba6c0999


Only packages that are available to the user are those made available by loading the anaconda3 module. If you have created your own Conda environment then you will need to activate it (e.g source activate myenv)

Aside on ssh

Looking at the man page for ssh, the relevant flags are:

-N  Do not execute a remote command. This is useful for just forwarding ports.

-f  Requests ssh to go to background just before command execution. This is useful if ssh is
going to ask for passwords or passphrases, but the user wants it in the background.

-L  Specifies that the given port on the local (client) host is to be forwarded to the given
host and port on the remote side

Aside on Open Ports

Jupyter will automatically find an open port if you happen to specify one that is occupied. If you wish to do the scanning yourself then run the command below:

netstat -antp | grep :88 | sort


onDemand Nodes

Internet access is available when running Jupyter on a OnDemand node (currently only n059,rcs,griffith.edu.au). There is no job scheduler on the onDemand nodes. Be sure to use these nodes in a way that is to fair all users.

No Format
# from behind VPN if off-campus or on wireless
ssh -Y snumber@n059,rcs,griffith.edu.au
module load anaconda3/2020.11
source activate snumber-tf-cpu #e.g source activate s123456-tf-cpu
jupyter-notebook --no-browser --port=8889 --ip=127.0.0.1
# note the last line of the output which will be something like
http://127.0.0.1:8889/?token=61f8a2aa8ad5e469d14d6a1f59baac05a8d9577916bd7eb0
# leave the session running


Then in a new terminal on your laptop,

No Format
ssh -N -f -L localhost:8889:localhost:8889 snumber@n059.rcs.griffith.edu.au

On a windows computer,  Open a Command Prompt terminal by searching “Command Prompt” in the
Window search bar at the bottom left of your screen. In the command
line, type ssh -N -f -L localhost:8889:localhost:8889 snumber@n059.rcs.griffith.edu.au

...

When you are done, terminate the ssh tunnel by running lsof -i tcp:8889 to get the PID and then kill -9 <PID> (e.g., kill -9 6010).



Tech support videos: 

Available on request.

/wiki/spaces/AS/pages/153550880 

Reference

1. https://jupyter.org/try
2. https://researchcomputing.princeton.edu/support/knowledge-base/jupyter

3. Jupyter on the gpu visualisation node

4. https://blogs.iu.edu/ncgas/2021/05/07/tunneling-a-jupyter-notebook-from-an-hpc/