Dockerfile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
  2. # Builds ultralytics/yolov5:latest image on DockerHub https://hub.docker.com/r/ultralytics/yolov5
  3. # Image is CUDA-optimized for YOLOv5 single/multi-GPU training and inference
  4. # Start FROM NVIDIA PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
  5. FROM nvcr.io/nvidia/pytorch:22.05-py3
  6. RUN rm -rf /opt/pytorch # remove 1.2GB dir
  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. RUN apt update && apt install --no-install-recommends -y zip htop screen libgl1-mesa-glx
  11. # Install pip packages
  12. COPY requirements.txt .
  13. RUN python -m pip install --upgrade pip
  14. RUN pip uninstall -y torch torchvision torchtext Pillow
  15. RUN pip install --no-cache -r requirements.txt albumentations wandb gsutil notebook Pillow>=9.1.0 \
  16. 'opencv-python<4.6.0.66' \
  17. --extra-index-url https://download.pytorch.org/whl/cu113
  18. # Create working directory
  19. RUN mkdir -p /usr/src/app
  20. WORKDIR /usr/src/app
  21. # Copy contents
  22. COPY . /usr/src/app
  23. RUN git clone https://github.com/ultralytics/yolov5 /usr/src/yolov5
  24. # Set environment variables
  25. ENV OMP_NUM_THREADS=8
  26. # Usage Examples -------------------------------------------------------------------------------------------------------
  27. # Build and Push
  28. # t=ultralytics/yolov5:latest && sudo docker build -f utils/docker/Dockerfile -t $t . && sudo docker push $t
  29. # Pull and Run
  30. # t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
  31. # Pull and Run with local directory access
  32. # t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/datasets:/usr/src/datasets $t
  33. # Kill all
  34. # sudo docker kill $(sudo docker ps -q)
  35. # Kill all image-based
  36. # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/yolov5:latest)
  37. # Bash into running container
  38. # sudo docker exec -it 5a9b5863d93d bash
  39. # Bash into stopped container
  40. # id=$(sudo docker ps -qa) && sudo docker start $id && sudo docker exec -it $id bash
  41. # Clean up
  42. # docker system prune -a --volumes
  43. # Update Ubuntu drivers
  44. # https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
  45. # DDP test
  46. # python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
  47. # GCP VM from Image
  48. # docker.io/ultralytics/yolov5:latest