yolov5/Dockerfile

59 lines
1.9 KiB
Docker
Raw Normal View History

# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
2020-05-29 17:04:54 -07:00
# Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
FROM nvcr.io/nvidia/pytorch:21.05-py3
2020-12-09 19:01:08 -08:00
# Install linux packages
2021-02-27 15:55:31 -08:00
RUN apt update && apt install -y zip htop screen libgl1-mesa-glx
2020-12-09 19:01:08 -08:00
# Install python dependencies
COPY requirements.txt .
RUN python -m pip install --upgrade pip
RUN pip uninstall -y nvidia-tensorboard nvidia-tensorboard-plugin-dlprof
RUN pip install --no-cache -r requirements.txt coremltools onnx gsutil notebook wandb>=0.12.2
2021-06-26 16:51:17 +02:00
RUN pip install --no-cache -U torch torchvision numpy
2021-09-26 19:16:14 -07:00
# RUN pip install --no-cache torch==1.9.1+cu111 torchvision==0.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
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
COPY . /usr/src/app
# Set environment variables
ENV HOME=/usr/src/app
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
# t=ultralytics/yolov5:latest && sudo docker build -t $t . && sudo docker push $t
# Pull and Run
# 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
# 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
2020-05-30 09:49:11 -07:00
# Bash into running container
2021-01-22 14:26:58 -08:00
# sudo docker exec -it 5a9b5863d93d bash
2020-05-29 17:04:54 -07:00
2020-05-30 09:49:11 -07:00
# Bash into stopped container
2021-01-26 17:30:42 -08:00
# id=$(sudo docker ps -qa) && sudo docker start $id && sudo docker exec -it $id bash
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