Skip to Content

How to Verify VRAM Usage in Automatic1111

  • The article explains how to verify and optimize VRAM usage in Automatic1111, a generative AI tool that can create realistic images from text or image prompts.
  • The article suggests using GPU-Z, a third-party tool that can monitor GPU activity and memory consumption, to check VRAM usage across multiple GPUs.
  • The article also provides various command-line arguments that can enable different optimization options for Automatic1111, such as –xformers, –opt-sdp-attention, –opt-sub-quad-attention, and more, and discusses their benefits and challenges.

Automatic1111 is a generative AI tool that can create realistic images from text or image prompts, using a technique called stable diffusion. It is based on a large neural network model that requires a lot of video memory (VRAM) to run efficiently. VRAM is the memory that the graphics processing unit (GPU) uses to store and process graphical data. The more VRAM a GPU has, the more complex and detailed images it can generate.

However, not all GPUs have the same amount of VRAM, and some users may have multiple GPUs installed on their systems. In such cases, it is important to know how to verify if Automatic1111 is using all available VRAM in a multi-GPU environment, and what are the benefits and challenges of doing so. In this article, we will explain how to check VRAM usage in Automatic1111, and what are the optimization options and trade-offs involved.

How to Verify VRAM Usage in Automatic1111

How to Check VRAM Usage in Automatic1111

To check VRAM usage in Automatic1111, you need to use a third-party tool that can monitor GPU activity and memory consumption. One such tool is GPU-Z, which is a free and lightweight utility that can display various information about your GPU, including VRAM usage, temperature, fan speed, clock speed, and more.

To use GPU-Z to check VRAM usage in Automatic1111, follow these steps:

  1. Download and install GPU-Z from its official website.
  2. Run GPU-Z and select the GPU that you want to monitor from the drop-down menu at the bottom-left corner of the window.
  3. Run Automatic1111 and start generating images from your desired prompts.
  4. Switch back to GPU-Z and observe the Memory Used (MB) value under the Sensors tab. This value shows how much VRAM is being used by the selected GPU at any given moment.
  5. Repeat steps 2-4 for each GPU that you have on your system.

By comparing the Memory Used values across different GPUs, you can see if Automatic1111 is using all available VRAM in a multi-GPU environment or not. Ideally, you want to see a balanced distribution of VRAM usage across all GPUs, which means that Automatic1111 is utilizing all the available resources efficiently.

How to Optimize VRAM Usage in Automatic1111

If you notice that Automatic1111 is not using all available VRAM in a multi-GPU environment, or if you want to improve its performance and image quality, you can try some optimization options that are available in the tool. These options are command-line arguments that can be added to the webui-user.bat file that launches Automatic1111. Some of these options are:

  • –opt-sdp-attention: This option may result in faster speeds than using xFormers on some systems but requires more VRAM. It uses sparse dot-product attention instead of full attention for the cross attention layer of the model. This option is non-deterministic, which means that it may produce different results for the same input.
  • –opt-sdp-no-mem-attention: This option may result in faster speeds than using xFormers on some systems but requires more VRAM. It uses sparse dot-product attention without memory attention for the cross attention layer of the model. This option is deterministic, which means that it will produce consistent results for the same input, but it may be slightly slower than –opt-sdp-attention and use more VRAM.
  • –xformers: This option uses xFormers library, which is a fast and memory-efficient implementation of transformers. It can greatly improve memory consumption and speed for Nvidia GPUs only. It is deterministic as of version 0.0.19 of xFormers (webui uses 0.0.20 as of 1.4.0).
  • –force-enable-xformers: This option enables xFormers regardless of whether the program thinks you can run it or not. It may cause bugs or errors if your system is not compatible with xFormers, so use it at your own risk.
  • –opt-split-attention: This option enables cross attention layer optimization that significantly reduces memory use for almost no cost (some report improved performance with it). It splits the attention matrix into smaller chunks and computes them separately. It is enabled by default for torch.cuda, which includes both Nvidia and AMD GPUs.
  • –disable-opt-split-attention: This option disables the optimization above.
  • –opt-sub-quad-attention: This option enables sub-quadratic attention, which is a memory-efficient cross attention layer optimization that can significantly reduce required memory, sometimes at a slight performance cost. It reduces the complexity of computing attention from quadratic to linearithmic by using locality-sensitive hashing (LSH). It is recommended if you are getting poor performance or failed generations with a hardware/software configuration that xFormers does not work for. On macOS, this option will also allow you to generate larger images.
  • –opt-split-attention-v1: This option uses an older version of the optimization above that is not as memory hungry (it will use less VRAM, but will be more limiting in the maximum size of pictures you can make).
  • –medvram: This option makes the Stable Diffusion model consume less VRAM by splitting it into three parts – cond (for transforming text into numerical representation), first_stage (for converting a picture into latent space and back), and unet (for actual denoising of latent space) and making it so that only one is in VRAM at all times, sending others to CPU RAM. It lowers performance, but only by a bit – except if live previews are enabled.
  • –lowvram: This option is an even more thorough optimization of the above, splitting unet into many modules, and only one module is kept in VRAM. It is devastating for performance.

To use any of these options, you need to edit the webui-user.bat file and add them to the set COMMANDLINE_ARGS= line. For example, if you want to use –xformers and –opt-split-attention, you need to change the line to:

set COMMANDLINE_ARGS=–xformers --opt-split-attention

Then save the file and run it to launch Automatic1111 with the desired options.

Benefits and Challenges of Optimizing VRAM Usage in Automatic1111

Optimizing VRAM usage in Automatic1111 can have several benefits and challenges, depending on your system configuration and your goals. Some of the benefits are:

  • You can generate larger and higher-quality images with less memory constraints.
  • You can improve the speed and efficiency of image generation by using faster and more memory-friendly attention mechanisms.
  • You can balance the VRAM usage across multiple GPUs and make use of all the available resources.

Some of the challenges are:

  • You may encounter bugs or errors if you use incompatible or experimental options that are not supported by your system or software.
  • You may sacrifice some performance or quality for lower memory consumption, depending on the trade-offs involved in each option.
  • You may need to experiment with different combinations of options to find the optimal settings for your use case.

Frequently Asked Questions (FAQs)

Question: What is Automatic1111?

Answer: Automatic1111 is a generative AI tool that can create realistic images from text or image prompts, using a technique called stable diffusion.

Question: What is VRAM?

Answer: VRAM or Video Random-Access Memory is the memory that the graphics processing unit (GPU) uses to store and process graphical data.

Question: How to check VRAM usage in Automatic1111?

Answer: To check VRAM usage in Automatic1111, you need to use a third-party tool that can monitor GPU activity and memory consumption, such as GPU-Z.

Question: How to optimize VRAM usage in Automatic1111?

Answer: To optimize VRAM usage in Automatic1111, you can use some command-line arguments that can enable various optimization options, such as –xformers, –opt-sdp-attention, –opt-sub-quad-attention, –medvram, and more.

Question: What are the benefits and challenges of optimizing VRAM usage in Automatic1111?

Answer: Optimizing VRAM usage in Automatic1111 can have several benefits, such as generating larger and higher-quality images, improving speed and efficiency, and balancing VRAM usage across multiple GPUs. It can also have some challenges, such as encountering bugs or errors, sacrificing performance or quality for lower memory consumption, and needing to experiment with different combinations of options.

Summary

In this article, we have explained how to verify if Automatic1111 is using all available VRAM in a multi-GPU environment, and what are the optimization options and trade-offs involved. We have also answered some frequently asked questions about generative AI, VRAM, and Automatic1111. We hope this article has been helpful for you to understand how to make the best use of your GPU resources when using Automatic1111.

Disclaimer: This article is for informational purposes only and does not constitute professional advice. The information contained herein is based on our own research and experience with Automatic1111 and may not reflect the latest developments or updates. We do not guarantee the accuracy or completeness of the information provided herein. We are not affiliated with or endorsed by OpenAI or any other organization mentioned in this article. We are not responsible for any damages or losses caused by using Automatic1111 or any of the optimization options mentioned in this article. Use Automatic1111 at your own risk and discretion.