Dockerfile-arm64 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # Builds ultralytics/ultralytics:latest-arm64 image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
  3. # Image is aarch64-compatible for Apple M1, M2, M3, Raspberry Pi and other ARM architectures
  4. # Start FROM Ubuntu image https://hub.docker.com/_/ubuntu with "FROM arm64v8/ubuntu:22.04" (deprecated)
  5. # Start FROM Debian image for arm64v8 https://hub.docker.com/r/arm64v8/debian (new)
  6. FROM arm64v8/debian:bookworm-slim
  7. # Set environment variables
  8. ENV APP_HOME /usr/src/ultralytics
  9. # Downloads to user config dir
  10. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
  11. https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
  12. /root/.config/Ultralytics/
  13. # Install linux packages
  14. # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package
  15. # pkg-config and libhdf5-dev (not included) are needed to build 'h5py==3.11.0' aarch64 wheel required by 'tensorflow'
  16. RUN apt update \
  17. && apt install --no-install-recommends -y python3-pip git zip unzip wget curl htop gcc libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0
  18. # Create working directory
  19. WORKDIR $APP_HOME
  20. # Copy contents and assign permissions
  21. COPY . $APP_HOME
  22. RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git
  23. ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt $APP_HOME
  24. # Remove python3.11/EXTERNALLY-MANAGED to avoid 'externally-managed-environment' issue, Debian 12 Bookworm error
  25. RUN rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
  26. # Install pip packages
  27. # Install tensorstore from .whl because PyPI does not include aarch64 binaries
  28. RUN python3 -m pip install --upgrade pip wheel
  29. RUN pip install --no-cache-dir https://github.com/ultralytics/yolov5/releases/download/v1.0/tensorstore-0.1.59-cp311-cp311-linux_aarch64.whl -e ".[export]"
  30. # Creates a symbolic link to make 'python' point to 'python3'
  31. RUN ln -sf /usr/bin/python3 /usr/bin/python
  32. # Usage Examples -------------------------------------------------------------------------------------------------------
  33. # Build and Push
  34. # t=ultralytics/ultralytics:latest-arm64 && sudo docker build --platform linux/arm64 -f docker/Dockerfile-arm64 -t $t . && sudo docker push $t
  35. # Run
  36. # t=ultralytics/ultralytics:latest-arm64 && sudo docker run -it --ipc=host $t
  37. # Pull and Run
  38. # t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host $t
  39. # Pull and Run with local volume mounted
  40. # t=ultralytics/ultralytics:latest-arm64 && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/usr/src/datasets $t