diff --git a/tests/test_cuda.py b/tests/test_cuda.py index aa7c5bb2ba..9690d65b53 100644 --- a/tests/test_cuda.py +++ b/tests/test_cuda.py @@ -121,6 +121,7 @@ def test_train(): device = tuple(DEVICES) if len(DEVICES) > 1 else DEVICES[0] # NVIDIA Jetson only has one GPU and therefore skipping checks if not IS_JETSON: + results = YOLO(MODEL).train(data="coco8-grayscale.yaml", imgsz=64, epochs=1, device=DEVICES[0], batch=-1) results = YOLO(MODEL).train(data="coco8.yaml", imgsz=64, epochs=1, device=device, batch=15, compile=True) results = YOLO(MODEL).train(data="coco128.yaml", imgsz=64, epochs=1, device=device, batch=15, val=False) visible = eval(os.environ["CUDA_VISIBLE_DEVICES"]) diff --git a/ultralytics/utils/autobatch.py b/ultralytics/utils/autobatch.py index c4b1097470..2a8e9dc718 100644 --- a/ultralytics/utils/autobatch.py +++ b/ultralytics/utils/autobatch.py @@ -84,8 +84,9 @@ def autobatch( # Profile batch sizes batch_sizes = [1, 2, 4, 8, 16] if t < 16 else [1, 2, 4, 8, 16, 32, 64] + ch = model.yaml.get("channels", 3) try: - img = [torch.empty(b, 3, imgsz, imgsz) for b in batch_sizes] + img = [torch.empty(b, ch, imgsz, imgsz) for b in batch_sizes] results = profile_ops(img, model, n=1, device=device, max_num_obj=max_num_obj) # Fit a solution