ultralytics / yolov5

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

CUDA is out of memory runtime error #4562

Closed sonyta29 closed 3 years ago

sonyta29 commented 3 years ago

❔Question

I'm trying to evaluate the performance of yolov5s trained on costum dataset using val.py but i'm getting this error : CUDA out of memory ( when evaluating the yolov5s trained on the coco dataset i'm not getting this error) I tried this solution https://stackoverflow.com/questions/59129812/how-to-avoid-cuda-out-of-memory-in-pytorch but it didn't work

I'll be grateful for anyone who can help or suggests a working solution for this issue

github-actions[bot] commented 3 years ago

πŸ‘‹ Hello @sonyta29, 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://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ 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), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@sonyta29 πŸ‘‹ Hello! Thanks for asking about CUDA memory issues. YOLOv5 πŸš€ can be trained on CPU, single-GPU, or multi-GPU. When training on GPU it is important to keep your batch-size small enough that you do not use all of your GPU memory, otherwise you will see a CUDA Out Of Memory (OOM) Error and your training will crash. You can observe your CUDA memory utilization using either the nvidia-smi command or by viewing your console output:

Screenshot 2021-05-28 at 12 19 51

If you encounter a CUDA OOM error, the steps you can take to reduce your memory usage are:

sonyta29 commented 3 years ago

@glenn-jocher Thank you for replying and explaining this issue... I already trained the yolov5s on Google Colab and then i have just downloaded the trained weights... by running the val.py with -- weights (my_custom_weights).pt make this problem.

I'm going to follow the reducing memory usage steps that you've mentioned. Thank you !

github-actions[bot] commented 3 years ago

πŸ‘‹ Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 πŸš€ resources:

Access additional Ultralytics ⚑ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐!

twn29004 commented 2 years ago

hello, have you slove your problem?