From 0572b294458524f3861bb4af6204150eaf47852b Mon Sep 17 00:00:00 2001 From: Lakshantha Dissanayake Date: Thu, 22 Feb 2024 14:43:09 -0800 Subject: [PATCH] `ultralytics 8.1.18` add cmake for building onnxsim on aarch64 (#8395) Co-authored-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- docker/Dockerfile-arm64 | 2 +- ultralytics/__init__.py | 2 +- ultralytics/engine/exporter.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile-arm64 b/docker/Dockerfile-arm64 index c56945f256..dd612b0517 100644 --- a/docker/Dockerfile-arm64 +++ b/docker/Dockerfile-arm64 @@ -15,7 +15,7 @@ ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \ # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package # cmake and build-essential is needed to build onnxsim when exporting to tflite RUN apt update \ - && apt install --no-install-recommends -y python3-pip git zip curl htop gcc libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 cmake build-essential + && apt install --no-install-recommends -y python3-pip git zip curl htop gcc libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0 build-essential # Create working directory WORKDIR /usr/src/ultralytics diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 7749fedd45..9c24e00cc2 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.1.17" +__version__ = "8.1.18" from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 20c7d3b7d5..68892958e3 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -343,6 +343,8 @@ class Exporter: requirements = ["onnx>=1.12.0"] if self.args.simplify: requirements += ["onnxsim>=0.4.33", "onnxruntime-gpu" if torch.cuda.is_available() else "onnxruntime"] + if ARM64: + check_requirements("cmake") # 'cmake' is needed to build onnxsim on aarch64 check_requirements(requirements) import onnx # noqa @@ -712,8 +714,12 @@ class Exporter: try: import tensorflow as tf # noqa except ImportError: - check_requirements(f"tensorflow{'-macos' if MACOS else '-aarch64' if ARM64 else '' if cuda else '-cpu'}") + suffix = "-macos" if MACOS else "-aarch64" if ARM64 else "" if cuda else "-cpu" + version = "" if ARM64 else "<=2.13.1" + check_requirements(f"tensorflow{suffix}{version}") import tensorflow as tf # noqa + if ARM64: + check_requirements("cmake") # 'cmake' is needed to build onnxsim on aarch64 check_requirements( ( "onnx>=1.12.0", @@ -722,7 +728,7 @@ class Exporter: "onnxsim>=0.4.33", "onnx_graphsurgeon>=0.3.26", "tflite_support", - "flatbuffers>=23.5.26", # update old 'flatbuffers' included inside tensorflow package + "flatbuffers>=23.5.26,<100", # update old 'flatbuffers' included inside tensorflow package "onnxruntime-gpu" if cuda else "onnxruntime", ), cmds="--extra-index-url https://pypi.ngc.nvidia.com",