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

AssertionError: CUDA unavailable, invalid device 0 requested #474

Closed
yancccc opened this issue Jul 22, 2020 · 15 comments
Closed

AssertionError: CUDA unavailable, invalid device 0 requested #474

yancccc opened this issue Jul 22, 2020 · 15 comments
Labels
question Further information is requested Stale

Comments

@yancccc
Copy link

yancccc commented Jul 22, 2020

~/yolov5-master$ python detect.py --source ./inference/images/ --weights yolov5s.pt --conf 0.4 --device 0
Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.4, device='0', img_size=640, iou_thres=0.5, output='inference/output', save_txt=False, source='./inference/images/', update=False, view_img=False, weights=['yolov5s.pt'])
False
Traceback (most recent call last):
File "detect.py", line 161, in
detect()
File "detect.py", line 16, in detect
device = torch_utils.select_device(opt.device)
File "/home/ycc/yolov5-master/utils/torch_utils.py", line 33, in select_device
assert torch.cuda.is_available(), 'CUDA unavailable, invalid device %s requested' % device # check availablity
AssertionError: CUDA unavailable, invalid device 0 requested

@yancccc yancccc added the question Further information is requested label Jul 22, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2020

Hello @yancccc, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

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 model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@NanoCode012
Copy link
Contributor

Check that you have CUDA installed
“nvcc -V”

@yancccc
Copy link
Author

yancccc commented Jul 23, 2020

Check that you have CUDA installed
“nvcc -V”
The environment is configured, and yolov4 can work normally

@yancccc
Copy link
Author

yancccc commented Jul 23, 2020

ycc@ycc:~/yolov5-master$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

@glenn-jocher
Copy link
Member

glenn-jocher commented Jul 23, 2020

@yancccc it appears you have environment problems. In order to run YOLOv5 correctly your environment must meet the minimum version requirements for the dependencies described in https://github.com/ultralytics/yolov5#requirements. You can either update your local environment to bring it into compliance or you can use one of our verified environment options below.

Reproduce Our Environment

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

@dddj969
Copy link

dddj969 commented Jul 27, 2020

@yancccc do you solve the problem ? i meet the same problem

@XiaoXiLe2023
Copy link

I meet the same problem. I used:
print(torch.cuda.device_count())
print(torch.version.cuda)
print(torch.version)
print(torch.cuda.is_available())
to check.

got
0
10.2
1.5.1
False

@XiaoXiLe2023
Copy link

ycc@ycc:~/yolov5-master$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

maybe you can try
pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html

@rohanbanerjee
Copy link

@Myhuang1996 's solution solved the issue in my case!

@DeepAndy
Copy link

try the latest pytorch + correct version of cuda:
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@caozhiwei1994
Copy link

Pytorch1.6 supports CUDA 9.2, 10.1 and 10.2. I update the version of CUDA,yolov5 can work.

@AxleCode
Copy link

AxleCode commented Apr 8, 2022

ycc@ycc:~/yolov5-master$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

maybe you can try pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html

PS D:\Kuliah\Yolov5\yolov5-master> nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:36:24_Pacific_Standard_Time_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0

i used cuda 11.6 what version torch and torchvision must im install?

@shubhambagwari
Copy link

shubhambagwari commented Aug 3, 2022

@DeepAndy

try the latest pytorch + correct version of cuda: pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

Throwing this error now.

Error:

requirements: torch>=1.7.0 not found and is required by YOLOv5, attempting auto-update...
requirements: 'pip install torch>=1.7.0' skipped (offline)
requirements: torchvision>=0.8.1 not found and is required by YOLOv5, attempting auto-update...
requirements: 'pip install torchvision>=0.8.1' skipped (offline)
YOLOv5  2022-7-20 Python-3.7.6 torch-1.6.0+cu101 CUDA:0 (NVIDIA GeForce GTX 1660 Ti, 6144MiB)

@Myhuang1996 facing the same issue. I tried your solution as well.

@glenn-jocher
Copy link
Member

@shubhambagwari you are not meeting requirements and your machine is not online for auto-update to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

10 participants