⚠️ OOM Troubleshooting Guide

How to Fix "torch.cuda.OutOfMemoryError" in ComfyUI

Step-by-step solutions to resolve GPU memory allocation crashes in Stable Diffusion, Flux, and SDXL pipelines.

Error Signature:torch.cuda.OutOfMemoryError: CUDA out of memory

⚡ Quick Direct Answer

Launch ComfyUI with the `--medvram` or `--lowvram` flag, enable tiled VAE decode, or decrease the latent batch size and output resolution.

Why Does This Error Happen?

Your generation workflow attempted to allocate more VRAM than your physical graphics card holds, or memory fragmented during high-resolution upscaling/UNet execution.

Recommended Startup Flags

Add these to your `run_nvidia_gpu.bat` or startup command to optimize memory usage:

--medvram--lowvram--fp8_e4m3fn-unet

Still Crashing on Your Local GPU?

Skip compilation conflicts and memory limits by deploying on high-VRAM Cloud GPUs starting at pennies/hour.

Frequently Asked Questions

What launch flag is best for 8GB cards like RTX 3070 or RTX 4060?

Use `--medvram`. It moves model weights between system RAM and VRAM during execution with minimal speed penalty.

Why did my generation crash during VAE Decode even if sampling finished?

Standard VAE decoding decodes the entire latent image in one massive uncompressed batch. Replace your standard VAE Decode node with "VAE Decode (Tiled)" to reduce decode memory to under 512MB.