AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: Extreme slowness (not sure if a bug) #14789

Open Butterfly-Dragon opened 7 months ago

Butterfly-Dragon commented 7 months ago

Checklist

What happened?

Stabe diffusion XL averages between 45 to 60 seconds per iteration on a 512x768 image Stable diffusion XL turbo averages between 3 and 4 seconds per iteration on a 512x768 image Most SD 1.5 models average around 1 to 2 iterations per second on a 512x768 image

My system specifications:

Steps to reproduce the problem

  1. just ask any image with those resolutions i gave put any number of steps you like to get a decent average.
  2. i am not sure if it is a "your hardware is obsolete" problem or something else.
  3. i tried even reinstalling automatic1111 to see if it was an old running environment problem or something.

What should have happened?

Most people i see seem to have "iterations per second" not "minutes per iteration" (if i start watching a video on youtube or tiktok or use the graphics card for anything the "seconds per iteration" can easily get in the hundreds) even on a base SDXL model and the comments i read state something about "waiting a couple of seconds" as the difference between SDXL Turbo and SDXL base model.

What browsers do you use to access the UI ?

Google Chrome

Sysinfo

sysinfo-2024-01-29-14-12.json

Console logs

Version: v1.7.0
Commit hash: cf2772fab0af5573da775e7437e6acdca424f26e
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu118
Requirement already satisfied: torch==2.0.1 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (2.0.1+cu118)
Requirement already satisfied: torchvision==0.15.2 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (0.15.2+cu118)
Requirement already satisfied: filelock in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torch==2.0.1) (3.12.4)
Requirement already satisfied: typing-extensions in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torch==2.0.1) (4.8.0)
Requirement already satisfied: sympy in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torch==2.0.1) (1.12)
Requirement already satisfied: networkx in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torch==2.0.1) (3.1)
Requirement already satisfied: jinja2 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torch==2.0.1) (3.1.2)
Requirement already satisfied: numpy in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torchvision==0.15.2) (1.23.5)
Requirement already satisfied: requests in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torchvision==0.15.2) (2.31.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from torchvision==0.15.2) (9.5.0)
Requirement already satisfied: MarkupSafe>=2.0 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from jinja2->torch==2.0.1) (2.1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from requests->torchvision==0.15.2) (3.3.0)
Requirement already satisfied: idna<4,>=2.5 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from requests->torchvision==0.15.2) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from requests->torchvision==0.15.2) (2.0.5)
Requirement already satisfied: certifi>=2017.4.17 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from requests->torchvision==0.15.2) (2023.7.22)
Requirement already satisfied: mpmath>=0.19 in d:\documents\github\stable-diffusion-webui\venv\lib\site-packages (from sympy->torch==2.0.1) (1.3.0)
Installing xformers
You are up to date with the most recent release.
Pulled changes for repository in 'D:\Documents\GitHub\stable-diffusion-webui\extensions\sd-dynamic-thresholding':
Already up to date.

Pulled changes for repository in 'D:\Documents\GitHub\stable-diffusion-webui\extensions\sd-infinity-grid-generator-script':
Already up to date.

Pulled changes for repository in 'D:\Documents\GitHub\stable-diffusion-webui\extensions\sd-webui-agent-scheduler':
Already up to date.

Launching Web UI with arguments: --no-half-vae --no-half --precision full --disable-nan-check --medvram-sdxl --xformers --update-all-extensions --update-check --reinstall-xformers --reinstall-torch
Using sqlite file: D:\Documents\GitHub\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\task_scheduler.sqlite3
Loading weights [31e35c80fc] from D:\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\Stable Diffusion XL 1.0 base.safetensors
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 22.3s (prepare environment: 10.1s, import torch: 3.3s, import gradio: 1.0s, setup paths: 2.3s, initialize shared: 0.2s, other imports: 0.7s, setup codeformer: 0.1s, load scripts: 2.0s, create ui: 0.7s, gradio launch: 1.2s, app_started_callback: 0.5s).
Creating model from config: D:\Documents\GitHub\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Applying attention optimization: xformers... done.
Model loaded in 14.4s (load weights from disk: 2.8s, create model: 0.6s, apply weights to model: 2.5s, apply float(): 4.4s, calculate empty prompt: 4.1s).
X/Y/Z plot will create 1 images on 1 1x1 grid. (Total steps to process: 150)
 81%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                                 | 91/113 [1:18:26<16:42, 45.56s/it]Reusing loaded model Stable Diffusion XL 1.0 base.safetensors [31e35c80fc] to load Stable Diffusion XL 1.0 refiner.safetensors [7440042bbd]████████████████████████████▌                                                                                              | 91/150 [1:18:31<44:48, 45.56s/it]
Loading weights [7440042bbd] from D:\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\Stable Diffusion XL 1.0 refiner.safetensors
Creating model from config: D:\Documents\GitHub\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_refiner.yaml
Applying attention optimization: xformers... done.
Model loaded in 35.1s (create model: 0.3s, apply weights to model: 31.6s, apply float(): 2.1s, calculate empty prompt: 1.0s).
 98%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍    | 111/113 [1:36:19<01:13, 36.79s/it]D:\Documents\GitHub\stable-diffusion-webui\venv\lib\site-packages\torchsde\_brownian\brownian_interval.py:599: UserWarning: Should have ta>=t0 but got ta=0.03040177747607231 and t0=0.030402.██████████▍                                                            | 112/150 [1:36:55<22:20, 35.27s/it]
  warnings.warn(f"Should have ta>=t0 but got ta={ta} and t0={self._start}.")
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [1:37:23<00:00, 51.71s/it]
Reusing loaded model Stable Diffusion XL 1.0 refiner.safetensors [7440042bbd] to load Stable Diffusion XL 1.0 base.safetensors [31e35c80fc]██████████████████████████████████████████████████████████████                                                           | 113/150 [1:37:27<21:08, 34.28s/it]
Loading weights [31e35c80fc] from D:\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\Stable Diffusion XL 1.0 base.safetensors
Creating model from config: D:\Documents\GitHub\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Applying attention optimization: xformers... done.
Model loaded in 7.7s (create model: 0.5s, apply weights to model: 3.4s, apply float(): 2.4s, calculate empty prompt: 1.3s).
Total progress:  75%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                                                           | 113/150 [1:37:51<32:02, 51.96s/it]
X/Y/Z plot will create 198 images on 1 9x22 grid. (Total steps to process: 29700)████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                                                           | 113/150 [1:37:51<21:08, 34.28s/it]
                                  Reusing loaded model Stable Diffusion XL 1.0 base.safetensors [31e35c80fc] to load Stable Diffusion XL 1.0 turbo.safetensors [3f067a1b94]
Loading weights [3f067a1b94] from D:\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\Stable Diffusion XL 1.0 turbo.safetensors
Creating model from config: D:\Documents\GitHub\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\configs\stable-diffusion\v2-inference.yaml
Applying attention optimization: xformers... done.
Model loaded in 3.0s (find config: 1.2s, create model: 0.1s, apply weights to model: 1.5s).
 98%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍    | 111/113 [06:37<00:07,  3.82s/it]D:\Documents\GitHub\stable-diffusion-webui\venv\lib\site-packages\torchsde\_brownian\brownian_interval.py:599: UserWarning: Should have ta>=t0 but got ta=0.03040177747607231 and t0=0.030402.                                                                    | 112/29700 [06:55<30:16:20,  3.68s/it]
  warnings.warn(f"Should have ta>=t0 but got ta={ta} and t0={self._start}.")
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:43<00:00,  3.57s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:30<00:00,  3.46s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [05:38<00:00,  2.99s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [05:54<00:00,  3.14s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [04:43<00:00,  2.51s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [04:21<00:00,  2.31s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [01:51<00:00,  1.02it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [05:07<00:00,  2.72s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:00<00:00,  3.19s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [04:39<00:00,  2.47s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [03:59<00:00,  2.12s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [04:21<00:00,  2.31s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [02:41<00:00,  1.43s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:50<00:00,  3.63s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:23<00:00,  3.39s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:59<00:00,  3.72s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [05:43<00:00,  3.04s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [04:25<00:00,  2.35s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [06:17<00:00,  3.34s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [05:39<00:00,  3.01s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [04:01<00:00,  2.13s/it]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [02:43<00:00,  1.45s/it]
Reusing loaded model Stable Diffusion XL 1.0 turbo.safetensors [3f067a1b94] to load Stable Diffusion v1.5.safetensors [1a189f0be6]                                                                                                                             | 2486/29700 [1:58:08<7:27:07,  1.01it/s]
Loading weights [1a189f0be6] from D:\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\Stable Diffusion v1.5.safetensors
Creating model from config: D:\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\Stable Diffusion v1.5.yaml
Applying attention optimization: xformers... done.
Model loaded in 2.1s (create model: 0.4s, apply weights to model: 1.6s).
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:52<00:00,  2.16it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:54<00:00,  2.06it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:53<00:00,  2.12it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:53<00:00,  2.11it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:53<00:00,  2.10it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:53<00:00,  2.11it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:54<00:00,  2.09it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:54<00:00,  2.08it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:54<00:00,  2.06it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 113/113 [00:54<00:00,  2.07it/s]
 30%|█████████████████████████████████████████████████████████████████████████████▋                                                                                                                                                                                    | 34/113 [00:20<01:05,  1.20it/s]
Total progress:  12%|████████████████████████████▊                                                                                                                                                                                                             | 3650/29700 [2:09:25<6:00:54,  1.20it/s]

Additional information

nothing else to add. But for the sake of completeness let me add what i was doing above. The following are (in order):

image

Butterfly-Dragon commented 7 months ago

Something to note: before writing here i noticed in the bugs that people seem to complain that SDXL Turbo does not load properly if one does not load SDXL before running it. I see it loads itself with the SD 2.X inference yaml.

That is unrelated to this but might be worth checking.

The speed of SD XL Turbo is (indeed) the same as my SD 2.X models. But the results are eons better. Also the results are eons better than standard SDXL too given a "same steps count". It is just incompatible with SD 1.5 loras but at this speed the price is one worth paying.

ryanoZphoto commented 7 months ago

im not at all savvy at this stuff but is there any way to speed up the generations? im at like an hour per gen image

Butterfly-Dragon commented 7 months ago

@ryanoZphoto what were you doing besides generating, and what model type did you use?

So far what i noticed is that:

Resolution is the second most important thing, as the speed scales with the megapixels, hence why most people prefer to upscale rather than generating at high resolution.

a 512x512 image (0.25 megapixels) is around 16x faster to generate than a 1024x1024 picture (1 megapixel) so you go from 2 iterations/second to 1 iteration every 8 seconds.

Next thing i saw that accounts for that is what else you do with your machine when generating. You get the fastest results by closing everything and letting the machine churn. Yes, that includes the browser with WebUI, as it would otherwise generate previews which further slow generation. Basically, start the project and if you are not in the "fiddling fase" where you are chosing what to ask and how, just let it do its thing. This is impacted by model size. Smaller models (2 GB) are less impacted by what you do with your machine, but if you have to load a 9GB model then even breathing near your machine will slow things considerably.

Obviously this is comparing a machine to itself, you said absolutely nothing about your machine, what were you doing, the size of your generation so, therefore your comment is pretty much useless, so i tried to give broad strokes to address what might be the problems you have and how to work around them according to my empirical personal experience.

Shuggaloaf commented 7 months ago

I had been on v1.5.1 and recently got back into it after a break. I updated to v1.7 and noticed the same extreme slowness.

When I tested, all things being equal and using the same exact model (making a copy in windows), 1.5.1 yields considerably faster results than 1.7. I tried several models, some based on SD 1.5 and some based on SDXL all came back much faster in A1111 v1.5.1. I even have my v1.5 copy on a standard HDD. I tried installed 1.7 on my nvme drive and it made no noticeable difference.

For now I'm sticking with A1111 v1.5.1 simply because I know it works, but I'd really love to use the new features in v1.7. If anyone has any insight into what's going on with the speed I'd love to hear it as well.