Using matlab full parallelisation with pattern search + parfor
Show older comments
Hello everybody,
I am running Matlab R2011b and I am optimising a function which is not everywhere differentiable, using patternsearch.
The problem is that my function evaluation is very costly, because each step requires the nonlinear estimation of around 200 set of parameters with lsqnonlin (100 parameters of the [x,y] dimension and other 100 with [x,y,z,w] dimension).
Using a parfor loop with a poolsize of 8 cores, each step takes around 1-3 min. However, with an average of 1000 function evaluations, the total run time will be around 17 - 50 hours.
Would there be any better way to improve this run?
matlabpool open 8
patternsearch(x)
until convergence
parfor
end
end
Kind regards.
Answers (5)
Alan Weiss
on 22 Feb 2013
0 votes
I am sorry, I do not understand your question. Are you asking whether it is better to run patternsearch in parallel, with the 'UseParallel' option set to 'always', or if it is better to run the nonlinear estimation in parallel using a parfor loop of your own devising? Or are you asking something else?
Please be a bit more specific, and then perhaps we can advise you.
Alan Weiss
MATLAB mathematical toolbox documentation
Marcelo Silva
on 23 Feb 2013
Edited: Marcelo Silva
on 24 Feb 2013
0 votes
Alan Weiss
on 25 Feb 2013
0 votes
You have touched on a thorny subject. I don't think there is ever a definitive answer. One general recommendation is to parallelize the innermost loop of any optimization, as it has the potential of providing the highest utilization of all the processors, but in any particular problem this might not be the fastest thing to do.
You can probably figure out for yourself what is best in your particular problem. You must have parallel hardware of at least 10, maybe even 50 processors, in order to get a speedup of a factor of 10 to 30 in serial computation of parameter estimation.
Now, how many dimensions is your problem, I mean how many entries in the x0 input? Call this number N. patternsearch will distribute evaluations to either N+1 or 2N processors, depending on which poll algorithm you use. If this number N+1 or 2N matches the number of processors you have, then it might be worthwhile using patternsearch in parallel, and parameter estimation in serial. If the number of processors is greater than N+1 or 2N, then you will certainly be better off using parallel parameter estimation, because many processors would be idle during patternsearch parallel poll. If the number of processors is less than N+1 or 2N, then it might not matter very much which strategy you employ, but I would do parallel parameter estimation anyway, because it is more likely to fully utilize the parallel processing, keeping all processors busy.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Marcelo Silva
on 26 Feb 2013
0 votes
1 Comment
Jason Ross
on 26 Feb 2013
Edited: Jason Ross
on 26 Feb 2013
For 2011b, you can run 12 local workers. The default is the number of compute cores your machine has, but you can override this by editing the properties of the local cluster (Parallel, Manage Cluster Profiles, edit the "local" profile, change NumWorkers). Keep in mind that this may actually decrease performance (or have no effect on it) if your CPUs are already fully utilized.
To go beyond 12 cores, you need to use MDCS in one way or another -- either the standalone Job Manager or by integrating with an existing scheduler.
Number of Local Workers Increased to Twelve You can now run up to 12 local workers on your MATLAB client machine. If you do not specify the number of local workers in a command or configuration, the default number of local workers is determined by the value of the local scheduler's ClusterSize property, which by default equals the number of computational cores on the client machine.
Marcelo Silva
on 4 Mar 2013
3 Comments
Jason Ross
on 4 Mar 2013
If you are using local and MDCS, I could see things getting confused with the data location setting. I'm assuming that the /user/leuven directory is visible to all the cluster nodes -- make a directory like /user/leuven/torqueshared and then set the DataLocation there.
Marcelo Silva
on 6 Mar 2013
Edited: Marcelo Silva
on 6 Mar 2013
Jason Ross
on 6 Mar 2013
For the worker to be able to work, it's going to need access to the files. If you are using a common file system between all workers, it needs to be accessible to every one. If the file system can't be found, something is going to error when it can't find needed data or code.
If you are using the term "private" in terms of the MATLAB definition of a "private" function, that's fine -- so long as the function is available to all of the workers. If you are meaning "private" as in "read access will be denied", that's going to be problematic if the workers can't read the data that they need to.
Another question -- is it possible that the file system is overloaded and can't serve the data quickly enough? Does this work with a smaller number of workers? If you set up a cluster profile, does it validate successfully? (from what you list above you should have all of the information needed to make a cluster profile and attempt to validate it in the Parallel > Manage Cluster Profile menu)
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!