ComfyUI CUDA Out of Memory Fix: torch.cuda.OutOfMemoryError
Fix ComfyUI CUDA out of memory by lowering resolution, batch size, frame count, loaded model extras, and VAE decode memory.
Community Knowledge
This page is based on common ComfyUI troubleshooting patterns and has not been fully tested across all environments. Back up your environment before changing packages.
If you searched for ComfyUI CUDA out of memory, torch.cuda.OutOfMemoryError: CUDA out of memory, or ComfyUI out of memory fix, your GPU does not have enough VRAM for the current operation.
This is usually not a broken installation. It means the generation settings, model size, loaded extras, or resolution exceed what your GPU can hold in memory at once. The good news is that most OOM errors can be fixed without buying a new GPU.
The OOM cases we see most often
In real support and launcher telemetry, CUDA OOM usually appears in one of these patterns:
| Pattern | What it usually means | Best first move |
|---|---|---|
OOM during KSampler | The active model/workflow is too large for current VRAM | Lower resolution and batch size |
| OOM during VAE decode | Sampling fit, final image decode did not | Switch to tiled VAE decode |
| OOM after adding ControlNet, IP-Adapter, or LoRA stacks | Too many models are loaded together | Remove one extra conditioning stack and retest |
| OOM on FLUX or video workflows | Model family exceeds the card's practical VRAM limit | Use quantized models or smaller workflows |
| OOM even at modest settings | Other apps are consuming VRAM or memory is fragmented | Close GPU-heavy apps and relaunch |
Fast answer
Try these in order:
- Lower your image resolution (e.g., from 1024x1024 to 768x768)
- Set batch size and video frame count to the smallest useful values
- Remove extra ControlNet, IP-Adapter, LoRA, or upscaler branches and retry
- Enable tiled VAE decoding if sampling finishes but final decode fails
- Use
--lowvramonly after reducing the workflow itself
What the error looks like
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.00 GiB.
GPU 0 has a total capacity of 8.00 GiB of which 512.00 MiB is free.
Including non-PyTorch memory, this process has 7.48 GiB memory in use.You may also see variations like:
RuntimeError: CUDA error: out of memoryError occurred when executing KSampler:
CUDA out of memory.Not enough GPU memory. Try reducing image resolution or batch size and run again.The error typically occurs during sampling, VAE decoding, or model loading. The "not enough GPU memory" message is ComfyUI's friendly rendering of the same CUDA OOM condition — the fix is identical: lower resolution, batch size, or frame count before changing any packages.
Why it happens
- Resolution too high: Larger images use exponentially more VRAM. A 2048x2048 image uses roughly 4x the VRAM of a 1024x1024 image
- Model too large for your GPU: SDXL models need more VRAM than SD 1.5 models. FLUX models need even more
- Multiple models loaded: Loading a checkpoint, ControlNet, IP-Adapter, and LoRA simultaneously adds up
- Batch size too high: Generating multiple images at once multiplies VRAM usage
- VAE decode at full resolution: The VAE decode step can spike VRAM even when sampling succeeded
- Other programs using GPU memory: Chrome, Discord, or other GPU-accelerated apps consume VRAM
Before you change anything
Check whether the error is really CUDA OOM and not another runtime issue:
CUDA out of memoryusually means the workflow is too large for current VRAMTorch not compiled with CUDA enabledis a different problemCUDA is not availableis a runtime/configuration problem- Python
MemoryErrorusually points to system RAM, not GPU VRAM
If the wording changed after a restart, always follow the newest first error.
Classify the memory pool first
Different memory errors need different fixes. If the repair path starts from the wrong pool, it can waste time or make the environment noisier.
| Error wording | Memory pool | First safe action |
|---|---|---|
torch.cuda.OutOfMemoryError or CUDA out of memory | GPU VRAM | Lower resolution, batch size, frame count, or loaded extras |
MemoryError | System RAM | Close RAM-heavy apps, split the workflow, or increase page file if Windows is paging heavily |
DefaultCPUAllocator: not enough memory | System RAM / CPU tensor allocation | Reduce large image/video tensors or split the workflow into stages |
| Page-file or commit-limit error | Windows virtual memory / system commit | Increase page file and reduce concurrent apps before changing ComfyUI packages |
Torch not compiled with CUDA enabled | PyTorch runtime, not memory | Fix the CUDA PyTorch install path first |
Do not reinstall PyTorch just because the word "memory" appears in the log. Reinstalling packages is only relevant if the newest error says CUDA is unavailable, Torch is CPU-only, or a dependency import failed.
VRAM requirements by model type
| Model | Minimum VRAM | Comfortable VRAM | Notes |
|---|---|---|---|
| SD 1.5 | 4 GB | 6 GB | Most compatible |
| SDXL | 6 GB | 8 GB | Default 1024x1024 |
| FLUX.1 | 8 GB (quantized) | 12 GB | fp8 recommended for 8GB cards |
| Video models | 12 GB | 24 GB | Highly variable |
Step-by-step fixes
1. Lower resolution and batch size
The fastest fix. Reduce your image dimensions:
- SD 1.5: try 512x512 or 512x768
- SDXL: try 768x768 or 832x1216
- FLUX: try 768x768 first
Set batch size to 1 if it is higher.
2. Use ComfyUI memory management flags
Launch ComfyUI with memory-saving arguments:
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --lowvramAvailable flags:
| Flag | Effect | VRAM saved |
|---|---|---|
--lowvram | Moves model parts to CPU during generation | Significant |
--novram | Keeps almost everything on CPU, moves to GPU only when needed | Maximum, but much slower |
--cpu | Runs entirely on CPU | All GPU VRAM free, very slow |
--disable-smart-memory | Disables automatic memory management | Try if auto management causes issues |
2.5 Reduce loaded extras before changing core runtime
If you are using a large workflow, remove one class of extra model at a time and retry:
- extra ControlNet branches
- multiple LoRAs
- IP-Adapter stacks
- upscalers loaded in the same run
- large video or high-frame workflows
This usually tells you faster whether the limit is coming from the base model or from stacked conditioning.
3. Use quantized or fp16 models
Full fp32 models use twice the VRAM of fp16 models. fp8 models use even less:
- Download fp16 checkpoints when available
- For FLUX, use fp8 quantized checkpoints on 8 GB GPUs
- Some checkpoint sites label these as "fp16-fix" or "pruned"
4. Enable tiled VAE decode
If the OOM happens during VAE decode (the final step), add a VAE Decode (Tiled) node instead of the regular VAE Decode. Tiled decoding processes the image in smaller chunks.
5. Close other GPU applications
Check what else is using VRAM:
nvidia-smiClose browsers, games, video editors, or other applications that consume GPU memory before generating.
6. Use --force-fp16 for the entire pipeline
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --force-fp16This forces all operations to use fp16 precision, roughly halving VRAM usage at the cost of minor quality differences.
What not to do
- Do not increase Windows virtual memory (pagefile) thinking it will fix GPU OOM — VRAM and system RAM are separate
- Do increase page file only when the error is system RAM, commit limit,
MemoryError, orDefaultCPUAllocator, not when the traceback is clearly CUDA VRAM - Do not reinstall ComfyUI — this is a resource limit, not a broken install
- Do not install random CUDA toolkits — the PyTorch wheel includes what it needs
- Do not ignore the specific numbers in the error message — they tell you exactly how much VRAM you have and how much was requested
When OOM is a hardware limit, not a bug
Sometimes the environment is fine and the workflow simply exceeds the card:
- 6 GB cards often need more conservative SDXL settings
- 8 GB cards often need quantized FLUX or smaller resolutions
- video pipelines can exceed 12 GB very quickly
In those cases, the fix is workflow sizing, quantization, tiling, or a different model family — not reinstalling ComfyUI.
How Wonderful Launcher can help
Wonderful Launcher can detect your GPU's VRAM capacity and help identify and suggest memory optimization settings. It also helps manage model formats and suggests compatible settings for your hardware.
Download Wonderful Launcher — it's free and can optimize your ComfyUI setup for your specific GPU.
Related errors
- ComfyUI GPU Compatibility
- Python Out of Memory in ComfyUI
- ComfyUI System Requirements
- Torch Not Compiled With CUDA Enabled
- ComfyUI Common Issues
Source References
Start free with Wonderful Launcher if this affects your real ComfyUI environment. It keeps launcher-native repair, task logs, and runtime checks in one place; credits are only for image generation and metered tools.
Download Wonderful LauncherSee credit packagesDid this fix your issue?
Your answer helps prioritize verified ComfyUI repairs.