How can I check if "matlabpool" is running when using Parallel Computing Toolbox?
显示 更早的评论
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?
采纳的回答
更多回答(1 个)
Seongsu Jeong
2018-2-6
>> 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
>>
类别
在 帮助中心 和 File Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!