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?
Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why is Matlab giving an UndefinedFunction error in this parfor loop?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!