Dockerfile-cpu 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # Builds ultralytics/ultralytics:latest-cpu image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
  3. # Image is CPU-optimized for ONNX, OpenVINO and PyTorch YOLOv8 deployments
  4. # Start FROM Ubuntu image https://hub.docker.com/_/ubuntu
  5. FROM ubuntu:23.10
  6. # Set environment variables
  7. ENV APP_HOME /usr/src/ultralytics
  8. # Downloads to user config dir
  9. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.ttf \
  10. https://github.com/ultralytics/assets/releases/download/v0.0.0/Arial.Unicode.ttf \
  11. /root/.config/Ultralytics/
  12. # Install linux packages
  13. # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package
  14. RUN apt update \
  15. && 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
  16. # Create working directory
  17. WORKDIR $APP_HOME
  18. # Copy contents (previously used git clone to avoid permission errors)
  19. COPY . $APP_HOME
  20. RUN git remote set-url origin https://github.com/ultralytics/ultralytics.git
  21. ADD https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt $APP_HOME
  22. # Remove python3.11/EXTERNALLY-MANAGED or use 'pip install --break-system-packages' avoid 'externally-managed-environment' Ubuntu nightly error
  23. RUN rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
  24. # Install pip packages
  25. RUN python3 -m pip install --upgrade pip wheel
  26. RUN pip install --no-cache-dir -e ".[export]" --extra-index-url https://download.pytorch.org/whl/cpu
  27. # Run exports to AutoInstall packages
  28. RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32
  29. RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32
  30. # Requires Python<=3.10, bug with paddlepaddle==2.5.0 https://github.com/PaddlePaddle/X2Paddle/issues/991
  31. # RUN pip install --no-cache-dir "paddlepaddle>=2.6.0" x2paddle
  32. # Remove exported models
  33. RUN rm -rf tmp
  34. # Creates a symbolic link to make 'python' point to 'python3'
  35. RUN ln -sf /usr/bin/python3 /usr/bin/python
  36. # Usage Examples -------------------------------------------------------------------------------------------------------
  37. # Build and Push
  38. # t=ultralytics/ultralytics:latest-cpu && sudo docker build -f docker/Dockerfile-cpu -t $t . && sudo docker push $t
  39. # Run
  40. # t=ultralytics/ultralytics:latest-cpu && sudo docker run -it --ipc=host --name NAME $t
  41. # Pull and Run
  42. # t=ultralytics/ultralytics:latest-cpu && sudo docker pull $t && sudo docker run -it --ipc=host --name NAME $t
  43. # Pull and Run with local volume mounted
  44. # t=ultralytics/ultralytics:latest-cpu && sudo docker pull $t && sudo docker run -it --ipc=host -v "$(pwd)"/shared/datasets:/usr/src/datasets $t