From 476c82495abc61821712c1f92d95a9ddb56311e2 Mon Sep 17 00:00:00 2001 From: Felix You <35478566+youyuxiansen@users.noreply.github.com> Date: Fri, 10 Dec 2021 17:28:50 +0800 Subject: [PATCH] Find out a bug. When set batch_size = -1 to use the autobatch. reproduce: --- utils/torch_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 16289104eb48..f6016d139df1 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -68,7 +68,7 @@ def select_device(device='', batch_size=None, newline=True): if cuda: devices = device.split(',') if device else '0' # range(torch.cuda.device_count()) # i.e. 0,1,6,7 n = len(devices) # device count - if n > 1 and batch_size: # check batch_size is divisible by device_count + if n > 1 and batch_size > 0: # check batch_size is divisible by device_count assert batch_size % n == 0, f'batch-size {batch_size} not multiple of GPU count {n}' space = ' ' * (len(s) + 1) for i, d in enumerate(devices):