Dockerfile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
  2. FROM nvcr.io/nvidia/pytorch:21.03-py3
  3. # Install linux packages
  4. RUN apt update && apt install -y zip htop screen libgl1-mesa-glx
  5. # Install python dependencies
  6. COPY requirements.txt .
  7. RUN python -m pip install --upgrade pip
  8. RUN pip uninstall -y nvidia-tensorboard nvidia-tensorboard-plugin-dlprof
  9. RUN pip install --no-cache -r requirements.txt coremltools onnx gsutil notebook
  10. # Create working directory
  11. RUN mkdir -p /usr/src/app
  12. WORKDIR /usr/src/app
  13. # Copy contents
  14. COPY . /usr/src/app
  15. # Set environment variables
  16. ENV HOME=/usr/src/app
  17. # --------------------------------------------------- Extras Below ---------------------------------------------------
  18. # Build and Push
  19. # t=ultralytics/yolov5:latest && sudo docker build -t $t . && sudo docker push $t
  20. # for v in {300..303}; do t=ultralytics/coco:v$v && sudo docker build -t $t . && sudo docker push $t; done
  21. # Pull and Run
  22. # t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
  23. # Pull and Run with local directory access
  24. # t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/coco:/usr/src/coco $t
  25. # Kill all
  26. # sudo docker kill $(sudo docker ps -q)
  27. # Kill all image-based
  28. # sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/yolov5:latest)
  29. # Bash into running container
  30. # sudo docker exec -it 5a9b5863d93d bash
  31. # Bash into stopped container
  32. # id=$(sudo docker ps -qa) && sudo docker start $id && sudo docker exec -it $id bash
  33. # Send weights to GCP
  34. # python -c "from utils.general import *; strip_optimizer('runs/train/exp0_*/weights/best.pt', 'tmp.pt')" && gsutil cp tmp.pt gs://*.pt
  35. # Clean up
  36. # docker system prune -a --volumes