Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autobatch feature for best batch-size estimation #5092

Merged
merged 47 commits into from
Oct 25, 2021
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7798401
Autobatch
glenn-jocher Oct 7, 2021
38ee33c
fix mem
glenn-jocher Oct 7, 2021
9bab757
fix mem2
glenn-jocher Oct 7, 2021
8a0ee56
Update
glenn-jocher Oct 7, 2021
8a68891
Update
glenn-jocher Oct 7, 2021
6f67028
Update
glenn-jocher Oct 7, 2021
ccd47a0
Update
glenn-jocher Oct 7, 2021
05d7860
Update
glenn-jocher Oct 7, 2021
78cbd2a
Update
glenn-jocher Oct 7, 2021
3b34bd4
Update
glenn-jocher Oct 7, 2021
cc09ecf
Update
glenn-jocher Oct 7, 2021
6d0b3e9
Update
glenn-jocher Oct 7, 2021
9282c21
Update
glenn-jocher Oct 7, 2021
45ddb57
Update
glenn-jocher Oct 7, 2021
b1a57d1
Update
glenn-jocher Oct 7, 2021
122733d
Update
glenn-jocher Oct 7, 2021
13c4996
Update
glenn-jocher Oct 7, 2021
bd34ab8
Update
glenn-jocher Oct 7, 2021
bbe56b8
Update
glenn-jocher Oct 7, 2021
aef68c9
Update
glenn-jocher Oct 7, 2021
3faf055
Update
glenn-jocher Oct 7, 2021
831593b
Update
glenn-jocher Oct 7, 2021
65e3bf6
Update
glenn-jocher Oct 7, 2021
6a0c4d2
Update
glenn-jocher Oct 7, 2021
6fa9834
Update train.py
glenn-jocher Oct 8, 2021
888f55c
print result
glenn-jocher Oct 8, 2021
d2f47bc
Cleanup print result
glenn-jocher Oct 8, 2021
c94026a
swap fix in call
glenn-jocher Oct 8, 2021
afdfcfb
to 64
glenn-jocher Oct 8, 2021
ab7cc12
use total
glenn-jocher Oct 8, 2021
a036dd4
fix
glenn-jocher Oct 8, 2021
f6f80ed
fix
glenn-jocher Oct 8, 2021
e601f42
fix
glenn-jocher Oct 8, 2021
f55ad0b
fix
glenn-jocher Oct 8, 2021
58ed6af
fix
glenn-jocher Oct 8, 2021
18f5dd3
Update
glenn-jocher Oct 8, 2021
4b39534
Update
glenn-jocher Oct 8, 2021
1c9b42a
Update
glenn-jocher Oct 8, 2021
5c2e235
Update
glenn-jocher Oct 8, 2021
08f8e17
Update
glenn-jocher Oct 8, 2021
a9c00fa
Update
glenn-jocher Oct 8, 2021
ccabcd3
Update
glenn-jocher Oct 8, 2021
af25dbc
Cleanup printing
glenn-jocher Oct 8, 2021
3e1c74f
Update final printout
glenn-jocher Oct 25, 2021
602cf9a
Update autobatch.py
glenn-jocher Oct 25, 2021
126c13a
Update autobatch.py
glenn-jocher Oct 25, 2021
327954f
Update autobatch.py
glenn-jocher Oct 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update
  • Loading branch information
glenn-jocher committed Oct 25, 2021
commit 6a0c4d21e08438f7cc8168679df760de5353360c
8 changes: 8 additions & 0 deletions utils/autobatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
from utils.torch_utils import de_parallel, profile


def check_batch_size(model, imgsz=640, b=16):
# Check YOLOv5 batch size
assert isinstance(b, int), f'batch-size {b} must be integer'
if b < 1:
b = autobatch(model, imgsz) # compute optimal batch size
return b


def autobatch(model, imgsz=640, fraction=0.95):
# Automatically compute optimal batch size to use `fraction` of available CUDA memory
# Usage:
Expand Down