Add checks for multi-GPU training (#20516)
Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
This commit is contained in:
parent
ac73bc4c36
commit
deedee7d99
@ -71,8 +71,13 @@ def test_export_engine_matrix(task, dynamic, int8, half, batch):
|
||||
@pytest.mark.skipif(not DEVICES, reason="No CUDA devices available")
|
||||
def test_train():
|
||||
"""Test model training on a minimal dataset using available CUDA devices."""
|
||||
device = DEVICES if len(DEVICES) > 1 else DEVICES[0]
|
||||
YOLO(MODEL).train(data="coco8.yaml", imgsz=64, epochs=1, device=device) # requires imgsz>=64
|
||||
import os
|
||||
|
||||
device = tuple(DEVICES) if len(DEVICES) > 1 else DEVICES[0]
|
||||
results = YOLO(MODEL).train(data="coco8.yaml", imgsz=64, epochs=1, device=device) # requires imgsz>=64
|
||||
visible = eval(os.environ["CUDA_VISIBLE_DEVICES"])
|
||||
assert visible == device, f"Passed GPUs '{device}', but used GPUs '{visible}'"
|
||||
assert results is (None if len(DEVICES) > 1 else not None) # DDP returns None, single-GPU returns metrics
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user