Fix training with compile (#23479)

Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
This commit is contained in:
Mohammed Yasin 2026-01-30 01:56:55 +08:00 committed by GitHub
parent b44adb3a54
commit 3e50f0adec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -120,7 +120,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.yaml", imgsz=64, epochs=1, device=device, batch=15)
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"])
assert visible == device, f"Passed GPUs '{device}', but used GPUs '{visible}'"

View File

@ -73,7 +73,7 @@ class DetectionTrainer(BaseTrainer):
Returns:
(Dataset): YOLO dataset object configured for the specified mode.
"""
gs = max(int(unwrap_model(self.model).stride.max() if self.model else 0), 32)
gs = max(int(unwrap_model(self.model).stride.max()), 32)
return build_yolo_dataset(self.args, img_path, batch, self.data, mode=mode, rect=mode == "val", stride=gs)
def get_dataloader(self, dataset_path: str, batch_size: int = 16, rank: int = 0, mode: str = "train"):