yolov5/Dockerfile

56 lines
1.8 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.05-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 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 22:51:17 +08:00
RUN pip install --no-cache -U torch torchvision numpy
# RUN pip install --no-cache torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
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
# 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/