Why can't I run Simulink from the command line inside a parfor loop?
3 views (last 30 days)
Show older comments
I have some code that creates and runs multiple Simulink models in normal mode from the command line like this:
matlabpool open 4;
parfor i = 1:100
sys = sprintf('system_%d', i);
new_system(sys);
%define the system
results(i, 1:1000) = sim(sys, [0 1000]);
close_system('foo', 0);
end
It seems straightforward and it does in fact run fine for a while using all four cores. However, within a minute or so, I invariably get the message:
The client lost connection to lab 2.
This might be due to network problems, or the interactive matlabpool job might have errored. This is causing: java.io.IOException: An existing connection was forcibly closed by the remote host
and it continues running as if it was a regular for loop instead of a parfor loop, using only one core. What's wrong? I know there are unique issues related to calling sim from within parfor, but as far as I know they all have to do with running the same model in parallel, not creating and running different models in parallel as in in my code. Thanks for any help~
1 Comment
Rick Rosson
on 26 Aug 2011
Which release of MATLAB are you using?
Have you tried this code from a MATLAB script, or only directly from the command line?
Have you tried creating a MATLAB function that calls the 'sim' command, and then calling that function from within the 'parfor' loop?
Answers (2)
Lucas García
on 26 Aug 2011
Are you running MATLAB in a 32-bit or 64-bit machine? I say this because if you are running MATLAB in 32-bit and you are passing a lot of data to your workers at each iteration, memory transfer is limited to ~600MB. In 64-bit it's around ~2GB:
Maybe try a simpler problem to see if it works.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!