santa hat
deerdeer nosedeer glow
Sign In

How to Avoid VRAM Exhaustion and Prevent VRAM Spikes!


Examples included in this guide on why you would want to use this.

Click here for a detail image guide by @fitCorder. Very cool Dude.

What is VRAM?

VRAM is the resource on your graphics card, which is used to generate images. Most graphics cards have between 6-12 GB of VRAM. Most people generate their images at resolutions of 512x512 or 768x512 and use a Hi-Res Fix afterwards. Depending on your VRAM capacity, you can upscale the images by a factor of 1.5 to 2.5 (the base resolution matters).

If you are familiar with Task Manager, you can check your VRAM usage on your GPU. Towards the end of your image generation, your VRAM may spike, which can lead to an out-of-memory error.

But why? The culprit is our VAE. It attempts to enhance colors and contrast in the final stages of image generation, causing a spike in VRAM usage.

How to fix this?

Easy Solution, we need only 2 things.

  1. We have to include --no-half-vae --disable-nan-check in our webui-user.

  2. We need an Extension.


Go to your Stable Diffusion Folder, right click your webui-user and click on edit. Under "set COMMANDLINE_ARGS=" add "--no-half-vae --disable-nan-check".

It should look like this:

(You can add --opt-sdp-attention or --xformers for additional boost.)

Tiled VAE

  1. Install this Extension.

    Go to your StableDiffusion -> Under Extensions -> Install from URL -> Paste link in "URL for extension's git repository" -> Install -> Go to Installed -> Check for updates -> Apply and restart UI.

  2. You will now see 2 additional tabs in your txt2img/img2img.

    We only need Tiled VAE.

  3. Set your Tiled VAE to these Settings:

  4. Done!

Now you can generate your images at a higher base resolution and higher upscale.

Be careful: Most LoRAs and checkpoints do not support high resolutions.

I would still recommend using a base resolution of 512x512 or 768x512 and upscaling by a factor of 2 or 2.5.