You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

5.8 KiB

comments description keywords
true Get started with YOLOv5 on AWS. Our comprehensive guide provides everything you need to know to run YOLOv5 on an Amazon Deep Learning instance. YOLOv5, AWS, Deep Learning, Instance, Guide, Quickstart

YOLOv5 🚀 on AWS Deep Learning Instance: A Comprehensive Guide

This guide will help new users run YOLOv5 on an Amazon Web Services (AWS) Deep Learning instance. AWS offers a Free Tier and a credit program for a quick and affordable start.

Other quickstart options for YOLOv5 include our Colab Notebook Open In Colab Open In Kaggle, GCP Deep Learning VM, and our Docker image at Docker Hub Docker Pulls. Updated: 21 April 2023.

1. AWS Console Sign-in

Create an account or sign in to the AWS console at https://aws.amazon.com/console/ and select the EC2 service.

Console

2. Launch Instance

In the EC2 section of the AWS console, click the Launch instance button.

Launch

Choose an Amazon Machine Image (AMI)

Enter 'Deep Learning' in the search field and select the most recent Ubuntu Deep Learning AMI (recommended), or an alternative Deep Learning AMI. For more information on selecting an AMI, see Choosing Your DLAMI.

Choose AMI

Select an Instance Type

A GPU instance is recommended for most deep learning purposes. Training new models will be faster on a GPU instance than a CPU instance. Multi-GPU instances or distributed training across multiple instances with GPUs can offer sub-linear scaling. To set up distributed training, see Distributed Training.

Note: The size of your model should be a factor in selecting an instance. If your model exceeds an instance's available RAM, select a different instance type with enough memory for your application.

Refer to EC2 Instance Types and choose Accelerated Computing to see the different GPU instance options.

Choose Type

For more information on GPU monitoring and optimization, see GPU Monitoring and Optimization. For pricing, see On-Demand Pricing and Spot Pricing.

Configure Instance Details

Amazon EC2 Spot Instances let you take advantage of unused EC2 capacity in the AWS cloud. Spot Instances are available at up to a 70% discount compared to On-Demand prices. We recommend a persistent spot instance, which will save your data and restart automatically when spot instance availability returns after spot instance termination. For full-price On-Demand instances, leave these settings at their default values.

Spot Request

Complete Steps 4-7 to finalize your instance hardware and security settings, and then launch the instance.

3. Connect to Instance

Select the checkbox next to your running instance, and then click Connect. Copy and paste the SSH terminal command into a terminal of your choice to connect to your instance.

Connect

4. Run YOLOv5

Once you have logged in to your instance, clone the repository and install the dependencies in a Python>=3.7.0 environment, including PyTorch>=1.7. Models and datasets download automatically from the latest YOLOv5 release.

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Then, start training, testing, detecting, and exporting YOLOv5 models:

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

Optional Extras

Add 64GB of swap memory (to --cache large datasets):

sudo fallocate -l 64G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h  # check memory

Now you have successfully set up and run YOLOv5 on an AWS Deep Learning instance. Enjoy training, testing, and deploying your object detection models!