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

ValueError: Expected a cuda device, but got: cpu

Open l8487 opened this issue 3 years ago • 1 comments

Describe the bug ValueError: Expected a cuda device, but got: cpu only edit the webui-user.bat。 @echo off set PYTHON= set GIT= set VENV_DIR= set COMMANDLINE_ARGS= --precision full --no-half --use-cpu all call webui.bat

Desktop (please complete the following information):

  • OS: Win10
  • Browser Edge
  • Commit revision

Additional context D:\ai\stable-diffusion-webui-master>webui-user.bat Creating venv in directory venv using python "D:\ai\Python310\python.exe" venv "D:\ai\stable-diffusion-webui-master\venv\Scripts\Python.exe" Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] Commit hash: Installing torch and torchvision Installing gfpgan Installing clip Cloning Stable Diffusion into repositories\stable-diffusion... Cloning Taming Transformers into repositories\taming-transformers... Cloning K-diffusion into repositories\k-diffusion... Cloning CodeFormer into repositories\CodeFormer... Cloning BLIP into repositories\BLIP... Installing requirements for CodeFormer Installing requirements for Web UI Launching Web UI with arguments: D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\cuda_init_.py:123: UserWarning: Found GPU0 NVIDIA GeForce GT 730 which is of cuda capability 3.5. PyTorch no longer supports this GPU because it is too old. The minimum cuda capability supported by this library is 3.7.

warnings.warn(old_gpu_warn % (d, name, major, minor, min_arch // 10, min_arch % 10)) No checkpoints found. When searching for checkpoints, looked at:

  • file D:\ai\stable-diffusion-webui-master\model.ckpt
  • directory D:\ai\stable-diffusion-webui-master\models\Stable-diffusion Can't run without a checkpoint. Find and place a .ckpt file into any of those locations. The program will exit. 请按任意键继续. . .

D:\ai\stable-diffusion-webui-master>webui-user.bat venv "D:\ai\stable-diffusion-webui-master\venv\Scripts\Python.exe" Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] Commit hash: Installing requirements for Web UI Launching Web UI with arguments: --use-cpu all --precision full --no-half D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\cuda_init_.py:123: UserWarning: Found GPU0 NVIDIA GeForce GT 730 which is of cuda capability 3.5. PyTorch no longer supports this GPU because it is too old. The minimum cuda capability supported by this library is 3.7.

warnings.warn(old_gpu_warn % (d, name, major, minor, min_arch // 10, min_arch % 10)) Warning: caught exception 'Expected a cuda device, but got: cpu', memory monitor disabled LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Loading weights [925997e9] from D:\ai\stable-diffusion-webui-master\models\Stable-diffusion\animefull-final-pruned.ckpt Applying cross attention optimization (Doggettx). Model loaded. Loaded a total of 0 textual inversion embeddings. Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch(). 0%| | 0/20 [00:00<?, ?it/s] Error completing request Arguments: ('a', '', 'None', 'None', 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 0, 0, 0, False, False, None, '', 1, '', 0, '', True, False, False) {} Traceback (most recent call last): File "D:\ai\stable-diffusion-webui-master\modules\ui.py", line 187, in f res = list(func(*args, **kwargs)) File "D:\ai\stable-diffusion-webui-master\webui.py", line 64, in f res = func(*args, **kwargs) File "D:\ai\stable-diffusion-webui-master\modules\txt2img.py", line 44, in txt2img processed = process_images(p) File "D:\ai\stable-diffusion-webui-master\modules\processing.py", line 408, in process_images samples_ddim = p.sample(conditioning=c, unconditional_conditioning=uc, seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength) File "D:\ai\stable-diffusion-webui-master\modules\processing.py", line 552, in sample samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning) File "D:\ai\stable-diffusion-webui-master\modules\sd_samplers.py", line 409, in sample samples = self.func(self.model_wrap_cfg, x, extra_args={'cond': conditioning, 'uncond': unconditional_conditioning, 'cond_scale': p.cfg_scale}, disable=False, callback=self.callback_state, **extra_params_kwargs) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\k-diffusion\k_diffusion\sampling.py", line 80, in sample_euler_ancestral denoised = model(x, sigmas[i] * s_in, **extra_args) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\modules\sd_samplers.py", line 239, in forward x_out = self.inner_model(x_in, sigma_in, cond=cond_in) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\k-diffusion\k_diffusion\external.py", line 112, in forward eps = self.get_eps(input * c_in, self.sigma_to_t(sigma), **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\k-diffusion\k_diffusion\external.py", line 138, in get_eps return self.inner_model.apply_model(*args, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\models\diffusion\ddpm.py", line 987, in apply_model x_recon = self.model(x_noisy, t, **cond) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\models\diffusion\ddpm.py", line 1410, in forward out = self.diffusion_model(x, t, context=cc) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\diffusionmodules\openaimodel.py", line 732, in forward h = module(h, emb, context) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\diffusionmodules\openaimodel.py", line 85, in forward x = layer(x, context) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\attention.py", line 258, in forward x = block(x, context=context) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\attention.py", line 209, in forward return checkpoint(self._forward, (x, context), self.parameters(), self.checkpoint) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\diffusionmodules\util.py", line 114, in checkpoint return CheckpointFunction.apply(func, len(inputs), *args) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\diffusionmodules\util.py", line 127, in forward output_tensors = ctx.run_function(*ctx.input_tensors) File "D:\ai\stable-diffusion-webui-master\repositories\stable-diffusion\ldm\modules\attention.py", line 212, in _forward x = self.attn1(self.norm1(x)) + x File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "D:\ai\stable-diffusion-webui-master\modules\sd_hijack_optimizations.py", line 79, in split_cross_attention_forward stats = torch.cuda.memory_stats(q.device) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\cuda\memory.py", line 205, in memory_stats stats = memory_stats_as_nested_dict(device=device) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\cuda\memory.py", line 216, in memory_stats_as_nested_dict device = _get_device_index(device, optional=True) File "D:\ai\stable-diffusion-webui-master\venv\lib\site-packages\torch\cuda_utils.py", line 30, in _get_device_index raise ValueError('Expected a cuda device, but got: {}'.format(device)) ValueError: Expected a cuda device, but got: cpu

l8487 avatar Oct 15 '22 12:10 l8487

Holy cow you're trying to run this on a 2 GB GPU. RTFM. Pytorch doesn't support this GPU and refuses to run so defaults to the CPU. Sorry to say this but you aren't going to be able to run this on your computer.

But fear not! Use google colab-> https://colab.research.google.com/drive/1kw3egmSn-KgWsikYvOMjJkVDsPLjEMzl

Everyone tries to run this on their own computer without reading the manual and we keep getting bug reports like this. Request closing this issue.

Cyberes avatar Oct 15 '22 17:10 Cyberes

No support for the Voodoo2 either.

dfaker avatar Oct 17 '22 17:10 dfaker

better way to force CPU only found:

  1. set environment variable CUDA_VISIBLE_DEVICES to -1

  2. parameters to use: --precision full --no-half --use-cpu all --skip-torch-cuda-test

ghost avatar Oct 17 '22 18:10 ghost

better way to force CPU only found

Here's a Windows powershell script to do this:

$ENV:CUDA_VISIBLE_DEVICES = -1
.\venv\Scripts\python.exe .\webui.py --no-half --use-cpu all --precision full

jamesWalker55 avatar Nov 12 '22 00:11 jamesWalker55

But fear not! Use google colab

Actually, Colab is also limited in terms of usage, so that at some point depending on current usage, it can decide at any moment to restrict free tier to CPU-only mode. This just happened to me. So it's still useful to be able to run the whole pipeline on CPU-only mode.

lrq3000 avatar Dec 13 '22 01:12 lrq3000