Merged
Conversation
This commit introduces objgraph calls at various points in the training
process to help diagnose potential memory leaks or unexpected object
accumulation.
Changes:
- Added `import objgraph` to `train_optimized.py` and `src/agent.py`,
with a fallback if the library is not installed.
- In `train_optimized.py`:
- Added an `objgraph` log at the beginning of `main()`.
- Added a periodic `objgraph` log every 20 episodes in the main
training loop.
- In `DQNAgent.update_model()` (in `src/agent.py`):
- Added a periodic `objgraph` log triggered every 2000 environment steps.
These logs will show the most common object types, providing insights
into memory usage patterns during training.
This commit removes the objgraph logging added previously, as it did not reveal a runaway Python object count leak directly explaining the scale of the memory issue. It introduces explicit calls to `gc.collect()` at the end of each episode in `train_optimized.py`. This is a diagnostic step to test if more aggressive garbage collection can help mitigate the observed high memory usage, which is suspected to be related to high churn of memory from frequent allocations/deallocations during intense training periods.
Changed the explicit garbage collection call in `train_optimized.py` to trigger every 5 episodes instead of every single episode. This is to test if a less frequent forced GC can still prevent memory explosion while reducing potential GC overhead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.