Force CPU Parallel pool

6 views (last 30 days)
T S on 16 Jan 2022
Edited: Joss Knight on 17 Jan 2022
My GPU is a GTX 970 with only 4 Gb of availble memory. I would like to force training of my UNET segmentation network on the CPU 16 core ryzen 5950x with availble system memory instead.
How can I force a multicore/multithreaded parallell pool on the CPU. By default matlab selects GPU and experiences memory errors.
Is there a way to "hide" the GPU from matlab?
options = trainingOptions('adam', ...
'InitialLearnRate',2e-4, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.85, ...
'LearnRateDropPeriod', 3, ...
'MaxEpochs',60, ...
'MiniBatchSize',20, ...
'Shuffle', 'every-epoch', ...
'VerboseFrequency', 5, ...
'ValidationData', Validationds, ...
'ValidationFrequency', 30, ...
'ExecutionEnvironment', 'parallel', ...

Answers (2)

Joss Knight
Joss Knight on 17 Jan 2022
Edited: Joss Knight on 17 Jan 2022
You should use 'ExecutionEnvironment','cpu' for training on your local machine. This is multithreaded and will use all your cores. Parallel training on CPU is only useful for multinode clusters.
In practice you will likely find that your 16 core CPU is still slower than training on your GTX 970 with the MiniBatchSize reduced so that you can fit into its memory - worth checking though.

Edric Ellis
Edric Ellis on 17 Jan 2022
There's no direct way to specify this using trainingOptions, but what you can do is disable the GPUs on the workers by running this command in your desktop MATLAB before creating the parallel pool:
You can then check that this has worked by running
This should return 0 on each worker.


Find more on Deep Learning in Parallel and in the Cloud 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!

Translated by