2021-08-15 03:17:51 +08:00
|
|
|
# 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
|
2022-02-17 21:51:53 +08:00
|
|
|
FROM nvcr.io/nvidia/pytorch:21.10-py3
|
2020-08-01 02:10:03 +08:00
|
|
|
|
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
|
2020-12-23 12:53:44 +08:00
|
|
|
COPY requirements.txt .
|
2021-03-06 07:53:57 +08:00
|
|
|
RUN python -m pip install --upgrade pip
|
2022-02-17 21:20:42 +08:00
|
|
|
RUN pip uninstall -y nvidia-tensorboard nvidia-tensorboard-plugin-dlprof torch torchvision
|
2022-02-17 20:24:44 +08:00
|
|
|
RUN pip install --no-cache -r requirements.txt albumentations wandb gsutil notebook
|
|
|
|
RUN pip install --no-cache torch==1.10.2+cu113 torchvision==0.11.3+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
|
2022-01-22 15:06:02 +08:00
|
|
|
# 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
|
|
|
|
|
2021-10-08 05:16:33 +08:00
|
|
|
# Downloads to user config dir
|
|
|
|
ADD https://ultralytics.com/assets/Arial.ttf /root/.config/Ultralytics/
|
|
|
|
|
2021-03-06 07:53:57 +08:00
|
|
|
# Set environment variables
|
2021-10-08 05:16:33 +08:00
|
|
|
# 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
|
2020-11-30 00:47:51 +08:00
|
|
|
# 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
|
2020-09-08 15:56:35 +08:00
|
|
|
# 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
|