How can I check if "matlabpool" is running when using Parallel Computing Toolbox?
Afficher commentaires plus anciens
I am writing MATLAB scripts using the Parallel Computing Toolbox Release R2015b. Many of my scripts contain a call to "matlabpool" to start a parallel computing pool. However, sometimes the pool is already initiated and I will get an error due to a duplicate call.
How can I check if a parallel pool is already running, so I can avoid trying to start it twice?
Réponse acceptée
Plus de réponses (1)
Seongsu Jeong
le 6 Fév 2018
>> isempty(gcp('nocreate'))
ans =
logical
1
>> parpool(2)
Starting parallel pool (parpool) using the 'local' profile ... connected to 2 workers.
ans =
Pool with properties:
Connected: true
NumWorkers: 2
Cluster: local
AttachedFiles: {}
IdleTimeout: 30 minutes (30 minutes remaining)
SpmdEnabled: true
>> isempty(gcp('nocreate'))
ans =
logical
0
>> delete(gcp('nocreate'))
Parallel pool using the 'local' profile is shutting down.
>> isempty(gcp('nocreate'))
ans =
logical
1
>>
Catégories
En savoir plus sur Parallel Computing Fundamentals dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!