I'm currently using Mathematica on a High Performance Cluster (HPC) which consists of many compute nodes each with around 16 cores. I currently run my Mathematica script on 20 of the nodes that invokes 10 cores and 10 of the subkernels licenses in Parallel, meaning I use 20 Mathkernel licenses and 200 subkernel licenses.
The problem is we have limited Mathkernel licenses (36, and for me to be using 20 of them is unfair on everyone else!) although ample subkernel licenses (288). Is there a way I can just use a single (or at least fewer) Mathkernel licenses to invoke the 200 subkernels I need?
Currently in each of the 20 scripts I just have
LaunchKernels[10];
ParellelTable[....];
which launches the 10 local subkernels on each node, but could I specify different nodes to launch subkernels on perhaps? Thereby I would only need to launch one Mathkernel which could invoke the 200 subkernels spread across the compute nodes.
Answer
What you need to launch subkernels across several nodes on a HPC cluster is the following:
- Figure out how to request several compute nodes for the same job
- Find the names of the nodes that have been allocated for your job
- Find out how to launch subkernels on these nodes from within the main kernel
All of these depend on the grid engine your cluster is using, as well as your local setup, and you'll need to check its docs and ask your administrator about the details. I have an example for our local setup (complete with a jobfile), which might be helpful for you to study:
https://bitbucket.org/szhorvat/crc/src
Our cluster uses the Sun Grid Engine. The names of the nodes (and information about them) are listed in a "hostfile" which you can find by retrieving the value of the PE_HOSTFILE
environment variable. (I think this works the same way with PBS, except the environment variable is called something else.)
Note that if you request multiple nodes in a single job file, the job script will be run on only one of the nodes, and you'll be launching the processes across all nodes manually (at least on SGE and PBS).
Launching processes on different nodes is usually possible with ssh
: just run ssh nodename command
to run command
. You may also need to set up passphraseless authentication if it is not set up by default. To launch subkernels, you'll need to pass the -f
option to ssh
to let it return immediately after it has launched the remote process.
Some setups use rsh
instead of ssh
. To launch a command in the background using rsh
, you'll need to do
rsh -n nodename "command >& /dev/null &"
To run the remote process in the background, it important to redirect the output (both stdout and stderr) because there's a bug in rsh (also described in its man page) that won't let it return immediately otherwise.
Another thing to keep in mind about rsh
is that you can't rsh
to the local machine, so you'll need to launch the subkernels which will run on the same machine as the main kernel without rsh
.
See my example for details.
Comments
Post a Comment