Repository navigation
Description
People using Dask on traditional job schedulers often depend on PBS scripts. It would be useful to include a plain example in the documentation that users to download, modify, and run.
What we do now
Currently we point users to the setup network docs, and in particular the section about using job schedulers with a shared network file system. The instructions there suggest that users submit two jobs, one for the scheduler and one for the workers:
# Start a dask-scheduler somewhere and write connection information to file
qsub -b y /path/to/dask-scheduler --scheduler-file /path/to/scheduler.json
# Start 100 dask-worker processes in an array job pointing to the same file
qsub -b y -t 1-100 /path/to/dask-worker --scheduler-file /path/to/scheduler.jsonHowever this is flawed because the scheduler or workers may start and run independently from each other. It would be better to place them into a single job, where one special node is told to be the dask-scheduler process and all other nodes are told to be the dask-worker processes. Additionally we would like to offer some guidance on tuning the number of CPUs and pointing workers to use local high-speed scratch disk if available.
PBS script options
Many docs on PBS scripts exist online, but each seems to be made by an IT group at a separate super-computer. It is difficult to tease out what is general to all systems and what is specific to a single supercomputer or job scheduler. After reading from a number of pages I've cobbled together the following example.
#!/bin/bash -login
# Configure these values to change the size of your dask cluster
#PBS -t 1-9 # Nine nodes. One scheduler and eight workers
#PBS -l ncpus=4 # Four cores per node.
#PBS -l mem=20GB # 20 GB of memory per node
#PBS -l walltime=01:00:00 # will run for at most one hour
# Environment variables
export OMP_NUM_THREADS=1
# Write ~/scheduler.json file in home directory
# connect with
# >>> from dask.distributed import Client
# >>> client = Client(scheduler_file='~/scheduler.json')
# Start scheduler on first process, workers on all others
if [[ $PBS_ARRAYID == '1' ]]; then
dask-scheduler --scheduler-file $HOME/scheduler.json;
else
dask-worker
--scheduler-file $HOME/scheduler.json \
--nthreads $PBS_NUM_PPN \
--local-directory $TMPDIR \
--name worker-$PBS_ARRAYID \
> $PBS_O_WORKDIR/$PBS_JOBID-$PBS_ARRAYID.out \
2> $PBS_O_WORKDIR/$PBS_JOBID-$PBS_ARRAYID.err;
fi
https://wiki.hpcc.msu.edu/display/hpccdocs/Advanced+Scripting+Using+PBS+Environment+Variables
http://www.pbsworks.com/documentation/support/PBSProUserGuide10.4.pdf
Questions
- What is the difference between
ncpusandppn? - How about
-t 1-8andnodes=8?
Does this actually work? I suspect not. I don't have a convenient testing system for this and would appreciate coverage by a few different groups.
Activity
apatlpo commentedon Jul 17, 2017
Hi,
I actually have access to a cluster that uses PBS scripts and would very much like to compute distributed xarray computations on it.
Your code does not work for me right now for multiple reasons, the main one being that dask-distributed is not installed on the cluster. Do you think I could install it locally? or will that require sys admins to step in?
aurelien
martindurant commentedon Jul 17, 2017
I believe PBS_ARRAYID is indexed from zero, although this will not matter - we ensure to create exactly one scheduler either way.
During sprints, a mini-script very much like this one did succeed in setting up a cluster and running a joblib-derrived workflow.
mrocklin commentedon Jul 17, 2017
@apatlpo you can install dask using pip or conda. If you have a local python installation (such as would be created with anaconda) then you should be able to follow the instructions here without help from your system administrator: http://distributed.readthedocs.io/en/latest/install.html
martindurant commentedon Jul 17, 2017
One obvious possibility is to have the (conda) python distribution in a directory accessible to all machines. Also, code in knit exists to build an environment to a description or wrap an existing one and place it in a particular location.
The PATH would need to be set to see wherever python ends up, or call python by absolute path.
(pip install against a system python will work too, using the
--userflag)apatlpo commentedon Jul 17, 2017
I believe the conda install went successfully.
After a very quick playing around before dinner time, it's not working yet but
here is what I've got for my PBS script:
the output is:
If you have any suggestions I'll give it a try, thanks
mrocklin commentedon Jul 17, 2017
it looks like it's treating each of the individual lines in the dask-worker command as a separate commend. Looking at my text from above it looks like I forgot a trailing slash after
dask-worker(which I have now added in an edit. You might want to try adding that that slash afterdask-worker.apatlpo commentedon Jul 17, 2017
The code is not crashing after few minutes with the trailing slash but there is not output.
How can I tell if everything went well?
Note also that in the preceding error code, the variables PBS_ARRAYID, PBS_NUM_PPN were empty.
Shouldn't this be a problem?
martindurant commentedon Jul 17, 2017
Can you also try printing $PBS_ARRAY_INDEX ?
You should probably have some .out and .err files with logging information. Similar
>output should be added to the scheduler command too. If things are working correctly, there should be no output as such, but you should be able to connect to the scheduler from a python shell with(note that you echo
$PBD_JOBIDinstead of$PBS_JOBID)guillaumeeb commentedon Jul 17, 2017
Hi everybody, and thank you Matthew for this script. I was just planning to make such a tool script for our HPC cluster at CNES. I will start from yours and try to make it work on our supercomputer. I hope I will be able to look at it this week.
But here is a few things I can tell you after a first look:
Looking at @apatlpo solution, here is what I can say:
Okay so on a second thought, the idea of using job arrays seemed promising, but I believe the flaw I underline makes it not usable. In order to be able to launch several process, so several workers, in only one PBS job, we will need to use something like pbsdsh command, which allows to launch a given command on every resource asked to PBS. I have done this for launching Spark clusters using PBS, and this is probably well suited also for Dask. I will try to improve your proposal with this solution, and share the result here.
martindurant commentedon Jul 17, 2017
@guillaumeeb : I thought for an array, you can specify "I need X tasks, of which Y must run concurrently", although I don't know the syntax for this.
guillaumeeb commentedon Jul 17, 2017
@martindurant: You may be right, I will check that tomorrow and tell you, This would be a really nice and clean solution.
guillaumeeb commentedon Jul 17, 2017
Another thought, what about the DRMAA proposed contributions on the Setup Network page, like https://github.com/dask/dask-drmaa? It seems a very elegant solution to be able to spawn a Dask cluster on PBS directly from a Python API. As anybody played with this?
mrocklin commentedon Jul 17, 2017
In my experience users ask far more often for PBS scripts than for help with DRMAA. I'm inclined to meet them with what they already know and use.
That being said, adding DRMAA to the documentation seems like a fine idea to me.
guillaumeeb commentedon Jul 17, 2017
I am also far more used to PBS scripts :). I don't even know if DRMAA tools can work with our PBS Scheduler version. Another thing I need to check. Starting with the script sounds much more simple to me, and still a very good and usable option.
apatlpo commentedon Jul 18, 2017
As anticipated by Guillaume, the script does seem to work, here is the relevant part of the output log:
Note that I have modified the number script and am now using upon Guillaume suggestion:
#PBS -l select=14:ncpus=2:mem=120GLet me know if you want me to try something else.
98 remaining items
lzamparo commentedon Sep 26, 2017
This example worker log suggests two problems:
dask-workercommand line)mrocklin commentedon Sep 27, 2017
Yes, see
--nthreadsand--memory-limitin particular.It did connect though, which shows that they found each other. Is your client on a machine that is able to see the scheduler? Perhaps everything connected except for that?
lzamparo commentedon Sep 27, 2017
@mrocklin yes, all of the client machine, scheduler, and worker nodes are on the same network, so visibility should not be an issue.
lzamparo commentedon Sep 27, 2017
Also, I looked at the docs for
dask-workerbut didn't see any way to specify the number of CPU cores, is it in fact via--nthreads?guillaumeeb commentedon Oct 30, 2017
Hi everybody,
Found time to work again on this script this morning. Thanks to some examples found in https://github.com/opendatacube github project and the work of a coworker ont it. I used a conda environment like what is done by @mrocklin in pangeo-data/pangeo#2. Here is what I've got:
This seems to work from the client perspective:
I tried to use different network interfaces because I have problem when loading Dask web UI: this takes a lot of time and most of the time it never works. Don't know why yet, if somebody has a hint...
guillaumeeb commentedon Jan 7, 2018
Hi everyone,
A quick word to share with you work that has been done on Dask (and also Spark) on PBS at @CNES. PBS scripts to launch Dask are available in this repo: https://github.com/guillaumeeb/big-data-frameworks-on-pbs.
Cheers.
rabernat commentedon Jan 8, 2018
@guillaumeeb, fantastic! Thanks for sharing your progress.
Would you and the CNES folks be interested in collaborating on a project benchmarking the performance of dask vs spark on common analysis workflows?
gmaze commentedon Jan 8, 2018
Hi @rabernat @guillaumeeb, at Ifremer we would be interested in looking at such benchmarking !
Note that I also raised a question with regard to machine learning methods on xarray/dask vs pyspark/MLlib here , some of our classic analysis could be part of the benchmark
mrocklin commentedon Jan 8, 2018
+1 on Dask/Spark benchmarking. This is a frequently asked question.
guillaumeeb commentedon Jan 20, 2018
@rabernat (and @gmaze @mrocklin), don't know if you got my email? We would be glad at CNES to collaborate on such a project. We should just define together how we could contribute, on which use cases, and on which place to discuss about it (e.g. Pangeo? Another Dask or Distributed issue?)
Any idea yet?
rabernat commentedon Jan 21, 2018
alvarouc commentedon Mar 2, 2018
@lzamparo Did you figure out your issue? I was experiencing the sample problem. I noticed that at the client I should put the scheduler address directly instead of the scheduler file and it worked.
That is
c = Client('111.99.99.9:8786')
instead of
c = Client(scheduler_file='/path/to/scheduler.json')
lzamparo commentedon Mar 5, 2018
@alvarouc Thanks for following up. I never did fix this for a bunch of reasons. Good to hear you found a workaround. I presume you still interrogate the
/path/to/scheduler.jsonfile to get the IP, and manually craft the string for theClientconstructor?mrocklin commentedon Jun 21, 2018
This has been resolved by the dask-jobqueue project.