stable-diffusion icon indicating copy to clipboard operation
stable-diffusion copied to clipboard

CUDA driver initialization failed, you might not have a CUDA gpu.

Open MojoJojo43 opened this issue 1 year ago • 9 comments

Hi, I'm new to all of this so please bear with me.

When I run nvidia-smi in conda to see if cuda is installed, I get back:

NVIDIA-SMI 426.78 Driver Version: 426.78 CUDA Version: 10.1

However I keep receiving the,

RuntimeError: CUDA driver initialization failed, you might not have a CUDA gpu.

whenever I try to run Diffusion.

I was thinking that since the environment was downloading the cudatoolkit version 11.3 (or something) that maybe my version of cuda isn't sufficient enough. Like I said, no idea what I am talking about so hopefully someone much smarter will be able to glean something from this :-)

UPDATE

I checked the cuda toolkit version with the nvcc -V command and it says:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:24:09_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0

So I am not sure why it still says I might not have a cuda GPU.

MojoJojo43 avatar Aug 25 '22 19:08 MojoJojo43

What happens if you run:

import torch
print(torch.cuda.is_available())
print(torch.__version__)

patrickvonplaten avatar Aug 29 '22 09:08 patrickvonplaten

Same issue here, everything including torch check is here:

  File "scripts/txt2img.py", line 346, in <module>
    main()
  File "scripts/txt2img.py", line 242, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 65, in load_model_from_config
    model.cuda()
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/pytorch_lightning/core/mixins/device_dtype_mixin.py", line 127, in cuda
    return super().cuda(device=device)
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 578, in _apply
    module._apply(fn)
  [Previous line repeated 1 more time]
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 601, in _apply
    param_applied = fn(param)
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/nn/modules/module.py", line 688, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py", line 216, in _lazy_init
    torch._C._cuda_init()
RuntimeError: CUDA driver initialization failed, you might not have a CUDA gpu.
(ldm) [centos@ip-20-0-4-157 stable-diffusion]$ nvidia-smi
Mon Sep  5 20:06:40 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.33.01    Driver Version: 440.33.01    CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla T4            Off  | 00000000:00:1E.0 Off |                    0 |
| N/A   48C    P0    27W /  70W |   1468MiB / 15109MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     22218      C   ...ntos/miniconda3/envs/my_env/bin/python3  1457MiB |
+-----------------------------------------------------------------------------+
(ldm) [centos@ip-20-0-4-157 stable-diffusion]$ python
Python 3.8.5 (default, Sep  4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
/home/centos/miniconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py:82: UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at  /opt/conda/conda-bld/pytorch_1646755903507/work/c10/cuda/CUDAFunctions.cpp:112.)
  return torch._C._cuda_getDeviceCount() > 0
False
>>> print(torch.__version__)
1.11.0
>>>```

Herobring avatar Sep 05 '22 20:09 Herobring

Found the solution, works for me: `conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

Herobring avatar Sep 05 '22 21:09 Herobring

Found the solution, works for me: `conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

it works!

re0phimes avatar Sep 11 '22 16:09 re0phimes

I'm getting the following error after installing the said cuda toolkit:

cannot import name 'PILLOW_VERSION' from 'PIL'

Please help.

AvirupJU avatar Nov 02 '22 05:11 AvirupJU

I'm getting the following error after installing the said cuda toolkit:

cannot import name 'PILLOW_VERSION' from 'PIL'

Please help.

me too

DUWENINK avatar Nov 22 '22 02:11 DUWENINK

I'm getting the following error after installing the said cuda toolkit:

cannot import name 'PILLOW_VERSION' from 'PIL'

Please help.

me too

getting the same error

AntouanK avatar Dec 06 '22 12:12 AntouanK

this is what I did to solve it

pip install "pillow<7"

AntouanK avatar Dec 06 '22 12:12 AntouanK

Found the solution, works for me: `conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

it works! Hi, Have you gotten it working? I am having the same issue but unsure what to do with it?

Thanks!

lishipu123 avatar Apr 26 '24 07:04 lishipu123