A follow-up question is, how does MATLAB continue to run simulations and keep their output in memory if memory usage is close to 100%?
Can I save the outputs of completed sims when running parsim instead of saving them all at the end?
조회 수: 7 (최근 30일)
이전 댓글 표시
I'm running 1000 simulations using parsim on 25 parallel workers. When I monitor my memory, I see that my memory usage goes up every time sims are completed, eventually reaching close to 100%. Fortunately, this has not caused my simulations to fail from a memory overload. However, I'd like to stay on the safer side, and save my sim outputs as soon as a batch is complete, and then clear that data from memory.
My code looks like this:
simOut = parsim(simInArray, ...
'SetupFcn', @()utilities.foo(mdl, bar}), ...
'CleanupFcn', @()close_system(mdl, 0), ...
'ShowSimulationManager', 'on');
Where simInArray is 1000 elements long. Is there anyway I can dump every 25 runs to disk, and clear them from memory? Could there be a name-value pair into parsim that does this?
댓글 수: 2
Walter Roberson
2024년 10월 2일
편집: Walter Roberson
2024년 10월 2일
Is there anyway I can dump every 25 runs to disk, and clear them from memory?
No, there is not.
Potentially you could save results using To File blocks.
채택된 답변
Paul
2024년 10월 3일
Hi Kadhir,
Based on the description in the question, I'm not quite sure what's happening. How exactly are you monitoring the memory and correlating to when each simulation is complete? Is that through the Simulation Manager (I'm not familiar with that tool)?
One option would be to not run all 1000 simInArray objects in one go. You could, for example, do four groups of 250 and stitch the results together afterwards. I don't think this approach is too palatable, but thought I'd mention it.
If the issue is that the logged data that gets returned to simOut is too large, you can instead force all logging to .mat files. See this discussion for an example.
More generally, check out Work with Big Data for Simulations and Running Multiple Simulations and other Related Topics therefrom to see if anything resonates to address your concern.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!