Filter löschen
Filter löschen

what does "parpool close force local" mean?

2 Ansichten (letzte 30 Tage)
zhu wenguo
zhu wenguo am 12 Jul. 2020
Kommentiert: zhu wenguo am 12 Jul. 2020
I am using a code based on old version matlab, and I got a error when it comes to:
if numProc <= 1
parpool close force local
else
% poolSize = parpool('size'); % check to see if a pool is already open
p = gcp('nocreate'); % If no pool, do not create new one.
if isempty(p)
poolSize = 0;
else
poolSize = p.NumWorkers
end
if poolSize == 0 || poolSize < numProc || poolSize ~= numProc
parpool close force local
eval(['parpool open ' num2str(numProc)])
end
end
and got the following error:
Error using parpool (line 145)
Properties and values must be specified in pairs.
it seems that the command has been deprecated, what does it mean? and what is its alternatives?
thank you in advance!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Jul. 2020
Something like,
if numProc <= 1
p = gcp('nocreate');
if ~isempty(p)
delete(p);
end
poolSize = 0;
else
p = gcp('nocreate');
if isempty(p)
poolSize = 0;
else
poolSize = p.NumWorkers;
if poolSize ~= numProc
delete(p);
poolSize = 0;
end
end
if poolSize == 0
try
p = parpool(numProc);
poolSize = p.NumWorkers;
catch
poolSize = 0;
end
end
end

Weitere Antworten (0)

Kategorien

Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by