Skip to content

Commit

Permalink
Fix a GPU memory leak in detect. No need to calculate gradients in in…
Browse files Browse the repository at this point in the history
…ference. (#900)

Co-authored-by: JKO095 <[email protected]>
  • Loading branch information
jpkoponen and JKO095 authored Oct 7, 2022
1 parent 8b616af commit 072f76c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def detect(save_img=False):

# Inference
t1 = time_synchronized()
pred = model(img, augment=opt.augment)[0]
with torch.no_grad(): # Calculating gradients would cause a GPU memory leak
pred = model(img, augment=opt.augment)[0]
t2 = time_synchronized()

# Apply NMS
Expand Down

0 comments on commit 072f76c

Please sign in to comment.