Matlab parpool gives me 4 workers on Azure VM instead of 8 workers

11 vues (au cours des 30 derniers jours)
Farouk
Farouk le 19 Jan 2025
Commenté : Farouk le 20 Jan 2025
I just deployed Matlab 2024b on Azure VM, with 8gb vCPU, 32gb RAM. However when i start the parpool with
% Start a parallel pool
parpool('local' );
parfor linearIdx = 1:totalCombinations
...
end
it runs with 4 workers whereas i would expect 8 workers since i have 8 vCPUS.
also parcluster('local') gives me
Local Cluster
Properties:
Profile: Processes
Modified: false
Host: matlabvm
NumWorkers: 4
NumThreads: 1
JobStorageLocation: /home/ubuntu/.matlab/local_cluster_jobs/R2024b
RequiresOnlineLicensing: false
PreferredPoolNumWorkers: Inf
Associated Jobs:
Number Pending: 0
Number Queued: 0
Number Running: 1
Number Finished: 0
Please note my Matlab 2024b licence is a Trial version. Could this be the case? Thanks

Réponse acceptée

Pratyush Swain
Pratyush Swain le 20 Jan 2025
Hi Farouk,
By default Parallel Computing Toolbox will attempt to use a number of workers equal to the number physical cores of the computer. In a cloud environment, a vCPU typically represents a portion of a physical CPU core.
To programmatically alter the maximum number of workers allowed by the 'Processes' or 'local' profile, use:
c = parcluster('Processes')
c.NumWorkers = 8;
saveProfile(c) % will overwrite the profile with the new NumWorkers value
Please also refer to http://www.mathworks.com/matlabcentral/answers/2042101-how-can-i-increase-the-number-of-matlab-workers-inside-parallel-computing-toolbox-to-use-all-the-log for information on why the number of cores detected might not be all of the cores on your machine.
Hope this helps.
  1 commentaire
Farouk
Farouk le 20 Jan 2025
Hi Pratyush,
Thanks yes you are right. i later figured it out and did it exactly this way and it worked. Cheers.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by