R2017a parfor error when starting parpool inside function body

1 次查看(过去 30 天)
Hello,
I'm testing the work of the distributed cluster MATLAB R2017a (in practice I use R2015b). MDCE components runs on Linux machines (Ubintu and Mint), client is Linux machine too. I have some problems in the new version, which did not arise in the previous one:
If I run the cluster (named MJSP17 in example) inside the body of a simple function " main.m" that uses a table (with three columns) as input arguments, I get an error in accessing variables:
Warning: While loading an object of class 'table':
Invalid default value for property 'propertyNames' in class 'table':
Error: File: metaDim.m Line: 246 Column: 20
Arguments to IMPORT must either end with ".*" or else specify a fully qualified class name: "matlab.internal.tabular.private.tabularDimension.checkReservedNames_impl" fails this test.
> In parallel.internal.pool.deserialize (line 9)
In parallel.internal.pool.deserializeFunction (line 12)
In remoteParallelFunction (line 33)
Error using main (line 28)
Struct contents reference from a non-struct array object.
1. Script that calls main.m:
% Generate filelist
gcpfilelist = {[cd filesep 'main.m']};
% Make an example of "data" table: | ID | PeriodID | Value |
numid = 1000; % Number of unique ID
maxlength = 74; % Maximum number of Period for every ID
varlength = randi(maxlength, numid, 1) + 1;
data = table(repelem((1:numid), varlength)', ...
cell2mat(arrayfun(@(x) (1:x)', varlength, 'UniformOutput', false)),...
randi(10^6, sum(varlength), 1), 'VariableName', {'FcID' 'PeriodID' 'Value'});
% Call main finction
main( data, gcpfilelist );
2. main.m example:
function [ batchoutput ] = main( data, gcpfilelist )
unqid = unique(data{:,'FcID'});
n = numel(unqid);
batchoutput = cell(n, 1);
%%Make main processing (using functions from project folders)
parpool('MJSP17', 'SpmdEnabled', false);
% addAttachedFiles(gcp, gcpfilelist);
% fprintf(1, '============== ATTACHED GCP FILES =================\n');
% curgcp = gcp; curgcp.AttachedFiles
% fprintf(1, '===================================================\n');
parfor j = 1:n %numel(metascenariofc.FcID)
curid = unqid(j);
curFcIDdata = data(data.FcID == curid, :);
batchoutput{j} = curFcIDdata;
end
delete(gcp('nocreate'));
% Completeness check
any(cellfun(@(x) isempty(x), batchoutput))
end
The problem is solved by the transfer list of project's working files ( gcpfilelist) to the gcp.
3. Uncomment in main.m:
addAttachedFiles(gcp, gcpfilelist);
fprintf(1, '============== ATTACHED GCP FILES =================\n');
curgcp = gcp; curgcp.AttachedFiles
fprintf(1, '===================================================\n');
But, this is extremely inconvenient, and besides, this error did not arise in R2015b.
Tell me, please, how to avoid the occurrence of this error without sending the structure of project files to all nodes of the cluster?
Thank you!
  3 个评论
Edric Ellis
Edric Ellis 2017-5-30
The error you're getting appears to be coming from MATLAB's built-in type table - which seems strange to me. Could you check that you're using precisely the same version of MATLAB for both client and workers?
Jonas
Jonas 2017-5-31
编辑:Jonas 2017-5-31
I call:
pctRunOnAll ver MATLAB
Results on all workers are the same:
MATLAB Version: 9.2.0.... (R2017a)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by