How do I get parfor to downgrade gracefully to for when no parallel seat is open?
5 次查看(过去 30 天)
显示 更早的评论
My biggest client has many MatLab seats but only a few parallel toolbox seats. Often, a user is able to run MatLab but not able to run in parallel. Is there a way to configure MatLab to automatically downgrade a parfor to a for loop when that happens? Currently it crashes with "Unable to checkout a license for the Parallel Computing Toolbox".
Please don't bother suggesting that I change all the code everywhere to check for the pool then run either a for or a parfor. Yeah. I know how to do that.
I'm looking for "a more elegant weapon for a more civilized age".
This is R2018b.
0 个评论
回答(1 个)
Edric Ellis
2020-1-7
parfor already has the innate ability to run without Parallel Computing Toolbox being present, and it should automatically handle the case where a PCT license is not available. Presuming the user settings are in the default state (i.e. a parallel pool is automatically created when encountering a parfor), then if the license checkout fails, parfor should already degrade gracefully. Here's what I tried:
>> parfor i = 1, end % this works
>> parpool('local', 2) % this fails because I don't have a license
Starting parallel pool (parpool) using the 'local' profile ...
License checkout failed.
License Manager Error -5
Cannot find a license for Distrib_Computing_Toolbox.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/R2018b/5
Diagnostic Information:
Feature: Distrib_Computing_Toolbox
License path: /home/eellis/.matlab/R2018b_licenses/license_uk-eellis-deb9-64_40447121_R2018b.lic:/local-ssd2/MATLAB/R2018b/licenses/license.dat:/local-ssd2/MATLAB/R2018b/licenses/*.lic
Licensing error: -5,0.
Error using parpool (line 113)
Unable to checkout a license for the Parallel Computing Toolbox.
So, I believe that if your code has only calls to parfor and not parpool, then it should work correctly. Please give more details if this isn't what you're seeing.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!