Get Started with YOLOv5 🚀 in Docker
This tutorial will guide you through the process of setting up and running YOLOv5 in a Docker container.
You can also explore other quickstart options for YOLOv5, such as our Colab Notebook , GCP Deep Learning VM, and Amazon AWS.
Prerequisites
- NVIDIA Driver: Version 455.23 or higher. Download from NVIDIA's website.
- NVIDIA-Docker: Allows Docker to interact with your local GPU. Installation instructions are available on the NVIDIA-Docker GitHub repository.
- Docker Engine - CE: Version 19.03 or higher. Download and installation instructions can be found on the Docker website.
Step 1: Pull the YOLOv5 Docker Image
The Ultralytics YOLOv5 DockerHub repository is available at https://hub.docker.com/r/ultralytics/yolov5. Docker Autobuild ensures that the ultralytics/yolov5:latest
image is always in sync with the most recent repository commit. To pull the latest image, run the following command:
Step 2: Run the Docker Container
Basic container:
Run an interactive instance of the YOLOv5 Docker image (called a "container") using the -it
flag:
Container with local file access:
To run a container with access to local files (e.g., COCO training data in /datasets
), use the -v
flag:
Container with GPU access:
To run a container with GPU access, use the --gpus all
flag:
Step 3: Use YOLOv5 🚀 within the Docker Container
Now you can train, test, detect, and export YOLOv5 models within the running Docker container:
# Train a model on your data
python train.py
# Validate the trained model for Precision, Recall, and mAP
python val.py --weights yolov5s.pt
# Run inference using the trained model on your images or videos
python detect.py --weights yolov5s.pt --source path/to/images
# Export the trained model to other formats for deployment
python export.py --weights yolov5s.pt --include onnx coreml tflite