Disable logging to disk from Simulink, during Reinforcement Learning training
Show older comments
I'm using the train function to run a Reinforcement Learning training using a PPO agent, with a rlSimulinkEnv object defining the environment.
Regarding the rlTrainingOptions, I'm using the default option for "SimulationStorageType", which is "memory". So I expect (if I understand correctly) that all the simulation data should be saved to RAM, not to disk, whenever possible. However I noticed that Simulink is actually saving the simulation data into .dmr files stored in my TEMPDIR.
I also tried to disable the Simulink logging to TEMPDIR directly from the Simulink Data Inspector, setting the Record Mode to "View during simulation only". However, as soon as I start the Reinforcement Learning Training, the simulation data are still saved as .dmr files in my TEMPDIR.
Is there a way to actually avoid saving .dmr files to TEMPDIR when training in a Simulink environment, and instead using only RAM to store the simulation data as long as the Matlab session is active?
I'm using version R2024a
Answers (2)
Ruchika Parag
on 19 Jul 2024
Hi Federico, it seems like Simulink is saving simulation data to .dmr files in your temporary directory, despite using the 'rlTrainingOptions' with 'SimulationStorageType' set to "memory". Here are steps to ensure data is stored in RAM:
1. Simulink Data Inspector Settings
Ensure logging is set to "View during simulation only" and "Save data in MAT files" is unchecked:
- Open Simulink Data Inspector.
- Go to Preferences (gear icon).
- Set "Record mode" to "View during simulation only".
- Uncheck "Save data in MAT files".
2. Make sure your training options specify to use memory:
trainingOptions = rlTrainingOptions(...
'MaxEpisodes', 1000, ...
'MaxStepsPerEpisode', 500, ...
'StopTrainingCriteria', 'AverageReward', ...
'StopTrainingValue', 500, ...
'ScoreAveragingWindowLength', 100, ...
'SaveAgentCriteria', 'EpisodeReward', ...
'SaveAgentValue', 500, ...
'SimulationStorageType', 'memory');
3. Model Configuration
Disable unnecessary logging in your Simulink model:
- Open Configuration Parameters (Ctrl+E).
- Under "Data Import/Export", disable unnecessary logging options.
4. Model Callbacks
Check for callbacks that may log data to disk:
- Open Model Properties.
- Check the "Callbacks" tab.
5. Programmatically Disable Logging
Use 'set_param' to disable logging:
set_param(gcs, 'DataLogging', 'off');
set_param(gcs, 'SignalLogging', 'off');
set_param(gcs, 'DSMLogging', 'off');
set_param(gcs, 'SaveFormat', 'Array');
By following these steps, you should be able to keep the simulation data in RAM.
Federico Toso
on 24 Jul 2024
0 votes
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!