Change parallel preferences from code or console in a live session
34 views (last 30 days)
Is there a way to change the AutoCreate and IdleTimeout preferences of the parallel computing toolbox in a live Matlab session from code/console (i.e. without using the GUI preferences panel or editing the parallel.settings file)?
Note that I am not talking about specific cluster preferences, which I know how to manipulate using Matlab code. I stumbled upon an answer by Yari which discusses undocumented features to change general Matlab preferences: http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/154608
Alas, the parallel computing toolbox settings are not stored in the matlab.prf file, which has a proprietary format, but in the parallel.settings file, which is in XML format. These are changed normally from the GUI preferences panel.
I'm interested in changing the following two settings:
The first is whether to auto-start a parallel cluster when 'parfor' is executed, the second is after how long to shutdown an idle cluster (Inf = never).
There is the function pctconfig but that cannot change the above two settings. There is also the parallel object with plenty of properties and methods, including parallel.settings and parallel.internal and parallel.internal.settings but again I couldn't find it in there.
Any masters of undocumented features have any clues?
Josh Wells on 28 Dec 2018
You can turn off the auto create via the following command:
ps = parallel.Settings;
ps.Pool.AutoCreate = false;
Elwin Chan on 14 Feb 2014
There is no documented way to change the parallel preferences programmatically. However, you may find Edric's advice on disabling the automatic creation of parpools useful.
When you create a pool manually, you can supply the IdleTimeout property:
% This will set the idle timeout to 2 hours
You can also change the IdleTimeout property of the pool whilst it is running:
p = parpool
p.IdleTimeout = 120