我试图让 Matlab 将许多脚本作为单独的批处理作业执行。每个脚本从 excel 表格中加载一些数据并实现一个神经网络。神经网络在内部使用 parfor 循环进行参数调整。
当我在本地机器上运行批处理作业时,它工作正常。我的 Matlab 代码看起来像
job1 = batch('Historical1Step',...
'Profile', 'local',...
'Matlabpool', 3,...
'CaptureDiary',true,...
'CurrentDirectory', '.');
try
job1Results = fetchOutputs(job1);
catch err
delete(job1);
rethrow(err);
end
delete(job1);
我得到的日记输出是
--- Start Diary ---
Analysing data for stock BAX
num_its =
2
100%[============================
100%[===================================================]
--- End Diary ---
但是,当我从“本地”配置更改为我的服务器配置时,我得到
--- Start Diary ---
--- End Diary ---
Error using parallel.Job/fetchOutputs (line 869)
An error occurred during execution of Task with ID 1.
Error in SOExample (line 14)
job1Results = fetchOutputs(job1);
Caused by:
Index exceeds matrix dimensions.
我假设问题与我的函数/数据对工作人员的可见性有关,但我已经尝试了批处理函数中我能想到的“FileDependencies”和“PathDependencies”选项的所有组合,但无济于事。
任何帮助将不胜感激,如果我在没有意识到的情况下做了一些非常愚蠢的事情,请提前道歉!
编辑-
错误堆栈如下:
Index exceeds matrix dimensions.
Error in Historical1Step (line 13)
Error in parallel.internal.cluster/executeScript (line 22)
eval(['iClearAndSetCallerWorkspace(workspaceIn);' scriptName]);
Error in parallel.internal.evaluator/evaluateWithNoErrors (line 14)
[out{1:nOut}] = feval(fcn, args{:});
Error in parallel.internal.evaluator/CJSStreamingEvaluator/evaluate (line 31)
[out, errOut] = parallel.internal.evaluator.evaluateWithNoErrors( fcn, nOut, args );
Error in dctEvaluateTask>iEvaluateTask/nEvaluateTask (line 281)
[output, errOutput, cellTextOutput{end+1}] = evaluator.evaluate(fcn, nOut, args);
Error in dctEvaluateTask>iEvaluateTask (line 141)
nEvaluateTask();
Error in dctEvaluateTask (line 57)
[resultsFcn, taskPostFcn, taskEvaluatedOK] = iEvaluateTask(job, task, runprop);
Error in distcomp_evaluate_filetask_core>iDoTask (line 149)
dctEvaluateTask(postFcns, finishFcn);
Error in distcomp_evaluate_filetask_core (line 48)
iDoTask(handlers, postFcns);
Error using parallel.Job/fetchOutputs (line 869)
An error occurred during execution of Task with ID 1.
Error in SOExample (line 14)
job1Results = fetchOutputs(job1);
Caused by:
Index exceeds matrix dimensions.
文件“Historical1Step”是我要运行的脚本。第一行(直到代码失败)是:
wrkDir = 'V:\Individual\SOFNN'; % this is where the files are on cluster headnode
wrkFldr = [wrkDir '\ExcelSheets\1-stepAhead\']; % location of excel sheets
%%
folder = dir(wrkFldr);
isub = [folder(:).isdir]; % data is stored in sub-directory based on stock symbol
stockNames = {folder(isub).name}'; % extract stock names from names of sub-dirs
stockNames(ismember(stockNames,{'.','..'})) = []; % remove names '.' and '..'
for i = 1:1 % this loop should read in data for stock i from correct sub-dir
close all;
clc;
sym = stockNames{i};
disp(['Analysing data for stock ' sym]);
fldrName = strcat(wrkFldr,'\', sym, '\');
end % added for completion