This page describes how to run Pangeo and Dask with JupyterHub using a python virtual environment on Setonix with Slurm. This involves launching JupyterHub and then connecting to the Jupyter server.
Installation
Here we use a python virtual environment for the installation of Pangeo and Dask. This allows users to add new python packages as required during their analysis. The installation steps are described below:
Setting up the batch script
Once you have the python virtual environment installed, you can then launch your Jupyter Notebook on Setonix with the following script. This script activates the python virtual environment and launches a Jupyter Notebook on a node in the work partition. You will need to edit the Slurm parameters and working directory to suit your needs.
Please note that the port forwarding will not work correctly if you run Jupyter on the login node.
Run your Jupyter notebook server
To start, submit the SLURM jobscript. It will take a few minutes to start (depending on how busy the queue and how large of an image you're downloading). Once the job starts you will have a SLURM output file in your directory, which will have instructions on how to connect at the end.
Now open a separate terminal window in your local computer and execute the ssh command to perform the tunneling between local and remote ports. In this case:
ssh -N -f -L 8888:nid002024:8888 <username>@setonix.pawsey.org.au
Supply your Setonix password if requested. Then go to your internet browser and navigate to the Jupyter address (e.g. http://127.0.0.1:8888/lab?token=a8135a22fab1a3f97214fa1424eefb25c4e415f6caaab030 in the above example). This will take you to your Jupyter lab, where you can run Pangeo and Dask.
When selecting the URL to use in your browser, ensure you use the address with 127.0.0.1 and not nidXXXXX.
Example Dask usage from Jupyter
The following is provided as an example of how you might use Dask from within the Jupyter session.
from dask_jobqueue import SLURMCluster cluster = dask_jobqueue.SLURMCluster( cores=24, memory='100GB', shebang='#!/bin/bash -l', # default is bash processes=6, local_directory='/scratch/your_working_dor', job_extra_directives=['--account=pawseyXXXX'], # additional job-specific options walltime='02:00:00', queue='work', ) cluster.scale(jobs=2) # launch 2 jobs, each of which starts 6 worker processes cluster.scale(cores=48) # Or specify cores or memory directly cluster.scale(memory="200 GB") # Or specify cores or memory directly ## Print job script for you to review print(cluster.job_script()) ##Connect the cluster to the notebook client = Client(cluster) client ## You should then see the workers spawn and the dashboard start up. You can also check the jobs spawning on the Setonix terminal with `watch squeue -u username -l`
Cleaning up when you are finished
Once you have finished:
- In the remote Pawsey cluster, cancel your job with
scancel <job_id>
. In you local computer terminal, kill the SSH tunnel, based on the command displayed in the output file:
kill $( ps x | grep 'ssh.*-L *8888:nid002024:8888' | awk '{print $1}' )
External Links
These external links may be useful for you in making the most of Dask:
- More information on how to submit Dask jobs to the Slurm queue via Jupyter, and other related information: https://jobqueue.dask.org/en/latest/examples.html
- Talk from SciPy 2019 conference, "Turning HPC Systems into Interactive Data Analysis Platforms" by A. Banihirwe. This gives a tutorial about using Dask on HPC. https://www.youtube.com/watch?v=vhawO8fgD64