Skip to content

[Bug]: CUDA out of memory, Stable Diffusion failed to load #9770

@VGTiredAF

Description

@VGTiredAF

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What happened?

After running webui-user.bat and installed all required files, it fails to load. I have entered what I think to be the required BATCH edit, but im not completely sure:

@echo off

set PYTHON="C:\Users\chron\AppData\Local\Programs\Python\Python310\python.exe"
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--lowvram --xformers --disable-nan-check --opt-sub-quad-attention --sub-quad-q-chunk-size=128 --sub-quad-kv-chunk-size=128 --sub-quad-chunk-threshold=80
set PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6,max_split_size_mb:128

call webui.bat

P/S: It could have some issue with --xformers commandlinearg because it doesnt load with it, and im not sure how to fix that either.

Steps to reproduce the problem

  1. Go to ....
  2. Press ....
  3. ...

What should have happened?

After installing all files it should have opened to the UI

Commit where the problem happens

unknown, if required please walk me through to find out

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

No

List of extensions

No

Console logs

venv "C:\Users\chron\stable-diffusion-webui\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: 22bcc7be428c94e9408f589966c2040187245d81
Installing requirements for Web UI
Launching Web UI with arguments: --xformers
Loading weights [6ce0161689] from C:\Users\chron\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
Creating model from config: C:\Users\chron\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
loading stable diffusion model: OutOfMemoryError
Traceback (most recent call last):
  File "C:\Users\chron\stable-diffusion-webui\webui.py", line 139, in initialize
    modules.sd_models.load_model()
  File "C:\Users\chron\stable-diffusion-webui\modules\sd_models.py", line 449, in load_model
    sd_model.to(shared.device)
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\lightning_fabric\utilities\device_dtype_mixin.py", line 54, in to
    return super().to(*args, **kwargs)
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 989, in to
    return self._apply(convert)
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 641, in _apply
    module._apply(fn)
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 641, in _apply
    module._apply(fn)
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 641, in _apply
    module._apply(fn)
  [Previous line repeated 2 more times]
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 664, in _apply
    param_applied = fn(param)
  File "C:\Users\chron\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 987, in convert
    return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 2.00 GiB total capacity; 1.66 GiB already allocated; 0 bytes free; 1.70 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF


Stable diffusion model failed to load, exiting
Press any key to continue . . .

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-reportReport of a bug, yet to be confirmed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions