Home > Tips and Tricks

Stable Diffusion Cuda Out of Memory: How to Fix

In this guide, we will show you the steps to fix the Stable Diffusion Cuda Out of Memory error. One of the most popular deep learning, text-to-image models, Stable Diffusion is able to generate some impressively detailed images based on the text descriptions. However, in spite of all the goodies that it has to offer, it isn’t free from its fair share of issues either.

In this regard, recently we covered its crashing with Automatic1111, and now, there has been another unwanted entry to this bug list. Numerous users have voiced their concern that they are getting Out of Memory error in Stable Diffusion Cuda. As a result of which, they are unable to make full use of this tool. If you are also currently getting bugged by this issue, then this guide will make you aware of numerous workarounds to rectify this issue. Follow along.

Fix Stable Diffusion Cuda Out of Memory

Stable Diffusion Cuda Out of Memory

It is recommended that you try out each of the below-mentioned workarounds and then see which one spells out success. So with that in mind, let’s get started.

FIX 1: Restart PC

As obvious as it may sound, but just doing a simple restart of the OPC did manage to rectify this issue for a few users. So before moving towards the advanced fixes, try out this basic one and check out the result.

Stable Diffusion Cuda Out of Memory

FIX 2: Install Anaconda with Nvidia CUDA Toolkit

For some users, installing Anaconda aka an open-source environment management system that allows you to install and run packages for Python along with the Nvidia CUDA Toolkit did the job. So install both these software onto your PC and then check if it fixes the Stable Diffusion Cuda Out of Memory error. 

FIX 3: Try out the Optimized variant of Stable Diffusion

There’s also a much more enhanced, efficient, and optimized open-source version of Stable Diffusion that is currently free from this Cuda Out of Memory error. So you could give it a try from its GitHub page and check if it works for you.

FIX 4: Generate Lower Resolution Images

You could also consider generating lower-resolution images as they are less resource hungry on your GPU. To do so, simply change the height and width values of the output to be generated inside Stable Diffusion.

Stable Diffusion Cuda Out of Memory

FIX 5: Reduce sample size to one

The more the merrier might not be true for such resource-extensive tasks, so you should consider reducing the output sample size to 1 so as to lower the overall burden on the GPU. To do so, you’ll have to enter “–n_samples 1”.

FIX 6: Edit webui-user.bat

For the unaware, Stable Diffusion uses the WebUI-user batch file to execute the required commands for generating images on your PC. So you could edit this file via notepad and add a few optimisation tweaks as mentioned in this GitHub page or check out these Reddit posts (1,2,3).

Stable Diffusion Cuda Out of Memory

These were the various methods to fix the Stable Diffusion Cuda Out of Memory error. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution at the earliest.

  • –medvram?