Force CPU Parallel pool

2 visualizzazioni (ultimi 30 giorni)
T S
T S il 16 Gen 2022
Modificato: Joss Knight il 17 Gen 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', ...
'Plots','training-progress');

Risposte (2)

Joss Knight
Joss Knight il 17 Gen 2022
Modificato: Joss Knight il 17 Gen 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 il 17 Gen 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:
setenv('CUDA_VISIBLE_DEVICES', '')
You can then check that this has worked by running
spmd
gpuDeviceCount
end
This should return 0 on each worker.

Categorie

Scopri di più su Parallel and Cloud in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by