Change parallel preferences from code or console in a live session

18 Ansichten (letzte 30 Tage)
Alex R.
Alex R. am 14 Feb. 2014
Beantwortet: Josh Wells am 28 Dez. 2018
Hi,
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:
AutoCreate
IdleTimeout
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?
Regards, Alex.

Antworten (2)

Josh Wells
Josh Wells am 28 Dez. 2018
You can turn off the auto create via the following command:
ps = parallel.Settings;
ps.Pool.AutoCreate = false;

Elwin Chan
Elwin Chan am 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
parpool('IdleTimeout', 120)
You can also change the IdleTimeout property of the pool whilst it is running:
p = parpool
p.IdleTimeout = 120
  2 Kommentare
Alex R.
Alex R. am 14 Feb. 2014
Thanks for that. Somehow I had missed looking into parpool.
The AutoCreate was something I cared about more. Edric's tips are useful, but don't help me in my situation. Basically, I have Matlab running on several remote machines and execute some code on all of them. Sometimes I want parfor not to trigger the creation of any pool (not just to run sequentially) -- for memory related reasons -- but I don't want to change the code. Basically, I would need to set AutoCreate=false programatically ... shame there is no API for it.
Yu Xiang
Yu Xiang am 25 Apr. 2016
Hi Alex,
Did you find the answer, i am also searching the method to turn off the AutoCreate with some codes in the matlab rather with the parallel preferences.
Kind Regards, Yu Xiang

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by