From 381401e8afea3d45cd359696d5609bc56ae1dfef Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 6 Mar 2026 00:01:35 +0100 Subject: [PATCH] Add Torch 2.10 with updated Torch and torchvision versions (#23808) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- .github/workflows/ci.yml | 4 ++++ ultralytics/engine/exporter.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1c8c25a..a7d530dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -288,6 +288,10 @@ jobs: python: "3.12" torch: "2.9.0" torchvision: "0.24.0" + - os: ubuntu-latest + python: "3.12" + torch: "2.10.0" + torchvision: "0.25.0" steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 8a1bbd32..17b2cf73 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -187,6 +187,8 @@ def best_onnx_opset(onnx, cuda=False) -> int: """Return max ONNX opset for this torch version with ONNX fallback.""" if TORCH_2_4: # _constants.ONNX_MAX_OPSET first defined in torch 1.13 opset = torch.onnx.utils._constants.ONNX_MAX_OPSET - 1 # use second-latest version for safety + if TORCH_2_9: + opset = min(opset, 20) # legacy TorchScript exporter caps at opset 20 in torch 2.9+ if cuda: opset -= 2 # fix CUDA ONNXRuntime NMS squeeze op errors else: