PROMPT GUIDE
How to Fix CUDA Out of Memory (When Image Generation Runs Out of Memory)
While making AI illustrations, you may be stopped by an error called "CUDA out of memory." A row of red English text is startling, but the meaning is simple: the graphics card's memory (VRAM) has run short. This guide sums up how to read the error and how to fix it, in the order that is most likely to work.
Last updated: approx. 3 min read
The short answer
CUDA out of memory is the error shown when the graphics card's memory (VRAM) runs short. Trying these in order usually fixes it: lower the image size, set the batch size to 1, restart the screen to free memory, and remove extensions and models you are not using. If it still appears, consider memory-saving settings or a lighter model.
What kind of error is CUDA out of memory?
It is the error shown when the graphics card's memory (VRAM) runs short.
CUDA is the name of the mechanism for doing calculations on a graphics card. "Out of memory" means "not enough memory," so the whole message says "the graphics card is out of memory." The text of the error sometimes says how much more was needed, as in "Tried to allocate X GiB." When the number is small, a little adjustment is enough, and when it is large, it is a sign to review the settings considerably. The wording of the message differs between versions, so judge by the meaning of the sentence.
What can you try right away to fix it?
Try, in the order that is most likely to work: size, batch, restart, then extensions.
Steps for fixing a memory shortage error
- Set the batch size (how many images are made at once) to 1
- Make the width and height of the image smaller (for example, start from around 512 by 768 for vertical)
- If you are using Hires.fix or enlarging, lower the scale or turn it off for now
- Turn off ControlNet, LoRAs and extensions you are not using
- Close the screen (WebUI), start it again and free the memory in use
- Close other apps (browser video, games, other image software)
- If it still appears, use memory-saving startup settings
Batch size: 1 / Width: 512 / Height: 768 / Hires.fix: off (first check that it runs)Example of a startup setting (startup argument for AUTOMATIC1111-style tools): --medvramRinka's tips
- If it worked the first time but starts to appear after making a few images, memory is being taken up little by little. Restarting often brings it back
- The names of startup settings differ by version and tool. Check the explanation for the tool you use
For measures to take first on a computer with little VRAM, see How to Run Stable Diffusion on a Computer with Little VRAM (Settings to Lighten It) →



How do you prevent it before it appears?
If you change to making pictures small and enlarging only the ones you like, the error is less likely to appear.
If you make many large pictures from the start, you come close to the memory limit. First look for a composition at a small size with the batch size at 1, fix the seed of a good picture, and then enlarge it with high-resolution finishing. Turning extensions on only when you use them, and off when you are done, also helps.
- Normally make pictures at a small size with the batch size at 1
- Use ControlNet and extra LoRAs only when needed
- After making dozens of pictures, restart the screen at a stopping point
- Do not open other heavy apps while generating
What if it appears again after you fixed it? (Common failures and fixes)
There can be more than one cause, so check them one by one in the order of the table.
To make the enlarging settings lighter, see Hires.fix Settings (Upscale Ratio, Denoising Strength, Upscaler) →
To find the cause when a picture breaks, see AI Art Troubleshooting Guide (Look Up Fixes by Symptom) →
For how to read the screen of a tool that makes memory easier to manage, see How to Use Stable Diffusion Forge (Reading the UI and Making Your First Image) →
FAQ
Frequently Asked Questions
Is CUDA out of memory a breakdown?
No. It is not a failure of the graphics card; the memory just ran short for the settings. Lowering the size or batch fixes it in many cases.
Why does restarting fix it?
As you keep generating, memory you have finished using may not be freed completely. Closing the screen and starting it again frees the memory cleanly.
Will the picture get worse if I lower the size?
It is common to decide the composition at a small size and enlarge it later with high-resolution finishing. You can try it lightly, so you fail less than by making large pictures from the start.
How can I get more memory?
What runs short in image generation is the graphics card's VRAM, so adding ordinary computer memory does not fix it. To get more VRAM you need to replace the graphics card. If that is not possible, consider a browser-based service.
RINKA WORLD
Play in Rinka World
MORE