Skip to content

Commit

Permalink
Ensure that GC remains disabled in GC callback (#534)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #534

Ensure that the GC remains disabled after every training batch since it may have been re-enabled elsewhere.

Reviewed By: anshulverma

Differential Revision: D49100568

fbshipit-source-id: f3dae95745778face82aa26af6fe06dd09dab50f
  • Loading branch information
kaishengtai authored and facebook-github-bot committed Sep 11, 2023
1 parent b98c3c7 commit c3b62dc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions torchtnt/framework/callbacks/garbage_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def on_train_step_end(self, state: State, unit: TTrainUnit) -> None:
if total_num_steps_completed % self._step_interval == 0:
gc.collect()

# Ensure that GC is disabled, in case GC was reenabled elsewhere
gc.disable()

def on_train_end(self, state: State, unit: TTrainUnit) -> None:
gc.enable()

Expand Down

0 comments on commit c3b62dc

Please sign in to comment.