Dear Jessica,
I got at times a similar error and I'm still unclear about when it
happens and why. With local workers, code shouldn't have to be copied
around but it seems it is:
>> Analyzing and transferring files to the workers...done.
and, unsurprisingly, MATLAB fails at finding all the dependencies in the
SPM code and the transferred local copies of SPM are unusable.
In my case, it was not working when the equivalent of your
LBCN_montage.m file was a function, but it was working fine when it was
a script. Do you see the same thing?
If someone else has been delving into this, I'd be curious to hear about
their findings.
Best regards,
Guillaume.
On 21/04/17 17:15, jschrouf wrote:
> Dear All,
>
> I am getting a similar error as reported below when trying to run SPM in
> a parfor loop (which contains a succession of matlab batches, home built
> functions and calls to spm routines):
>
> Error using cfg_repeat/list (line 112)
> An UndefinedFunction error was thrown on the workers for 'list'. This
> might be
> because the file containing 'list' 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.
>
> Error in cfg_util>local_getcjid2subs (line 1352)
> cjid2subsin = list(cjin, exspec, tropts);
>
> Error in cfg_util>local_initjob (line 1537)
> [ucj, ucjid2subs] = cellfun(@local_getcjid2subs, ucj, 'UniformOutput',
> false);
>
> Error in cfg_util (line 802)
> [jobs(cjob), mod_job_idlist] = local_initjob(jobs(cjob),
> job,
> jobdedup);
>
> Error in spm_jobman (line 246)
> cjob = cfg_util('initjob', mljob);
>
> Error in LBCN_montage (line 97)
> [out] = spm_jobman('run', jobfile,input_array{:});
>
> Caused by:
> Undefined function 'list' for input arguments of type 'cell'.
>
> There are a lot of warnings issued as well, including 'Multiple versions
> of FieldTrip' (I only have the SPM release), 'Can't obtain SPM revision
> information' or Warning: Name is nonexistent or not a directory:
> C:\Users\PARVIZ~1\AppData\Local\Temp\tp8072edf9_f75f_4d55_bb66_0c72af7d62b8rp8020\a\tp7f37736c_aeeb_4493_bb36_dc729ef44248\toolbox\MEEGtools
>> In path (line 109)
> In addpath (line 88)
> In spm (line 434)
> In LBCN_montage (line 92)
> In parallel_function>make_general_channel/channel_general (line 929)
> In remoteParallelFunction (line 38)
> Item matlabbatch: No repeat named
> spm
>
> Can you please advise?
>
> Thank you!
>
> Best regards,
>
> Jessica
>
>
> On 6/16/2016 10:30 AM, Katie Surrence wrote:
>> Dear SPM experts,
>>
>> I am attempting to run SPM, specifically first level estimation, on
>> Matlab Parallel Pool, with little success.
>>
>> The first errors I get are 'undefined function' errors. They all
>> reference functions defined in one of the @cfg_ directories under the
>> matlabbatch directory. I use the addAttachedFiles method of the
>> parallel pool to make these files available to the remote workers,
>> although in some cases there is more than one version of these files
>> available, and I have to guess at the correct one, which who knows,
>> may be part of my problem. Eventually I stop getting 'undefined
>> function' errors and start getting an error that indicates a variable
>> is not of the type Matlab/SPM expects it to be. This is very
>> challenging to look into without access to the debugger (since these
>> errors only occur on the remote workers, where I can't debug -- the
>> scripts run fine locally).
>>
>> Here is the stack trace for the error I'm getting.
>>
>> ks_main_3
>> Item matlabbatch: No repeat named
>> spm
>> Error using list (line 103)
>> Struct contents reference from a non-struct array object.
>>
>> Error in cfg_repeat/list (line 112)
>>
>> Error in cfg_util>local_getcjid2subs (line 1352)
>>
>> Error in cfg_util>local_initjob (line 1537)
>>
>> Error in cfg_util (line 802)
>>
>> Error in spm_jobman (line 245)
>>
>> Error in ks_conds_estimate_func (line 37)
>> parfor nsub = 1:length(subjects)
>>
>> Error in ks_main_3 (line 151)
>> ks_conds_estimate_func(Data, Time)
>>
>> Here are lines 99 to 103 of the version of list.m I attached to the
>> parallel pool:
>>
>> if (isempty(tropts.stopspec) || ~match(item, tropts.stopspec)) &&
>> (tropts.cnt < tropts.mcnt) && (tropts.clvl < tropts.mlvl)
>>
>> tname = treepart(item, tropts.dflag);
>>
>> % subscripts to child nodes
>>
>> idsubs = substruct('.', tname, '{}', {});
>>
>> citems = subsref(item, idsubs(1));
>>
>> It's that last line that causes the error. Even though I can't use
>> the debugger, I tried adding some disp statements to list.m to see
>> what the values of item and idsubs were just before the error. I get
>> an empty line for item. For idsubs, Matlab reports that it's a 1x2
>> _struct_ array with fields
>>
>> type
>>
>> subs
>>
>> I also had it display idsubs(1) and matlab gives
>>
>> type: '.'
>>
>> subs: 'val'
>>
>> So, according to Matlab, idsubs *is* a struct, so it shouldn't be
>> causing the error. I thought for a second that maybe somehow item,
>> being empty, was at fault, and subsref.m expected a struct, but if
>> that were so I would assume the trace would include a call to subsref.
>>
>> I would love to be able to run on the cluster and complete first
>> levels faster, but this is extremely daunting. I would appreciate any
>> insight into this problem that you may have, or suggestions for other
>> approaches (like a complete remote SPM installation? I'm not sure how
>> that would work).
>>
>> I'm attaching the main script I run, the function it calls that
>> populates matlabbatch for the estimation, and the versions of list.m,
>> match.m, and treeparts.m I attach to the parallel pool, in case they
>> are helpful for understanding the problem.
>>
>> Thanks very much in advance.
>>
>> Best,
>>
>> Katie
>>
>>
>>
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|