Hello everyone! I experience a problem with pytorch can’t see cuda. Can someone give any suggestions, how to make it work properly? I’m quite new to pytorch.
OS: Windows 10
import torch
print(torch.backends.cudnn.enabled)
>> True
print(torch.cuda.is_available())
>> False
!python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A
OS: Microsoft Windows 10 Pro
GCC version: (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 7.2.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A
Python version: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19043-SP0
Is CUDA available: False
CUDA runtime version: 11.7.99
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1080
Nvidia driver version: 516.94
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.20.3
[pip3] numpydoc==1.1.0
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas 1.0 mkl
[conda] cudatoolkit 11.7.0 ha6f8bbd_10 conda-forge
[conda] mkl 2021.4.0 haa95532_640
[conda] mkl-service 2.4.0 py39h2bbff1b_0
[conda] mkl_fft 1.3.1 py39h277e83a_0
[conda] mkl_random 1.2.2 py39hf11a4ad_0
[conda] numpy 1.20.3 py39ha4e8547_0
[conda] numpy-base 1.20.3 py39hc2deb75_0
[conda] numpydoc 1.1.0 pyhd3eb1b0_1
[conda] pytorch 1.12.1 py3.9_cpu_0 pytorch
[conda] pytorch-mutex 1.0 cpu pytorch
[conda] torch 1.12.1 pypi_0 pypi
[conda] torchaudio 0.12.1 py39_cpu pytorch
[conda] torchvision 0.13.1 pypi_0 pypi
nvidia-smi
Fri Aug 12 12:08:31 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 516.94 Driver Version: 516.94 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| 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 |
| N/A 56C P8 12W / N/A | 463MiB / 8192MiB | 2% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 9436 C+G C:\Windows\explorer.exe N/A |
| 0 N/A N/A 9960 C+G ...icrosoft VS Code\Code.exe N/A |
| 0 N/A N/A 10480 C+G ...artMenuExperienceHost.exe N/A |
| 0 N/A N/A 11668 C+G ...5n1h2txyewy\SearchApp.exe N/A |
| 0 N/A N/A 13736 C+G ...e\PhoneExperienceHost.exe N/A |
| 0 N/A N/A 14156 C+G ...2txyewy\TextInputHost.exe N/A |
| 0 N/A N/A 14476 C+G ...me\Application\chrome.exe N/A |
| 0 N/A N/A 14560 C+G ...lPanel\SystemSettings.exe N/A |
+-----------------------------------------------------------------------------+
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:59:34_Pacific_Daylight_Time_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0
Are you pointing to the right cuda install? On Linux you get issues emerging from not setting your environment variables to use the correct cuda installs, there might be an equivalent behavior on Windows.
What GPU do you have? Can you check your current cuda driver to make sure it supports running cuda 11.7? (you can do this via the nvidia-smi command)
@Rhinestone Was this ever resolved?
I have this same exact issue even though all the dependencies are met. I installed pytorch using the following command (which I got from the pytorch installation website here:
>> python3.8 -c 'import torch; print(torch.backends.cudnn.enabled)'
True
>> python3.8 -c 'import torch; print(torch.cuda.is_available())'
/path_to/myenv/lib/python3.8/site-packages/torch/cuda/__init__.py:88: UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at /opt/conda/conda-bld/pytorch_1666642975312/work/c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
Some useful command outputs:
>> nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.57 Driver Version: 515.57 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA A100 80G... Off | 00000000:CA:00.0 Off | On |
| N/A 38C P0 65W / 300W | 0MiB / 81920MiB | N/A Default |
| | | Enabled |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| MIG devices: |
+------------------+----------------------+-----------+-----------------------+
| GPU GI CI MIG | Memory-Usage | Vol| Shared |
| ID ID Dev | BAR1-Usage | SM Unc| CE ENC DEC OFA JPG|
| | | ECC| |
|==================+======================+===========+=======================|
| No MIG devices found |
+-----------------------------------------------------------------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
>> nvcc -V
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0
Finally:
>> python3.8 -m torch.utils.collect_env
Collecting environment information...
/path_to/myenv/lib/python3.8/site-packages/torch/cuda/__init__.py:88: UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at /opt/conda/conda-bld/pytorch_1666642975312/work/c10/cuda/CUDAFunctions.cpp:109.)
return torch._C._cuda_getDeviceCount() > 0
PyTorch version: 1.13.0
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A
OS: Scientific Linux release 7.9 (Nitrogen) (x86_64)
GCC version: (GCC) 6.3.0
Clang version: Could not collect
CMake version: version 2.8.12.2
Libc version: glibc-2.17
Python version: 3.8.5 | packaged by conda-forge | (default, Sep 24 2020, 16:55:52) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-3.10.0-1160.76.1.el7.x86_64-x86_64-with-glibc2.10
Is CUDA available: False
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA A100 80GB PCIe
Nvidia driver version: 515.57
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Versions of relevant libraries:
[pip3] numpy==1.23.4
[pip3] torch==1.13.0
[pip3] torchaudio==0.13.0
[pip3] torchvision==0.14.0
[conda] blas 1.0 mkl
[conda] ffmpeg 4.3 hf484d3e_0 pytorch
[conda] mkl 2021.4.0 h06a4308_640
[conda] mkl-service 2.4.0 py38h7f8727e_0
[conda] mkl_fft 1.3.1 py38hd3c417c_0
[conda] mkl_random 1.2.2 py38h51133e4_0
[conda] numpy 1.23.4 py38h14f4228_0
[conda] numpy-base 1.23.4 py38h31eccc5_0
[conda] pytorch 1.13.0 py3.8_cuda11.7_cudnn8.5.0_0 pytorch
[conda] pytorch-cuda 11.7 h67b0de4_0 pytorch
[conda] pytorch-mutex 1.0 cuda pytorch
[conda] torchaudio 0.13.0 py38_cu117 pytorch
[conda] torchvision 0.14.0 py38_cu117 pytorch
Looks like you are running Linux. It might be a NVIDIA linux driver issue. Sometimes after the driver is updated, PyTorch may run into issues with the new driver. It might be redundant as you might have tried this already, have you restarted your machine after running an update packages command? Another thing to explore might be to downgrade the NVIDIA driver or PyTorch (if you have updated either of these) and see if the problem persists. Regards.
I just wanted to point this out as it doesn’t seem you’ve created any MIG devices.
Generally, MIG will work, but you would have to stick to the user guide and create the desired devices etc.
I tried that and I got this error:
File “”, line 1, in
File “C:\Users\Valerio Cadura\AppData\Roaming\Python\Python310\site-packages\torch\cuda_init_.py”, line 239, in _lazy_init
raise AssertionError(“Torch not compiled with CUDA enabled”)
AssertionError: Torch not compiled with CUDA enabled