LIMO-EEG-Toolbox / limo_tools

Hierarchical Linear Modelling for MEEG data
https://limo-eeg-toolbox.github.io/limo_meeg/
Other
58 stars 28 forks source link

limo_check_ppool fail when running matlab singlethreaded while parallel toolbox is installed #195

Closed schoffelen closed 1 month ago

schoffelen commented 2 months ago

When I try to run https://github.com/SIESTA-eu/wp15/blob/main/usecase-2.4/2.4.A/ERP_Core_WB.m I get the following error:

std_limo: Invalid time upper limit, using default value insteadFailed to get study
Starting parallel pool (parpool) using the 'local' profile ...
Error using parallel.Cluster/parpool (line 86)
Invalid value specified for property 'NumWorkers'. Allowed values are either 1 or 2
numbers specifying a range for number of workers, [minWorkers, maxWorkers], where 0 <
minWorkers <= maxWorkers. Specifying only one number sets minWorkers = maxWorkers.

Error in limo_check_ppool (line 34)
            c.parpool(N-1);

Error in limo_batch (line 514)
    limo_check_ppool

Error in std_limo (line 570)
    [LIMO_files, procstatus] = limo_batch('model specification',model,[],STUDY);

Error in pop_limo (line 183)
[STUDY,limofiles] = std_limo(STUDY, ALLEEG, options{:});

Error in ERP_Core_WB (line 216)
    [STUDY, ~, files] = pop_limo(STUDY, EEG, 'method','WLS','measure','daterp',...

limo_batch ends up in the section where the default parallel processing is attempted, but running singlethreaded matlab session (by default enforced on the DCCN cluster) the variable 'N' (number of threads) is 1, causing the error. I assume there is a way to define in limo a parameter that avoids the parallel processing, but I would also assume that the limo-code would behave robustly in a singlethreaded application.

schoffelen commented 2 months ago

My suggestion would be to change in

limo_check_ppool, line 13:

if isempty(N)

into

if isempty(N) || N==1

CPernet commented 2 months ago

that par pool check works for me -- what about on your cluster?

schoffelen commented 2 months ago

Well, I get a little bit further in the pipeline, but now fail due to the fact that parfor apparently attempts to start a parcluster anyhow (if it has not been started before), and does so in my case in the 'Threaded' mode. This causes an error downstream, due to the fact that it's forbidden to run mex-files in a parallel loop in threaded mode...

CPernet commented 2 months ago

there is undocumented stuff that I saw on StackOverflow . In limo_check_ppool if 1 (line 37), we can force matlab NOT to start when it sees parpool

ps = parallel.Settings;
ps.Pool
ans = 
  PoolSettings with properties:
                            AutoCreate: 1
                RestartOnClusterChange: 1
    RestartOnPreferredNumWorkersChange: 1
                           IdleTimeout: 30
                   PreferredNumWorkers: 12

changing AutoCreate to false? what do you think