Skip to content

Commit

Permalink
Add garbage collection to predict_step
Browse files Browse the repository at this point in the history
  • Loading branch information
surajpaib committed Feb 2, 2024
1 parent b95775c commit 23fa0e9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lighter/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from functools import partial

import gc
import pytorch_lightning as pl
import torch
from loguru import logger
Expand Down Expand Up @@ -183,6 +184,7 @@ def _base_step(self, batch: Union[List, Tuple], batch_idx: int, mode: str) -> Un
if mode == "predict":
# Postprocessing for logging/writing.
pred = apply_fns(pred, self.postprocessing["logging"]["pred"])
gc.collect()
return {"pred": pred, "id": id}

# Calculate the loss.
Expand Down

0 comments on commit 23fa0e9

Please sign in to comment.