Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Why is Matlab giving an UndefinedFunction error in this parfor loop?

조회 수: 5 (최근 30일)
Richard Buckalew
Richard Buckalew 2018년 10월 2일
댓글: Walter Roberson 2018년 10월 3일
UPDATE: I decided to take the opportunity to update to R2018b, and the problem is gone. Who knows what caused it, but this problem is no longer a problem. Thanks if you were already thinking about it!
#########
I am having some trouble assigning values to a cell array inside a parfor loop. Here is what I think are the relevant parts of the script:
isoBins = cell(1,nBins);
parfor nBin = 1:nBins
for ii = 1:iters
%build a cell called isoClasses%
end
isoBins{nBin} = isoClasses;
end
Within the parfor, isoBins is only referenced once, at the end of each loop, exactly as shown above. It is initialized immediately before the parfor, also exactly as shown above. The code runs fine, with the expected results, when I replace 'parfor' with 'for'. But the parallel code throws:
Error using enumerateAllGraphs (line 87)
An UndefinedFunction error was thrown on the workers for 'isoBins'. This might be because the
file containing 'isoBins' is not accessible on the workers. Use addAttachedFiles(pool, files)
to specify the required files to be attached. See the documentation for
'parallel.Pool/addAttachedFiles' for more details.
Caused by:
Undefined function or variable 'isoBins'.
I have searched both here and on the broader web, and haven't found anything that helps; I tried building a minimal example and it doesn't throw the error. I'm at a complete loss, so anything will help. Thanks!
Just in case the full code is helpful, here it is:
% Parallelize isomorphism calculations
allSequenceBins = sequenceBins.values;
isoBins = cell(1,nBins);
% each isoBin cell contains isomorphism classes of one particular deg seq
parfor nBin = 1:nBins % TODO: parfor
fePairs = allSequenceBins{nBin};
nPairs = numel(fePairs);
isoClasses = {};
for fePair = 1:nPairs
% build G
fe = fePairs{fePair};
F = zeros(n);
E = zeros(n);
F(sub2ind([n,n],fe(1,:),1:n)) = 1;
E(sub2ind([n,n],fe(2,:),1:n)) = 1;
FE = F - E;
G = digraph(FE);
% check G against reps of each extant class
nClasses = numel(isoClasses);
placed = 0; % when placed, set to 1 and break
for nClass = 1:nClasses
isoClass = isoClasses{nClass};
repG = isoClass{1};
if isisomorphic(repG,G,'EdgeVariables','Weight')
nInClass = numel(isoClass);
isoClass{nInClass+1} = G;
placed = 1;
isoClasses{nClass} = isoClass;
break;
end
end
if placed
continue
else
isoClasses{nClasses+1} = {G};
end
end
isoBins{nBin} = isoClasses;
end
  댓글 수: 2
Richard Buckalew
Richard Buckalew 2018년 10월 2일
Update: I decided to poke around in my parallel settings a bit, and found some tests to run on my local cluster profile. The 'Job test' test seems to hang -- it's said "Running" for several minutes now. Maybe this is related?
Walter Roberson
Walter Roberson 2018년 10월 3일
(Richard updated MATLAB versions, which fixed the problem.)

답변 (0개)

이 질문은 마감되었습니다.

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by