Skip to content

Commit

Permalink
add clear gpu cache after each batch in eval
Browse files Browse the repository at this point in the history
  • Loading branch information
OuyangWenyu committed Dec 14, 2024
1 parent 184534d commit 2b9c0d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchhydro/trainers/deep_hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ def inference(self) -> Tuple[xr.Dataset, xr.Dataset]:
ys, pred = model_infer(seq_first, device, self.model, xs, ys)
test_preds.append(pred.cpu().numpy())
obss.append(ys.cpu().numpy())
# clear GPU cache -- this will not impact results
torch.cuda.empty_cache()
pred = reduce(lambda x, y: np.vstack((x, y)), test_preds)
obs = reduce(lambda x, y: np.vstack((x, y)), obss)
if pred.ndim == 2:
Expand Down

0 comments on commit 2b9c0d3

Please sign in to comment.