ahrm / UnstableFusion

A Stable Diffusion desktop frontend with inpainting, img2img and more!
GNU General Public License v3.0
1.26k stars 86 forks source link

Any prompt "Torch not compiled with CUDA enabled" #29

Open ffdown opened 2 years ago

ffdown commented 2 years ago

Fetching 16 files: 100%|█████████████████████████████████████████████████████████████| 16/16 [00:00<00:00, 3181.27it/s] Traceback (most recent call last): File "unstablefusion.py", line 889, in handle_inpaint_button inpainted_image = self.get_handler().inpaint(prompt, File "unstablefusion.py", line 436, in get_handler return self.stable_diffusion_manager.get_handler() File "unstablefusion.py", line 318, in get_handler return self.get_local_handler(self.get_huggingface_token()) File "unstablefusion.py", line 301, in get_local_handler self.cached_local_handler = StableDiffusionHandler(token) File "E:\AI\SD\SDUI\UnstableFusion-main\diffusionserver.py", line 27, in init self.text2img = StableDiffusionPipeline.from_pretrained( File "e:\Anaconda3\envs\ldm\lib\site-packages\diffusers\pipeline_utils.py", line 179, in to module.to(torch_device) File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 907, in to return self._apply(convert) File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply module._apply(fn) File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply module._apply(fn) File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply module._apply(fn) [Previous line repeated 1 more time] File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 601, in _apply param_applied = fn(param) File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 905, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "e:\Anaconda3\envs\ldm\lib\site-packages\torch\cuda__init__.py", line 210, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

ahrm commented 2 years ago

As the title suggests, you need to install pytorch with cuda enabled (after installing cuda itself of course).

ffdown commented 2 years ago

cuda installed, pytorch too... I don't understand anything( automatic111 works fine

ahrm commented 2 years ago

It is not enough for pytorch and cuda to be installed. You need to install the cuda version of pytorch. Automatic111 creates its own virtual environment, so it doesn't affect your global python installation.

ffdown commented 2 years ago

command for conda please, anyone combination not work

Kamekos commented 2 years ago

I have the exact same issue, it's saddening that no ones is helping https://www.youtube.com/watch?v=GMSjDTU8Zlc&list=LL&index=1 (followed this tutorial to install Pytorch's Cuda)

I have cuda, pytorch, and the Pytorch's version of cuda installed, and yet I run into the exact same issue

raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

ahrm commented 2 years ago

In order to test if you have pytorch with cuda available, you can run the python command and then enter:

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

Note that the tutorial video that you linked creates a virtual environment, so you only have torch within that virtual environment.

Kamekos commented 2 years ago

In order to test if you have pytorch with cuda available, you can run the python command and then enter:

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

Note that the tutorial video that you linked creates a virtual environment, so you only have torch within that virtual environment.

Oh my bad, it's indeed telling me that cuda isn't installed while running this command

How do you install cuda for pytorch that can be used anywhere ?

ahrm commented 2 years ago

Don't create a new environment, install it globally, or alternatively you can switch to the environment that you created in visual studio and presumably already has torch installed.

Kamekos commented 2 years ago

I've just installed it globally, and I still run into the same issue, it appears fine in the pip list command too

Kamekos commented 2 years ago

Ok so I've just found out I had the cpu version installed while running the print(torch.version) command for whatever reason, I will try uninstalling it and re install the gpu one

calebrader commented 1 year ago

It is not enough for pytorch and cuda to be installed. You need to install the cuda version of pytorch. Automatic111 creates its own virtual environment, so it doesn't affect your global python installation.

How do you do that? Please give pip or conda examples.