Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

How to Fix "AssertionError: CUDA unavailable, invalid device 0 requested"

$
0
0

I'm trying to use my GPU to run the YOLOR model, and I keep getting the error:

Traceback (most recent call last):  File "D:\yolor\detect.py", line 198, in <module>    detect()  File "D:\yolor\detect.py", line 41, in detect    device = select_device(opt.device)  File "D:\yolor\utils\torch_utils.py", line 47, in select_device    assert torch.cuda.is_available(), 'CUDA unavailable, invalid device %s requested' % device  # check availablityAssertionError: CUDA unavailable, invalid device 0 requested

When I try to check if CUDA is available with the following:

python3>>import torch>>print(torch.cuda.is_available())

I get False, which explains the problem. I tried running the command

py -m pip install torch1.9.0+cu111 torchvision0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

I get the error: ERROR: Invalid requirement: 'torch1.9.0+cu111'

Running nvcc --version, I get:

nvcc: NVIDIA (R) Cuda compiler driverCopyright (c) 2005-2021 NVIDIA CorporationBuilt on Mon_May__3_19:41:42_Pacific_Daylight_Time_2021Cuda compilation tools, release 11.3, V11.3.109Build cuda_11.3.r11.3/compiler.29920130_0

Thus, I'm not really sure what the issue is, or how to fix it.

EDIT: As @Ivan pointed out, I added the == sign, but still get False when checking if CUDA is available.


Viewing all articles
Browse latest Browse all 23160

Trending Articles