Skip to content
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

How to use my GPU GeForce 920M with YoloV5 #13400

Open
1 of 2 tasks
henriquerubio opened this issue Nov 5, 2024 · 9 comments
Open
1 of 2 tasks

How to use my GPU GeForce 920M with YoloV5 #13400

henriquerubio opened this issue Nov 5, 2024 · 9 comments
Labels
bug Something isn't working dependencies Dependencies and packages detect Object Detection issues, PR's

Comments

@henriquerubio
Copy link

henriquerubio commented Nov 5, 2024

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

No response

Bug

Hi, I have a GPU GeForce 920M, but I can't use it. I can run inference with CPU, but it doesn't woork with my GPU.

python detect.py --weights yolov5s.pt --source 0 --device cpu --> works well (image "cpu")
python detect.py --weights yolov5s.pt --source 0 --> ERROR (described bellow) (image "gpu")

  • I have a GPU GeForce 920m, with 425.31 driver version (25.21.14.2531).
  • The most up-to-date version of the "CUDA compatible with my driver is the version: CUDA 10.1 (https://docs.nvidia.com/deploy/cuda-compatibility)
  • To install the "CUDA 10.1 I need Microsoft Visual Studio 2017. Installed!

All required packages are up to date, according to the "Requirements.TXT" from Yolov5 ("Requirements" and "Piplist" images)
When I test the cuda and the GPU it seems to me to be right (image "cuda-test")

Do you think the current versions of Pytorch and Torchvision are incorrectly with GeForce 920m? Should I try to reinstall the Pytorch and Cuda?
I think if I try to execute Yolov5 with a version of Pytorch that is best suited for older GPUs, such as Pytorch 1.7 or 1.6 (which may be more compatible with my GPU), I will have to change yolo version to one Lower version than yolov5, right? I say this because in the "Requirements" is said "Torch> = 1.8.0"

IMAGES:
"cpu"
cpu

"gpu"
gpu

"yolov5requirements"
yolov5requirements

"pip list"
pip list

"NVIDIA-SMI"
NVIDIA-SMI

"cuda-test"
cuda-test

Environment

  • YOLOv5
  • Windows 10
  • opencv-python: 4.10.0.84
  • torch: 1.8.0+cu101
  • torchvision: 0.9.0+cu101
  • Python 3.9.5
  • CUDA 10.1

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@henriquerubio henriquerubio added the bug Something isn't working label Nov 5, 2024
@UltralyticsAssistant UltralyticsAssistant added dependencies Dependencies and packages detect Object Detection issues, PR's labels Nov 5, 2024
@henriquerubio henriquerubio changed the title How to use my GPU with YoloV5 How to use my GPU GeForce 920M with YoloV5 Nov 5, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @henriquerubio, thank you for reaching out and your interest in YOLOv5 🚀! It seems you're having some issues using your GPU with YOLOv5.

To help us diagnose the problem, please make sure to provide a minimum reproducible example of your setup. You have already included some useful details about your environment and driver versions. This information is very helpful for us to understand what's happening. Additionally, ensure that all requirements are satisfied and compatible with your hardware.

For a quick check, ensure your GPU drivers and CUDA installation are correctly set up for your GPU model, and that your installed version of PyTorch supports CUDA 10.1. Remember that compatibility among these components is crucial for proper GPU utilization.

Our team is currently looking into this, and an Ultralytics engineer will assist you soon. In the meantime, please double-check the compatibility notes and keep sharing any additional context that might help us pinpoint the issue. Having a few more details or clarifications could expedite the resolution. 😊

Stay tuned!

@henriquerubio
Copy link
Author

GPU drivers and CUDA installation are correctly set up for my GPU model.

@pderrenger
Copy link
Member

Thank you for confirming your setup. Please ensure you're using the latest YOLOv5 version and verify if the issue persists. If the problem continues, consider testing with a different PyTorch version that supports your CUDA setup.

@henriquerubio
Copy link
Author

Thank you.
Yes I tried with the latest YOLOv5, but it didn't work. And it also requires torch>=1.8.0.
I read that maybe my CPU could wokr just with max torch: 1.7.1. So I also tried with the YOLOv5 v5.0. But it's the same error:
RuntimeError: CUDA error: no kernel image is available for execution on the device

How can I know wich PyTorch version supports my GPU and CUDA setup?

@pderrenger
Copy link
Member

To determine the compatible PyTorch version for your GPU and CUDA setup, refer to the official PyTorch installation guide at https://pytorch.org/get-started/previous-versions/. This resource provides detailed compatibility information for various CUDA versions and PyTorch releases.

@henriquerubio
Copy link
Author

henriquerubio commented Nov 6, 2024

Ok, before making this post, I followed this page you mentioned https://pytorch.org/get-started/previous-versions/
In it we have: For CUDA 10.1 this website recommends versions<=Pytorch v1.8.1.

CUDA 10.1
pip install torch==1.8.1+cu101 torchvision==0.9.1+cu101 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.1 -c pytorch
and soo on...

But how can I know wich PyTorch version supports my GPU and CUDA setup?

@pderrenger
Copy link
Member

To determine which PyTorch version supports your GPU and CUDA setup, refer to the compatibility table on the PyTorch website you mentioned. It lists the PyTorch versions compatible with specific CUDA versions. For your GeForce 920M with CUDA 10.1, try using PyTorch 1.7.1 or 1.8.1 as suggested, and ensure your GPU drivers are up to date.

@henriquerubio
Copy link
Author

Ok I found the origin of the problem:
The PyTorch team decided not to include support for compute capabilities below 3.7 in the standard builds starting from version 1.3 in order to optimize performance and the size of the binaries. Supporting older compute capabilities involves including CUDA kernels for various versions, which increases compilation time and the size of the final binary, as well as potentially limiting optimizations aimed at more modern architectures:
https://discuss.pytorch.org/t/minimum-cuda-compute-compatibility-for-pytorch-1-3/60794

Starting from version 1.3 of PyTorch, the pre-compiled binaries are no longer optimized for GPUs with a compute capability lower than 3.7. This includes older models, such as the Tesla K40c, which has a compute capability of 3.5. In practice, this means that when installing PyTorch from the official binaries, the code will not be compatible with older GPUs, resulting in the error:

RuntimeError: CUDA error: no kernel image is available for execution on the device

This error occurs because PyTorch cannot find a compatible "image" (CUDA binary kernel) with the GPU's compute capability, preventing the execution of the code.

Solution: Compile PyTorch from Source Code:
For users with older GPUs (such as the GeForce 920M with compute capability 3.5), it is possible to compile PyTorch from source code by manually configuring it to support the desired compute capability.

@pderrenger
Copy link
Member

Thank you for identifying the issue. Compiling PyTorch from source with support for your GPU's compute capability is indeed a viable solution. You can follow the PyTorch from source guide to customize the build for your GeForce 920M.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Dependencies and packages detect Object Detection issues, PR's
Projects
None yet
Development

No branches or pull requests

3 participants