Skip to content

Run YOLOv5 🚀 on Google Cloud Platform (GCP) Deep Learning Virtual Machine (VM) ⭐

This tutorial will guide you through the process of setting up and running YOLOv5 on a GCP Deep Learning VM. New GCP users are eligible for a $300 free credit offer.

You can also explore other quickstart options for YOLOv5, such as our Colab Notebook Open In Colab Open In Kaggle, Amazon AWS and our Docker image at Docker Hub Docker Pulls. Updated: 21 April 2023.

Last Updated: 6 May 2022

Step 1: Create a Deep Learning VM

  1. Go to the GCP marketplace and select a Deep Learning VM.
  2. Choose an n1-standard-8 instance (with 8 vCPUs and 30 GB memory).
  3. Add a GPU of your choice.
  4. Check 'Install NVIDIA GPU driver automatically on first startup?'
  5. Select a 300 GB SSD Persistent Disk for sufficient I/O speed.
  6. Click 'Deploy'.

The preinstalled Anaconda Python environment includes all dependencies.

GCP Marketplace

Step 2: Set Up the VM

Clone the YOLOv5 repository and install the requirements.txt in a Python>=3.7.0 environment, including PyTorch>=1.7. Models and datasets will be downloaded automatically from the latest YOLOv5 release.

git clone  # clone
cd yolov5
pip install -r requirements.txt  # install

Step 3: Run YOLOv5 🚀 on the VM

You can now train, test, detect, and export YOLOv5 models on your VM:

python  # train a model
python --weights  # validate a model for Precision, Recall, and mAP
python --weights --source path/to/images  # run inference on images and videos
python --weights --include onnx coreml tflite  # export models to other formats

GCP terminal

Created 2023-04-21, Updated 2023-05-09
Authors: Glenn Jocher (3)