Open tjasmin111 opened 2 weeks ago
Hello! Thanks for reaching out with the comprehensive details. It seems like a PyTorch-specific issue concerning GPU initialization when running the YOLOv8 model.
As a quick workaround, you might want to try explicitly setting the CUDA-visible devices before launching your script to ensure it’s detecting the right GPU index. Here's how you can set it via the command line:
export CUDA_VISIBLE_DEVICES=0
yolo detect predict model=yolov8n.pt source='your_image_or_video.jpg' device=0
This environment variable tells PyTorch to use only the specified GPU. Adjust the CUDA_VISIBLE_DEVICES
index based on your environment (0
for the first GPU, 1
for the second, etc.).
If the error persists, make sure all your packages are up-to-date, especially torch
and cuda
, as sometimes mismatches can cause such issues. A reinstall or update may help:
pip install torch torchvision --upgrade
Please let us know if this helps or if you need further assistance! 😊
Search before asking
Question
When I'm trying to use PyTorch with YOLOv8 with
yolo detect predict ... device=0
, I'm getting this error:RuntimeError: device >= 0 && device < num_gpus INTERNAL ASSERT FAILED at "../aten/src/ATen/cuda/CUDAContext.cpp":50, please report a bug to PyTorch. device=, num_gpus=
But outputs of PyTorch usage and GPU availability as shown below looks good though.
What is the problem? How to fix it?
Some pytorch outputs:
Full stack trace:
Additional
No response