-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPU Memory Usage during Tensor Inference #8719
Comments
👋 Hello @M1keStr0ng, 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 support@ultralytics.com. RequirementsPython>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. |
@M1keStr0ng 👋 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 CUDA Out of Memory SolutionsIf you encounter a CUDA OOM error, the steps you can take to reduce your memory usage are:
AutoBatchYou can use YOLOv5 AutoBatch (NEW) to find the best batch size for your training by passing Good luck 🍀 and let us know if you have any other questions! |
@glenn-jocher Thanks for replying. I know this tutorial and it is for training. My issue is about inference GPU memory usage. During inference, I check the batch is 1, model is .pt --> .engine, image is 640, source is Webcam/RTSP/Video, and decrease width_multiple in yolov5.yaml. What I would like to ask is how can I further decrease GPU Memory during inference, because I need to run multiple yolov5 models in one GPU card (cannot upgrade GPU). The thing is I decreased width_multiple and it did decrease the model size, but GPU memory usage is almost kept the same during reference. REALLY needs your generous help, thanks! |
@M1keStr0ng I don't have any quantifiable information on inference memory, but I'd assume smaller models, image sizes and batch sizes would correlate to reduced requirements. |
I'm facing a similar issue. When I run an inference on GPU, the memory usage keeps growing and leads to "RuntimeError: CUDA out of memory. " after only 3 or 4 images being processed. |
Since you are talking about inference, I will skip training part. Your situation never happens my here, but I might provide some checks:
|
👋 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 ⭐! |
@K-YLMike Those are great suggestions. Have you tried using smaller model sizes, batch sizes, or image sizes for inference to see if there's any change in GPU memory usage? If you're using your own custom inference scripts, I'd recommend comparing your implementation to the standard |
Search before asking
Question
Hi Sir, thanks for providing amazing codes! Now I am almost familiar with how to make own dataset, training with all -- commands, inference, and deploy in TensorRT. The question is no matter I use n/s/m model, or edit width_multiple: 0.50 to 0.25 even less in yolov5_custom.yaml, or change --img from 640 to 320,finally I turn these pt models to tensorRT, the GPU memory usages are always larger than 1700 Mib in nvidia-smi (even file size of pt can be 1.6 mb which is far smaller than 14.4 mb yolov5s.engine). Could you tell me how to further decrease GPU memory usage during inference in tensorRT?
Additional
No response
The text was updated successfully, but these errors were encountered: