ultralytics / ultralytics

NEW - YOLOv8 🚀 in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
25.74k stars 5.13k forks source link

How to run YOLOv8 predict on GPU without CUDA? #13033

Open dy113g opened 1 month ago

dy113g commented 1 month ago

Search before asking

Question

I'd like to run YOLOv8.2 training and prediction models but without the use of CUDA. I have tried setting the device to GPU but I keep getting an attribute error. It's using CPU by default. How can I give it access to GPU but without CUDA?

image

image

image

Additional

No response

github-actions[bot] commented 1 month ago

👋 Hello @dy113g, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

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

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 1 month ago

@dy113g hello! 👋

To run YOLOv8 on a GPU without using CUDA, you can utilize the MPS (Metal Performance Shaders) backend if you're on an Apple device with an M1 or M2 chip. Here's how you can specify the device as 'mps' in your code:

from ultralytics import YOLO

# Load your model
model = YOLO('yolov8n.pt')

# Set the device to MPS for Apple Silicon
results = model.predict('path/to/image.jpg', device='mps')

This will allow you to leverage the GPU capabilities of Apple Silicon without needing CUDA. If you're not on an Apple device, running YOLOv8 on a GPU generally requires CUDA as it relies on NVIDIA's GPU architecture.

Let me know if this helps or if you have any other questions!

github-actions[bot] commented 1 week ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

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 YOLO 🚀 and Vision AI ⭐