Dockerfile 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # Builds ultralytics/ultralytics:latest image on DockerHub https://hub.docker.com/r/ultralytics/ultralytics
  3. # Image is CUDA-optimized for YOLOv8 single/multi-GPU training and inference
  4. # Start FROM PyTorch image https://hub.docker.com/r/pytorch/pytorch or nvcr.io/nvidia/pytorch:23.03-py3
  5. FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
  6. RUN pip install --no-cache nvidia-tensorrt --index-url https://pypi.ngc.nvidia.com
  7. # Downloads to user config dir
  8. ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Arial.Unicode.ttf /root/.config/Ultralytics/
  9. # Install linux packages
  10. # g++ required to build 'tflite_support' and 'lap' packages, libusb-1.0-0 required for 'tflite_support' package
  11. RUN apt update \
  12. && apt install --no-install-recommends -y gcc git zip curl htop libgl1-mesa-glx libglib2.0-0 libpython3-dev gnupg g++ libusb-1.0-0
  13. # RUN alias python=python3
  14. # Security updates
  15. # https://security.snyk.io/vuln/SNYK-UBUNTU1804-OPENSSL-3314796
  16. RUN apt upgrade --no-install-recommends -y openssl tar
  17. # Create working directory
  18. WORKDIR /usr/src/ultralytics
  19. # Copy contents
  20. # COPY . /usr/src/app (issues as not a .git directory)
  21. RUN git clone https://github.com/ultralytics/ultralytics /usr/src/ultralytics
  22. ADD https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt /usr/src/ultralytics/
  23. # Install pip packages
  24. RUN python3 -m pip install --upgrade pip wheel
  25. RUN pip install --no-cache -e ".[export]" thop albumentations comet pycocotools
  26. # Run exports to AutoInstall packages
  27. RUN yolo export model=tmp/yolov8n.pt format=edgetpu imgsz=32
  28. RUN yolo export model=tmp/yolov8n.pt format=ncnn imgsz=32
  29. # Requires <= Python 3.10, bug with paddlepaddle==2.5.0
  30. RUN pip install --no-cache paddlepaddle==2.4.2 x2paddle
  31. # Fix error: `np.bool` was a deprecated alias for the builtin `bool`
  32. RUN pip install --no-cache numpy==1.23.5
  33. # Remove exported models
  34. RUN rm -rf tmp
  35. # Set environment variables
  36. ENV OMP_NUM_THREADS=1
  37. # Avoid DDP error "MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 library" https://github.com/pytorch/pytorch/issues/37377
  38. ENV MKL_THREADING_LAYER=GNU
  39. # Usage Examples -------------------------------------------------------------------------------------------------------
  40. # Build and Push
  41. # t=ultralytics/ultralytics:latest && sudo docker build -f docker/Dockerfile -t $t . && sudo docker push $t
  42. # Pull and Run
  43. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
  44. # Pull and Run with local directory access
  45. # t=ultralytics/ultralytics:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/datasets:/usr/src/datasets $t
  46. # Kill all
  47. # sudo docker kill $(sudo docker ps -q)
  48. # Kill all image-based
  49. # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/ultralytics:latest)
  50. # DockerHub tag update
  51. # t=ultralytics/ultralytics:latest tnew=ultralytics/ultralytics:v6.2 && sudo docker pull $t && sudo docker tag $t $tnew && sudo docker push $tnew
  52. # Clean up
  53. # sudo docker system prune -a --volumes
  54. # Update Ubuntu drivers
  55. # https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
  56. # DDP test
  57. # python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
  58. # GCP VM from Image
  59. # docker.io/ultralytics/ultralytics:latest