You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.3KB

  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.04-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. --extra-index-url https://download.pytorch.org/whl/cu113
  17. # Create working directory
  18. RUN mkdir -p /usr/src/app
  19. WORKDIR /usr/src/app
  20. # Copy contents
  21. COPY . /usr/src/app
  22. RUN git clone https://github.com/ultralytics/yolov5 /usr/src/yolov5
  23. # Set environment variables
  24. ENV OMP_NUM_THREADS=8
  25. # Usage Examples -------------------------------------------------------------------------------------------------------
  26. # Build and Push
  27. # t=ultralytics/yolov5:latest && sudo docker build -f utils/docker/Dockerfile -t $t . && sudo docker push $t
  28. # Pull and Run
  29. # t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
  30. # Pull and Run with local directory access
  31. # t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/datasets:/usr/src/datasets $t
  32. # Kill all
  33. # sudo docker kill $(sudo docker ps -q)
  34. # Kill all image-based
  35. # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/yolov5:latest)
  36. # Bash into running container
  37. # sudo docker exec -it 5a9b5863d93d bash
  38. # Bash into stopped container
  39. # id=$(sudo docker ps -qa) && sudo docker start $id && sudo docker exec -it $id bash
  40. # Clean up
  41. # docker system prune -a --volumes
  42. # Update Ubuntu drivers
  43. # https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
  44. # DDP test
  45. # python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
  46. # GCP VM from Image
  47. # docker.io/ultralytics/yolov5:latest