Skip to content

Commit

Permalink
fix memory bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bubbliiiing committed Jul 2, 2022
1 parent e618179 commit 0a289c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/utils_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def fit_one_epoch(model_train, model, yolo_loss, loss_history, eval_callback, op
images, targets = batch[0], batch[1]
with torch.no_grad():
if cuda:
images = images.cuda()
targets = [ann.cuda() for ann in targets]
images = images.cuda(local_rank)
targets = [ann.cuda(local_rank) for ann in targets]
#----------------------#
# 清零梯度
#----------------------#
Expand Down Expand Up @@ -91,8 +91,8 @@ def fit_one_epoch(model_train, model, yolo_loss, loss_history, eval_callback, op
images, targets = batch[0], batch[1]
with torch.no_grad():
if cuda:
images = images.cuda()
targets = [ann.cuda() for ann in targets]
images = images.cuda(local_rank)
targets = [ann.cuda(local_rank) for ann in targets]
#----------------------#
# 清零梯度
#----------------------#
Expand Down

0 comments on commit 0a289c0

Please sign in to comment.