Skip to content

Commit

Permalink
gc collect on trainer teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli committed Jul 29, 2021
1 parent ecf42db commit 6f3afb2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Trainer to automate the training."""
import gc
import logging
import os
import traceback
Expand Down Expand Up @@ -982,6 +983,7 @@ def _post_dispatch(self):
self.accelerator.teardown()
self._active_loop.teardown()
self.logger_connector.teardown()
gc.collect()

def _dispatch(self):
if self.evaluating:
Expand Down

0 comments on commit 6f3afb2

Please sign in to comment.