AUTOMATIC1111 / stable-diffusion-webui

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

[Feature Request]: Enabling Half Precision #6308

Closed super3 closed 1 year ago

super3 commented 1 year ago

Is there an existing issue for this?

What would your feature do ?

Is there a way to enable half precision in stable-diffusion-webui? Duffusers seems to support it, but looking through the command line arguments for stable-diffusion-webui I only see an option to disable it. According to this benchmark it can cut times in half: https://lambdalabs.com/blog/inference-benchmark-stable-diffusion

What am I missing?

Proposed workflow

  1. Add --half-precision to command line arguments
  2. Run stable-diffusion-webui
  3. ???
  4. Double performance!

Additional information

No response

fractal-fumbler commented 1 year ago

--no-half stand for forbidding model to switch only to fp16, thus allowing using fp32 as well as fp16

AnonymousCervine commented 1 year ago

To clarify: The reason you only see an option to disable it is that running at half precision is the default mode in this repo, in general (I'm not sure if there's been any quibbles introduced with 2.1 models breaking on them when xformers isn't installed)

IIRC, it doesn't cut rendering times in half for everyone, only those who have chip architectures designed with the expectation of half-precision operations (Though I think even with those on bad support it generally wins out a little because massive-matrix-multiplication is memory-bandwidth-limited and so even with significantly slower half-precision ops, it still wins out anyway by dint of fetching half-as-much memory); however even without that, most of everyone who don't have fast half-precision architectures (and several who do!) also have comparatively little VRAM and still want to run in half-precision—in short, it's a good default.

ClashSAN commented 1 year ago

often, users have gpus that run (half-precision/mixed-precision/fp16) what @AnonymousCervine says is correct, everybody by default already runs this mode.

some users on cpu, old gpu, amd gpu, and, macos need to run in (full-precision/fp32), so they must run those flags.

list of flags - https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings

super3 commented 1 year ago

Everything makes more sense now. Thanks very much for the information!

DougStoker commented 1 year ago

i'm using an an intel mac running on cpu, and the invokeai thing can run on half precision. I want to switch over to this repo because invoke added a bunch of woke stuff in their TOS, but running the automatic gui is much slower and if i use the half precision args it crashes and says its not supported. in addition, images that are in the process of being generated are often killed by the system.