2021-08-14 21:17:51 +02:00
|
|
|
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
|
2022-05-29 20:43:01 +02:00
|
|
|
# Builds ultralytics/yolov5:latest image on DockerHub https://hub.docker.com/r/ultralytics/yolov5
|
|
|
|
# Image is CUDA-optimized for YOLOv5 single/multi-GPU training and inference
|
2021-08-14 21:17:51 +02:00
|
|
|
|
2022-05-03 13:47:30 -07:00
|
|
|
# Start FROM NVIDIA PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
|
2022-11-24 16:34:14 +01:00
|
|
|
FROM nvcr.io/nvidia/pytorch:22.11-py3
|
2022-05-03 13:47:30 -07:00
|
|
|
RUN rm -rf /opt/pytorch # remove 1.2GB dir
|
|
|
|
|
|
|
|
# Downloads to user config dir
|
|
|
|
ADD https://ultralytics.com/assets/Arial.ttf https://ultralytics.com/assets/Arial.Unicode.ttf /root/.config/Ultralytics/
|
2020-07-31 11:10:03 -07:00
|
|
|
|
2020-12-09 19:01:08 -08:00
|
|
|
# Install linux packages
|
2022-05-17 01:29:23 +02:00
|
|
|
RUN apt update && apt install --no-install-recommends -y zip htop screen libgl1-mesa-glx
|
2020-12-09 19:01:08 -08:00
|
|
|
|
2022-05-02 20:53:02 -07:00
|
|
|
# Install pip packages
|
2020-12-22 20:53:44 -08:00
|
|
|
COPY requirements.txt .
|
2022-07-16 16:41:43 +02:00
|
|
|
RUN python -m pip install --upgrade pip wheel
|
2022-11-08 00:58:00 +01:00
|
|
|
RUN pip uninstall -y Pillow torchtext # torch torchvision
|
2022-11-09 15:05:19 +01:00
|
|
|
RUN pip install --no-cache -r requirements.txt ultralytics albumentations comet gsutil notebook Pillow>=9.1.0 \
|
2022-06-09 22:45:49 +02:00
|
|
|
'opencv-python<4.6.0.66' \
|
2022-05-17 14:11:38 +02:00
|
|
|
--extra-index-url https://download.pytorch.org/whl/cu113
|
2020-08-15 09:53:22 -07:00
|
|
|
|
2020-05-29 17:04:54 -07:00
|
|
|
# Create working directory
|
|
|
|
RUN mkdir -p /usr/src/app
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
# Copy contents
|
2022-08-01 21:45:31 +02:00
|
|
|
# COPY . /usr/src/app (issues as not a .git directory)
|
|
|
|
RUN git clone https://github.com/ultralytics/yolov5 /usr/src/app
|
2020-05-29 17:04:54 -07:00
|
|
|
|
2021-03-05 15:53:57 -08:00
|
|
|
# Set environment variables
|
2022-03-30 16:01:55 +02:00
|
|
|
ENV OMP_NUM_THREADS=8
|
2020-05-29 17:04:54 -07:00
|
|
|
|
|
|
|
|
2021-06-26 16:09:56 +02:00
|
|
|
# Usage Examples -------------------------------------------------------------------------------------------------------
|
2020-05-29 17:04:54 -07:00
|
|
|
|
|
|
|
# Build and Push
|
2022-04-21 20:31:26 -07:00
|
|
|
# t=ultralytics/yolov5:latest && sudo docker build -f utils/docker/Dockerfile -t $t . && sudo docker push $t
|
2020-05-29 17:04:54 -07:00
|
|
|
|
|
|
|
# Pull and Run
|
2020-11-29 17:47:51 +01:00
|
|
|
# t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all $t
|
2020-05-29 17:04:54 -07:00
|
|
|
|
|
|
|
# Pull and Run with local directory access
|
2021-06-26 16:09:56 +02:00
|
|
|
# t=ultralytics/yolov5:latest && sudo docker pull $t && sudo docker run -it --ipc=host --gpus all -v "$(pwd)"/datasets:/usr/src/datasets $t
|
2020-05-29 17:04:54 -07:00
|
|
|
|
|
|
|
# Kill all
|
2020-09-08 00:56:35 -07:00
|
|
|
# sudo docker kill $(sudo docker ps -q)
|
2020-05-29 17:04:54 -07:00
|
|
|
|
|
|
|
# Kill all image-based
|
2021-01-26 17:30:42 -08:00
|
|
|
# sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/yolov5:latest)
|
2020-05-29 17:04:54 -07:00
|
|
|
|
2022-08-17 22:50:08 +02:00
|
|
|
# DockerHub tag update
|
|
|
|
# t=ultralytics/yolov5:latest tnew=ultralytics/yolov5:v6.2 && sudo docker pull $t && sudo docker tag $t $tnew && sudo docker push $tnew
|
2020-07-15 17:40:19 -07:00
|
|
|
|
2020-05-29 17:04:54 -07:00
|
|
|
# Clean up
|
2020-07-15 17:40:19 -07:00
|
|
|
# docker system prune -a --volumes
|
2021-09-20 12:22:24 +02:00
|
|
|
|
|
|
|
# Update Ubuntu drivers
|
|
|
|
# https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
|
2021-09-20 13:10:41 +02:00
|
|
|
|
|
|
|
# DDP test
|
|
|
|
# python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
|
2021-11-28 18:12:46 +01:00
|
|
|
|
|
|
|
# GCP VM from Image
|
|
|
|
# docker.io/ultralytics/yolov5:latest
|