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

Predict and display VRAM requirement for a run and add warnings if it would cause OOM

Open oxysoft opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. Users running on low VRAM (6GB in my case) will try to max it out as close as possible to the limit. If I open too many tabs in firefox or other apps, I can easily take up an extra 150-300mb VRAM which will now be too much to fit my gen parameters in. I think preventions for crashing is always a good feature to have in any user-facing application. (I understand why this wasn't a priority of course)

Describe the solution you'd like Display a text label near the generate button which estimates the amount of VRAM that will be used, changing to a red color if it would not fit.

Perform the check as well when pressing the generate button and display a warning if it will not fit. This warning should not use the browser popup API because we can't ensure a good UX. Instead, the warning should be another label on the page which appears. Pressing the button a second time bypasses the warning and launches anyway. The warning label is removed/refreshed whenever the page regains focus, and when the VRAM frees up again.

I'm not sure how fast/expensive it is to poll the GPU for VRAM usage e.g. with nvidia-smi (or perhaps there are already built-in functions in PyTorch for this) so perhaps this should be done every few seconds.

Perhaps the VRAM requirements can be calculated mathematically, I'm not exactly sure how myself and there are certainly challenges with all the different options like --lowvram, --medvram, not to forget the optimizations that people are introducing on a weekly basis seemingly. As such it might be better for starters that we simply store statistics about the VRAM usage by parameters for each runs, i.e. making it adaptative and 'learning'. The prediction would display a question mark if the resolution hasn't be tried yet with the enabled optimizations, model size, resolution, and any other setting which can affect VRAM.

Describe alternatives you've considered

Additional context

oxysoft avatar Oct 05 '22 15:10 oxysoft

Made an extension for this, see here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/8330

space-nuko avatar Mar 05 '23 04:03 space-nuko