From 63ff6d0a05d9254a449b43a7e39fe0f39624f917 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 8 Feb 2022 11:40:43 +0100 Subject: [PATCH 1/2] Improved AutoBatch DDP error message --- train.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/train.py b/train.py index 56103b8d4202..b25bddcb079e 100644 --- a/train.py +++ b/train.py @@ -522,10 +522,12 @@ def main(opt, callbacks=Callbacks()): # DDP mode device = select_device(opt.device, batch_size=opt.batch_size) if LOCAL_RANK != -1: - assert torch.cuda.device_count() > LOCAL_RANK, 'insufficient CUDA devices for DDP command' + msg = 'is not compatible with YOLOv5 Multi-GPU DDP training' + assert not opt.image_weights, f'--image-weights {msg}' + assert not opt.evolve, f'--evolve {msg}' + assert opt.batch_size != -1, f'AutoBatch with --batch-size -1 {msg}, please pass a valid --batch-size' assert opt.batch_size % WORLD_SIZE == 0, '--batch-size must be multiple of CUDA device count' - assert not opt.image_weights, '--image-weights argument is not compatible with DDP training' - assert not opt.evolve, '--evolve argument is not compatible with DDP training' + assert torch.cuda.device_count() > LOCAL_RANK, 'insufficient CUDA devices for DDP command' torch.cuda.set_device(LOCAL_RANK) device = torch.device('cuda', LOCAL_RANK) dist.init_process_group(backend="nccl" if dist.is_nccl_available() else "gloo") From bd73bdd09f63f33c5ac333682e2c16e60bd16cbb Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 8 Feb 2022 11:44:12 +0100 Subject: [PATCH 2/2] Cleanup --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index b25bddcb079e..4a1f8958b874 100644 --- a/train.py +++ b/train.py @@ -526,7 +526,7 @@ def main(opt, callbacks=Callbacks()): assert not opt.image_weights, f'--image-weights {msg}' assert not opt.evolve, f'--evolve {msg}' assert opt.batch_size != -1, f'AutoBatch with --batch-size -1 {msg}, please pass a valid --batch-size' - assert opt.batch_size % WORLD_SIZE == 0, '--batch-size must be multiple of CUDA device count' + assert opt.batch_size % WORLD_SIZE == 0, f'--batch-size {opt.batch_size} must be multiple of WORLD_SIZE' assert torch.cuda.device_count() > LOCAL_RANK, 'insufficient CUDA devices for DDP command' torch.cuda.set_device(LOCAL_RANK) device = torch.device('cuda', LOCAL_RANK)