CUDA out of memory (ComfyUI / Stable Diffusion) — how to fix
Also seen as: "torch.cuda.OutOfMemoryError", "CUDA OOM", "GPU out of memory"
Direct answer
How do I fix "torch.cuda.OutOfMemoryError"?
A "CUDA out of memory" error means a GPU memory allocation failed. Check the model, resolution, batch size, other loaded models and available memory before choosing a larger GPU.
Key facts
- iThe model + activations exceed your GPU VRAM (e.g. an fp16 14B video model wanting ~28GB on a 24GB card).
- iResolution or batch size too high — VRAM scales with pixel count and batch.
- iA second model (upscaler, ControlNet, VAE) loaded alongside the main checkpoint.
- iFragmentation after many generations without a flush.
Next step
- 1Try a lower resolution (for example, 1024×1024 to 768×768) and batch size 1 before renting more memory.
- 2If the workflow supports it, try a compatible quantized checkpoint. Check its loader requirements and compare output quality.
- 3Add --lowvram / --medvram (or the WanVideoWrapper block-swap / offload nodes) to trade speed for VRAM.
- 4If logs show the workload exceeds available VRAM, consider a 48GB (A6000) or 80GB (A100) configuration after reviewing compatibility and the current quote.
If that didn't fix it
- An OOM at a small resolution does not by itself prove that a larger GPU is the only fix; inspect the failing stage and other memory use.
- Large full-precision checkpoints may exceed 24GB when kept fully in VRAM; supported offload and quantization can change the requirement.
Compare GPU memory options
A larger GPU can help when available VRAM is the bottleneck. These are hardware capacities, not a guarantee that your workflow runs unchanged. Review the current quote before starting.
| GPU | VRAM | Action |
|---|---|---|
| L4 | 24 GB | Review prices |
| A6000 | 48 GB | Review prices |
| A100 | 80 GB | Review prices |
| H100 | 80 GB | Review prices |
Rates and availability can change. Include startup, running time and any retained storage in your comparison.
Not sure this workflow will run before you rent a GPU?
Paste your ComfyUI workflow JSON into the free checker — it flags known dependencies and an estimated hardware requirement. It does not run the workflow, verify GPU capacity or judge output quality. No signup.
Other ComfyUI errors
Frequently Asked Questions
What causes "torch.cuda.OutOfMemoryError" in ComfyUI?
The model + activations exceed your GPU VRAM (e.g. an fp16 14B video model wanting ~28GB on a 24GB card).
How do I fix "torch.cuda.OutOfMemoryError"?
Try a lower resolution (for example, 1024×1024 to 768×768) and batch size 1 before renting more memory. If the workflow supports it, try a compatible quantized checkpoint. Check its loader requirements and compare output quality.
When could more GPU memory help?
A A6000 (48GB) has more memory than a 24GB card. It may help a workload that exceeds available VRAM, but check the failing stage, runtime compatibility and current quote first.