I’m trying to use my GPU to run the YOLOR model, and I keep getting the error that CUDA is unavailable, not sure how to fix.
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 availablity
AssertionError: CUDA unavailable, invalid device 0 requested

When I check CUDA availability with:
py
>>import torch
>>print(torch.cuda.is_available())

I get False, which explains the problem. I tried running the command:
py -m pip install --user torch==1.9.0+cu111 torchvision==0.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 driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:41:42_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0

Additionally, torch.version.cuda gives None.
Running nvidia-smi, I get:
Wed Jul 28 22:42:06 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 471.41       Driver Version: 471.41       CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  On |                  N/A |
| 39%   36C    P5    17W / 215W |   1533MiB /  8192MiB |      3%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1396    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A      2940    C+G   Insufficient Permissions        N/A      |
|    0   N/A  N/A      4812    C+G   ...obeNotificationClient.exe    N/A      |
|    0   N/A  N/A      4876    C+G   ...Roaming\Zoom\bin\Zoom.exe    N/A      |
|    0   N/A  N/A      5200    C+G   ...\app-1.0.9002\Discord.exe    N/A      |
|    0   N/A  N/A      7256    C+G   ...Container\nvcontainer.exe    N/A      |
|    0   N/A  N/A      7876    C+G   C:\Windows\explorer.exe         N/A      |
|    0   N/A  N/A      9944    C+G   ...ekyb3d8bbwe\YourPhone.exe    N/A      |
|    0   N/A  N/A     10692    C+G   ...t\Teams\current\Teams.exe    N/A      |
|    0   N/A  N/A     10988    C+G   ...zilla Firefox\firefox.exe    N/A      |
|    0   N/A  N/A     11636    C+G   ...perience\NVIDIA Share.exe    N/A      |
|    0   N/A  N/A     11948    C+G   ...perience\NVIDIA Share.exe    N/A      |
|    0   N/A  N/A     13396    C+G   ...lication\WebCompanion.exe    N/A      |
|    0   N/A  N/A     14028    C+G   ...w5n1h2txyewy\SearchUI.exe    N/A      |
|    0   N/A  N/A     14060    C+G   ...zilla Firefox\firefox.exe    N/A      |
|    0   N/A  N/A     14664    C+G   ...les\NZXT CAM\NZXT CAM.exe    N/A      |
|    0   N/A  N/A     15760    C+G   ...t\Teams\current\Teams.exe    N/A      |
|    0   N/A  N/A     17764    C+G   ...bbwe\Microsoft.Photos.exe    N/A      |
|    0   N/A  N/A     18328    C+G   ...icrosoft VS Code\Code.exe    N/A      |
|    0   N/A  N/A     18896    C+G   ...es.TextInput.InputApp.exe    N/A      |
|    0   N/A  N/A     23256    C+G   ...y\ShellExperienceHost.exe    N/A      |
+-----------------------------------------------------------------------------+

Thus, I’m not really sure what the issue is, or how to fix it. Please help!