LogoWonderful Launcher
  • Home
  • Pricing
  • Docs
  • Download

ComfyUI CUDA Out of Memory Fix: torch.cuda.OutOfMemoryError

Partially verifiedMedium riskLast verified 2026-06-10

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:

PatternWhat it usually meansBest first move
OOM during KSamplerThe active model/workflow is too large for current VRAMLower resolution and batch size
OOM during VAE decodeSampling fit, final image decode did notSwitch to tiled VAE decode
OOM after adding ControlNet, IP-Adapter, or LoRA stacksToo many models are loaded togetherRemove one extra conditioning stack and retest
OOM on FLUX or video workflowsModel family exceeds the card's practical VRAM limitUse quantized models or smaller workflows
OOM even at modest settingsOther apps are consuming VRAM or memory is fragmentedClose GPU-heavy apps and relaunch

Fast answer

Try these in order:

  1. Lower your image resolution (e.g., from 1024x1024 to 768x768)
  2. Set batch size and video frame count to the smallest useful values
  3. Remove extra ControlNet, IP-Adapter, LoRA, or upscaler branches and retry
  4. Enable tiled VAE decoding if sampling finishes but final decode fails
  5. Use --lowvram only 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 memory
Error 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 memory usually means the workflow is too large for current VRAM
  • Torch not compiled with CUDA enabled is a different problem
  • CUDA is not available is a runtime/configuration problem
  • Python MemoryError usually 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 wordingMemory poolFirst safe action
torch.cuda.OutOfMemoryError or CUDA out of memoryGPU VRAMLower resolution, batch size, frame count, or loaded extras
MemoryErrorSystem RAMClose RAM-heavy apps, split the workflow, or increase page file if Windows is paging heavily
DefaultCPUAllocator: not enough memorySystem RAM / CPU tensor allocationReduce large image/video tensors or split the workflow into stages
Page-file or commit-limit errorWindows virtual memory / system commitIncrease page file and reduce concurrent apps before changing ComfyUI packages
Torch not compiled with CUDA enabledPyTorch runtime, not memoryFix 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

ModelMinimum VRAMComfortable VRAMNotes
SD 1.54 GB6 GBMost compatible
SDXL6 GB8 GBDefault 1024x1024
FLUX.18 GB (quantized)12 GBfp8 recommended for 8GB cards
Video models12 GB24 GBHighly 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 --lowvram

Available flags:

FlagEffectVRAM saved
--lowvramMoves model parts to CPU during generationSignificant
--novramKeeps almost everything on CPU, moves to GPU only when neededMaximum, but much slower
--cpuRuns entirely on CPUAll GPU VRAM free, very slow
--disable-smart-memoryDisables automatic memory managementTry 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-smi

Close 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-fp16

This 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, or DefaultCPUAllocator, 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

  • PyTorch CUDA Semantics
  • ComfyUI CLI Arguments
  • NVIDIA CUDA Documentation

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 packages

Did this fix your issue?

Your answer helps prioritize verified ComfyUI repairs.

Table of Contents

The OOM cases we see most often
What the error looks like
Why it happens
Before you change anything
Classify the memory pool first
VRAM requirements by model type
Step-by-step fixes
1. Lower resolution and batch size
2. Use ComfyUI memory management flags
2.5 Reduce loaded extras before changing core runtime
3. Use quantized or fp16 models
4. Enable tiled VAE decode
5. Close other GPU applications
6. Use --force-fp16 for the entire pipeline
What not to do
When OOM is a hardware limit, not a bug
How Wonderful Launcher can help
Related errors
Source References