yolov5/Dockerfile

65 lines
2.0 KiB
Docker
Raw Normal View History

# YOLOv5 🚀 by Ultralytics, GPL-3.0 license
2020-05-30 08:04:54 +08:00
# Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
FROM nvcr.io/nvidia/pytorch:21.10-py3
2020-12-10 11:01:08 +08:00
# Install linux packages
2021-02-28 07:55:31 +08:00
RUN apt update && apt install -y zip htop screen libgl1-mesa-glx
2020-12-10 11:01:08 +08:00
# Install python dependencies
COPY requirements.txt .
RUN python -m pip install --upgrade pip
RUN pip uninstall -y torch torchvision torchtext
RUN pip install --no-cache -r requirements.txt albumentations wandb gsutil notebook \
torch==1.10.2+cu113 torchvision==0.11.3+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
# RUN pip install --no-cache -U torch torchvision
2020-08-16 00:53:22 +08:00
2020-05-30 08:04:54 +08:00
# Create working directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Copy contents
COPY . /usr/src/app
# Downloads to user config dir
ADD https://ultralytics.com/assets/Arial.ttf /root/.config/Ultralytics/
# Set environment variables
# ENV HOME=/usr/src/app
2020-05-30 08:04:54 +08:00
2021-06-26 22:09:56 +08:00
# Usage Examples -------------------------------------------------------------------------------------------------------
2020-05-30 08:04:54 +08: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-30 08:04:54 +08:00
# Pull and Run with local directory access
2021-06-26 22:09:56 +08: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-30 08:04:54 +08:00
# Kill all
# sudo docker kill $(sudo docker ps -q)
2020-05-30 08:04:54 +08:00
# Kill all image-based
2021-01-27 09:30:42 +08:00
# sudo docker kill $(sudo docker ps -qa --filter ancestor=ultralytics/yolov5:latest)
2020-05-30 08:04:54 +08:00
2020-05-31 00:49:11 +08:00
# Bash into running container
2021-01-23 06:26:58 +08:00
# sudo docker exec -it 5a9b5863d93d bash
2020-05-30 08:04:54 +08:00
2020-05-31 00:49:11 +08:00
# Bash into stopped container
2021-01-27 09:30:42 +08:00
# id=$(sudo docker ps -qa) && sudo docker start $id && sudo docker exec -it $id bash
2020-07-16 08:40:19 +08:00
2020-05-30 08:04:54 +08:00
# Clean up
2020-07-16 08:40:19 +08:00
# docker system prune -a --volumes
2021-09-20 18:22:24 +08:00
# Update Ubuntu drivers
# https://www.maketecheasier.com/install-nvidia-drivers-ubuntu/
2021-09-20 19:10:41 +08:00
# DDP test
# python -m torch.distributed.run --nproc_per_node 2 --master_port 1 train.py --epochs 3
2021-11-29 01:12:46 +08:00
# GCP VM from Image
# docker.io/ultralytics/yolov5:latest