Why can't I run Simulink from the command line inside a parfor loop?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Rick Rosson
2011년 8월 26일
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?
답변 (2개)
Lucas García
2011년 8월 26일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!