MATLAB parfor crashes while evaluating casadi.Function

576 views
Skip to first unread message

Armin Nurkanovic

unread,
Aug 1, 2017, 8:23:44 AM8/1/17
to CasADi
Hello everyone,

I have already read a similarly post on this forum but it has not helped me.

I need to do a lot of simulations and sensitivity propagation of the same ODE with different initial values/parameters.
doing it in a sequential way works fine, but doing in parallel, the codes crashes ( I have already considered all issues regarding MATLABs Parallel Computing Toolbox). I'm running it on my PC ,using 4 cores of my CPU. After  removing any parts containing CasADi  calls, the code works without errors. 


a simplified version of the code: 
%% done before

  opts = struct('tf',T,'abstol',abstol,'reltol',reltol);
        I = integrator('I', 'cvodes', dae, opts);
....

for k=1:N
        x0= X0(k,:);  % vector with all the initial values
        u0 = U0(k,:);
       res = I('x0',x0,'p',u0);
      a(k) = [full(res.xf)]
      % even putting the part of evaluating the integral into a matlab function does not help. for example crating a function...      res =  integrate_casadi(I,x0,u0);
end

replacing for with parfor does not work , even thought are iterates are independent,

MATLAB gives following error code:

Warning: While saving an object of class 'casadi.Function':
Serializing SWIG objects not supported.

> In parallel.internal.pool.serialize (line 21)
  In distcomp.remoteparfor/addInterval (line 103)
  In parallel_function>distributed_execution (line 780)
  In parallel_function (line 587)

...
Warning: A worker aborted during execution of the parfor loop. The parfor loop will now run again on the remaining workers.
> In parallel_function (line 596)
...
Error using parallel_function (line 604)
All workers aborted during execution of the parfor loop.
 


Any help is appreciated. Thank you.

Best,
Armin



Joris Gillis

unread,
Aug 1, 2017, 8:32:52 AM8/1/17
to CasADi
Dear Armin,

parfor syntax is not currently supported, unfortunately.
With 'crashing', do you mean printing an error message, or Matlab shutting down?

Best regards,
  Joris

Armin Nurkanovic

unread,
Aug 1, 2017, 8:39:04 AM8/1/17
to CasADi
Dear Joris,

just those messages I have posted appear in the Command Windows and the parallel pool shuts down, but MATLAB still works.  Is there any known workaround to use CasADi functions in a parallel manner in MATLAB?

Best
Armin
Reply all
Reply to author
Forward
0 new messages