How can I check if "matlabpool" is running when using Parallel Computing Toolbox?
Show older comments
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?
Accepted Answer
More Answers (1)
Seongsu Jeong
on 6 Feb 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
>>
Categories
Find more on Parallel Computing Fundamentals 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!