ultralytics / yolov5

YOLOv5 šŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.11k stars 16.42k forks source link

Amazon Web Services (AWS) Quickstart Tutorial #2084

Open glenn-jocher opened 3 years ago

glenn-jocher commented 3 years ago

This quickstart guide helps new users run YOLOv5 šŸš€ on an Amazon Web Services (AWS) Deep Learning instance ā­. AWS offers a Free Tier and a credit program to get started quickly and affordably. Other quickstart options for YOLOv5 include our Colab Notebook Open In Colab, GCP Deep Learning VM and our Docker image at https://hub.docker.com/r/ultralytics/yolov5 Docker Pulls.

1. Console Sign-in

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

Console

2. Launch Instance

In the EC2 part 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 select an alternative Deep Learning AMI. See Choosing Your DLAMI for more information on selecting an AMI.

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. You can scale sub-linearly when you have multi-GPU instances or if you use distributed training across many instances with GPUs. To set up distributed training, seeĀ Distrbuted 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.

Check outĀ EC2 Instance TypesĀ and choose Accelerated Computing to see the different GPU instance options.

Choose Type

DLAMI instances provide tooling to monitor and optimize your GPU processes. For more information on overseeing your GPU processes, 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 to 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 check box next to your running instance, and then click connect. You can copy 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 this repo and install requirements.txt dependencies, including Python>=3.8 and PyTorch>=1.7.

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

Then get started training, testing and detecting!

$ python train.py  # train a model
$ python test.py --weights yolov5s.pt  # test a model for Precision, Recall and mAP
$ python detect.py --weights yolov5s.pt --source path/to/images  # run inference on images and videos

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
github-actions[bot] commented 3 years ago

šŸ‘‹ Hello @glenn-jocher, thank you for your interest in šŸš€ YOLOv5! Please visit our ā­ļø Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a šŸ› Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ā“ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

ghost commented 2 years ago

Hello, Thank you for this tutoriel, I'm using [Amazon EC2 P2 Instances], but the training is being done on CPU instead of GPU, I've activated the Pytorch environment,but the issue is still the same,can you help me with this please ?

glenn-jocher commented 1 year ago

@ghost hello,

Make sure you have PyTorch installed with GPU support (torch.cuda.is_available()) and that your pytorch version matches your CUDA version. If that's the case, try adding --device 0 when running train.py to ensure training on the GPU.

For any additional issues, please consult the Ultralytics YOLOv5 documentation.

Best of luck!