AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
143.44k stars 27.01k forks source link

[Bug]: SD now Uses way more VRAM than before no mader what image size I generate #12273

Open azi52 opened 1 year ago

azi52 commented 1 year ago

Is there an existing issue for this?

What happened?

started to use all Vram when generating for no apparent reasons (maybe IDK).

I installed a new game on the computer around the same time the problem started and uninstalled it after seeing the problem arise and deleted any left over files, but the problem persisted even after that.

game: tower of fantasy (installed on epic luncher)

Steps to reproduce the problem

generate and image and you'll get all your Gpu's dedicated memory at 100%, even if you make a 512x512 image

What should have happened?

normally generating a 512x768 image would never get to more than 9~10 Gb being used

Version or Commit where the problem happens

a9fed7c3

What Python version are you running on ?

Python 3.10.x

What platforms do you use to access the UI ?

Windows

What device are you running WebUI on?

Nvidia GPUs (RTX 20 above)

Cross attention optimization

Automatic

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS= --no-half-vae --disable-nan-check --precision full --no-half

call webui.bat

List of extensions

I didn't install extensions until today trying to figure out the problem, I will delete them after the problem is solve (or not reinstall them if I need a fresh installation)

-a1111-stable-diffusion-webui-vram-estimator -sd-extension-system-info -sd-webui-additional-networks

Console logs

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: a9fed7c364061ae6efb37f797b6b522cb3cf7aa2
Installing requirements for Web UI

Launching Web UI with arguments:
No module 'xformers'. Proceeding without it.
==============================================================================
You are running torch 1.12.1+cu113.
The program is tested to work with torch 1.13.1.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.

Use --skip-version-check commandline argument to disable this check.
==============================================================================
[AddNet] Updating model hashes...
0it [00:00, ?it/s]
[AddNet] Updating model hashes...
0it [00:00, ?it/s]
Loading weights [48fd89ed36] from C:\Users\Azi\stable-diffusion-webui\models\Stable-diffusion\mistoonSapphire_v20.safetensors
Creating model from config: C:\Users\Azi\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (Doggettx).
Textual inversion embeddings loaded(0):
Model loaded in 2.9s (create model: 0.4s, apply weights to model: 0.7s, apply half(): 0.5s, move model to device: 0.4s, load textual inversion embeddings: 0.8s).
[VRAMEstimator] No stats available, run benchmark first
C:\Users\Azi\AppData\Local\Programs\Python\Python310\lib\site-packages\gradio\deprecation.py:43: UserWarning: You have unused kwarg parameters in JSON, please remove them: {'lines': 0}
  warnings.warn(
C:\Users\Azi\AppData\Local\Programs\Python\Python310\lib\site-packages\gradio\deprecation.py:43: UserWarning: You have unused kwarg parameters in Textbox, please remove them: {'default': ''}
  warnings.warn(
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 13.4s (import gradio: 2.0s, import ldm: 3.3s, other imports: 1.4s, list extensions: 0.3s, load scripts: 1.9s, load SD checkpoint: 2.9s, create ui: 1.1s, gradio launch: 0.4s).
100%|██████████████████████████████████████████████████████████████████████████████████| 36/36 [00:19<00:00,  1.80it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 36/36 [00:25<00:00,  1.43it/s]
{"prompt": "1girl, 4k, fine detail, beautiful, (masterpiece:1.2), (best quality:1.2), perfect eyes, perfect face, perfect lighting,", "all_prompts": ["1girl, 4k, fine detail, beautiful, (masterpiece:1.2), (best quality:1.2), perfect eyes, perfect face, perfect lighting,"], "negative_prompt": "animal ears, 3d, censor, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, large breasts, muscular, bad hands,", "all_negative_prompts": ["animal ears, 3d, censor, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, large breasts, muscular, bad hands,"], "seed": 3039244939, "all_seeds": [3039244939], "subseed": 266858429, "all_subseeds": [266858429], "subseed_strength": 0, "width": 512, "height": 768, "sampler_name": "Euler a", "cfg_scale": 7, "steps": 36, "batch_size": 1, "restore_faces": false, "face_restoration_model": null, "sd_model_hash": "48fd89ed36", "seed_resize_from_w": 0, "seed_resize_from_h": 0, "denoising_strength": null, "extra_generation_params": {}, "index_of_first_image": 0, "infotexts": ["1girl, 4k, fine detail, beautiful, (masterpiece:1.2), (best quality:1.2), perfect eyes, perfect face, perfect lighting,\nNegative prompt: animal ears, 3d, censor, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, large breasts, muscular, bad hands,\nSteps: 36, Sampler: Euler a, CFG scale: 7, Seed: 3039244939, Size: 512x768, Model hash: 48fd89ed36"], "styles": [], "job_timestamp": "20230803022511", "clip_skip": 1, "is_using_inpainting_conditioning": false}
Loading weights [f8bb2922e1] from C:\Users\Azi\stable-diffusion-webui\models\Stable-diffusion\revAnimated_v122.safetensors
Loading VAE weights specified in settings: C:\Users\Azi\stable-diffusion-webui\models\VAE\vae-ft-mse-840000-ema-pruned.safetensors
Applying cross attention optimization (Doggettx).
Weights loaded in 5.0s (apply weights to model: 4.0s, load VAE: 0.4s, move model to device: 0.5s).
100%|██████████████████████████████████████████████████████████████████████████████████| 36/36 [00:18<00:00,  1.94it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 36/36 [00:24<00:00,  1.46it/s]
{"prompt": "1girl, 4k, fine detail, beautiful, (masterpiece:1.2), (best quality:1.2), perfect eyes, perfect face, perfect lighting,", "all_prompts": ["1girl, 4k, fine detail, beautiful, (masterpiece:1.2), (best quality:1.2), perfect eyes, perfect face, perfect lighting,"], "negative_prompt": "animal ears, 3d, censor, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, large breasts, muscular, bad hands,", "all_negative_prompts": ["animal ears, 3d, censor, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, large breasts, muscular, bad hands,"], "seed": 2381610838, "all_seeds": [2381610838], "subseed": 1461682696, "all_subseeds": [1461682696], "subseed_strength": 0, "width": 512, "height": 768, "sampler_name": "Euler a", "cfg_scale": 7, "steps": 36, "batch_size": 1, "restore_faces": false, "face_restoration_model": null, "sd_model_hash": "f8bb2922e1", "seed_resize_from_w": 0, "seed_resize_from_h": 0, "denoising_strength": null, "extra_generation_params": {}, "index_of_first_image": 0, "infotexts": ["1girl, 4k, fine detail, beautiful, (masterpiece:1.2), (best quality:1.2), perfect eyes, perfect face, perfect lighting,\nNegative prompt: animal ears, 3d, censor, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, bad anatomy, large breasts, muscular, bad hands,\nSteps: 36, Sampler: Euler a, CFG scale: 7, Seed: 2381610838, Size: 512x768, Model hash: f8bb2922e1"], "styles": [], "job_timestamp": "20230803022733", "clip_skip": 1, "is_using_inpainting_conditioning": false}

Additional information

found this in webui bat (not webui-user) I have no clue if this is normal;

@echo off

if not defined PYTHON (set PYTHON=python) if not defined VENV_DIR (set "VENV_DIR=%~dp0%venv")

set ERROR_REPORTING=FALSE

mkdir tmp 2>NUL

%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :check_pip echo Couldn't launch python goto :show_stdout_stderr

:check_pip %PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :start_venv if "%PIP_INSTALLER_LOCATION%" == "" goto :show_stdout_stderr %PYTHON% "%PIP_INSTALLER_LOCATION%" >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :start_venv echo Couldn't install pip goto :show_stdout_stderr

:start_venv if ["%VENV_DIR%"] == ["-"] goto :skip_venv if ["%SKIP_VENV%"] == ["1"] goto :skip_venv

dir "%VENV_DIR%\Scripts\Python.exe" >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :activate_venv

for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i" echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME% %PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt if %ERRORLEVEL% == 0 goto :activate_venv echo Unable to create venv in directory "%VENV_DIR%" goto :show_stdout_stderr

:activate_venv set PYTHON="%VENV_DIR%\Scripts\Python.exe" echo venv %PYTHON%

:skip_venv if [%ACCELERATE%] == ["True"] goto :accelerate goto :launch

:accelerate echo Checking for accelerate set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe" if EXIST %ACCELERATE% goto :accelerate_launch

:launch %PYTHON% launch.py %* pause exit /b

:accelerate_launch echo Accelerating %ACCELERATE% launch --num_cpu_threads_per_process=6 launch.py pause exit /b

:show_stdout_stderr

echo. echo exit code: %errorlevel%

for /f %%i in ("tmp\stdout.txt") do set size=%%~zi if %size% equ 0 goto :show_stderr echo. echo stdout: type tmp\stdout.txt

:show_stderr for /f %%i in ("tmp\stderr.txt") do set size=%%~zi if %size% equ 0 goto :show_stderr echo. echo stderr: type tmp\stderr.txt

:endofscript

echo. echo Launch unsuccessful. Exiting. pause

AbstractEyes commented 1 year ago

I'm having a similar problem. I have a 4090 and it seems to just want all of it.

dfzdfg-Zheng commented 1 year ago

found it eats most of the VRAM after loading the model. idk but you can try launch with argument '--medvram', which may help reduce the VRAM consume at the beginning.

PsilAxis commented 1 year ago

this is happening to me too, making it so i am unable to use the webui at all. i have an rtx 2060 that worked just fine before and now its entirely useless.

dhwz commented 1 year ago

@azi52 remove --precision full --no-half Using these arguments does drastically increase the memory usage as the models are loaded as fp32 Also remove --no-half-vae and use fp16 fixed VAE (if you want to use SDXL) Forget about --disable-nan-check

azi52 commented 1 year ago

@dhwz thx I'll try it next time before I use SD and see how it goes

I also updated my cuda drivers since someone recommended it to me but it didn't work.

azi52 commented 1 year ago

@azi52 remove --precision full --no-half Using these arguments does drastically increase the memory usage as the models are loaded as fp32 Also remove --no-half-vae and use fp16 fixed VAE (if you want to use SDXL) Forget about --disable-nan-check

I basically took off all my argument and sad to report it didn't fix anything

Combine101 commented 1 year ago

i am using an rtx 2060 6gb as well, till sunday everything worked fine. After git pull and updating some stuff, it seems there is no unloading the module from vram after generating anything again. Can't tell you what was updated since i can't find any log. While monitoring gpu performance after generating image is still a max size (before monday vram was getting free after generating was finished). I think it is a bug bc there was an update on monday (or sunday) after it there was this behaviour...

There is a workaround: "unload the module to free vram" in settings -> actions but this should be only a temp solution from my pov

dhwz commented 1 year ago

@Combine101 not a bug model is now kept in VRAM, change settings > Stable Diffusion if you don't like it