2023-07-18 15:11:13 +00:00
|
|
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
|
|
|
# Builds ultralytics/ultralytics:latest-cpu image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
|
|
|
|
|
# Image is CPU-optimized for ONNX, OpenVINO and PyTorch YOLOv8 deployments
|
|
|
|
|
|
2024-09-28 23:02:35 +00:00
|
|
|
# Use official Python base image for reproducibility (3.11.10 for export and 3.12.6 for inference)
|
|
|
|
|
FROM python:3.11.10-slim-bookworm
|
2023-07-18 15:11:13 +00:00
|
|
|
|
2024-08-06 16:21:48 +00:00
|
|
|
# Set environment variables
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
|
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
|
PIP_NO_CACHE_DIR=1 \
|
|
|
|
|
PIP_BREAK_SYSTEM_PACKAGES=1
|
|
|
|
|
|
2023-07-18 15:11:13 +00:00
|
|
|
# Downloads to user config dir
|
2024-02-01 22:33:02 +00:00
|
|
|
ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
|
|
|
|
|
https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
|
|
|
|
|
/root/.config/Ultralytics/
|
2023-07-18 15:11:13 +00:00
|
|
|
|
|
|
|
|
# Install linux packages
|
|
|
|
|
# g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package
|
|
|
|
|
RUN apt update \
|
2024-07-06 09:22:50 +00:00
|
|
|
&& apt install --no-install-recommends -y python3-pip git zip unzip wget curl htop libgl1 libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0
|
2023-07-18 15:11:13 +00:00
|
|
|
|
|
|
|
|
# Create working directory
|
2024-07-28 15:49:07 +00:00
|
|
|
WORKDIR /ultralytics
|
2023-07-18 15:11:13 +00:00
|
|
|
|
2024-08-06 16:21:48 +00:00
|
|
|
# Copy contents and configure git
|
2024-07-28 15:49:07 +00:00
|
|
|
COPY . .
|
2024-08-06 16:21:48 +00:00
|
|
|
RUN sed -i '/^\[http "https:\/\/github\.com\/"\]/,+1d' .git/config
|
2024-07-28 15:49:07 +00:00
|
|
|
ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt .
|
2023-07-18 15:11:13 +00:00
|
|
|
|
|
|
|
|
# Install pip packages
|
|
|
|
|
RUN python3 -m pip install --upgrade pip wheel
|
2024-08-06 16:21:48 +00:00
|
|
|
RUN pip install -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu
|
2023-07-18 15:11:13 +00:00
|
|
|
|
|
|
|
|
# Run exports to AutoInstall packages
|
2023-07-25 02:16:02 +00:00
|
|
|
RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32
|
|
|
|
|
RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32
|
2024-06-08 21:34:51 +00:00
|
|
|
# Requires Python<=3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991
|
2024-08-06 16:21:48 +00:00
|
|
|
RUN pip install "paddlepaddle>=2.6.0" x2paddle
|
2023-07-18 16:31:17 +00:00
|
|
|
|
2024-09-28 18:07:03 +00:00
|
|
|
# Remove extra build files
|
|
|
|
|
RUN rm -rf tmp /root/.config/Ultralytics/persistent_cache.json
|
2023-09-03 21:44:11 +00:00
|
|
|
|
2023-07-18 15:11:13 +00:00
|
|
|
# Usage Examples -------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# Build and Push
|
|
|
|
|
# t=ultralytics/ultralytics:latest-python && sudo docker build -f docker/Dockerfile-python -t $t . && sudo docker push $t
|
|
|
|
|
|
|
|
|
|
# Run
|
|
|
|
|
# t=ultralytics/ultralytics:latest-python && sudo docker run -it --ipc=host $t
|
|
|
|
|
|
2023-09-02 18:01:57 +00:00
|
|
|
# Pull and Run
|
|
|
|
|
# t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host $t
|
|
|
|
|
|
2023-07-18 15:11:13 +00:00
|
|
|
# Pull and Run with local volume mounted
|
2024-07-28 15:49:07 +00:00
|
|
|
# t=ultralytics/ultralytics:latest-python && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/datasets $t
|