Running trainNetwork() starts parallel pool in Matlab 2023b even when options.Ex​ecutionEnv​ironment = 'cpu'

8 Ansichten (letzte 30 Tage)
It seems the behaviour of trainNetwork has changed. I have a for loop that performs a grid search of models' hyper-parameters. After updating to version 2023b, parallel pool is being started whenever trainNetwork is invoked. Is this a bug or trainNetwork behaviour changed?
  6 Kommentare
Artem Lensky
Artem Lensky am 22 Sep. 2023
In function
function executionSettings = setupExecutionEnvironment(options)
there is this if statement
% Validate PCT if needed. It is not needed only when the execution
% environment is set as CPU and dispatch in background is false
if isPoolNeeded || options.ExecutionEnvironment == "gpu"
nnet.internal.cnn.util.validatePCTIsInstalled(options.ExecutionEnvironment);
end
for some reason even when options.ExecutionEnvironment set to "cpu", isPoolNeeded is set to true, which leads to executing the pool even when there is no need for it.
Artem Lensky
Artem Lensky am 22 Sep. 2023
I think I identified the problem, option DispatchInBackground was set to True expcplicitly. Surprisingly, it didn't execute the pool in previous Matlab version.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Artem Lensky
Artem Lensky am 22 Sep. 2023
Bearbeitet: Artem Lensky am 22 Sep. 2023
Whenever option DispatchInBackground set true, trainNetwork executes parallel pool.
If I am not mistaken this behaviour was different in 2023a, I already deleted it so can't verify, but it would be nice if someone at Mathworks would check wherther
function executionSettings = setupExecutionEnvironment( opts, X, precision, networkInfo )
contains these lines
% In DLT if the training datastore is set up for background prefetch,
% enable background prefetch
backgroundPrefetch = iUseBackgroundPrefetch(X) || opts.DispatchInBackground;
  4 Kommentare
Joss Knight
Joss Knight am 25 Sep. 2023
Experiment Manager can do an parameter sweep in whatever way you like, and the parameters can be anything you like, so rng seeds for instance.
Implementing a specific grid search algorithm (sweeping one parameter at a time) may require more manual intervention I'll admit. But you might still find it saves you time.
Artem Lensky
Artem Lensky am 26 Sep. 2023
Thanks for the reply. I might give it another go. I am surprised the grid search hasn't been implemented as an out of the box feature given that it is one of the basic parameter search approaches. Perhaps in 2024 version :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Parallel and Cloud 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