torch.cuda.OutOfMemoryError: CUDA out of memory in ComfyUI の直し方
ComfyUI の torch.cuda.OutOfMemoryError: CUDA out of memory を、解像度、batch size、読み込みモデル、VAE decode の調整で切り分けます。
実務向けメモ
このページは英語版 Wonderful Launcher docs と一般的な ComfyUI troubleshooting pattern に基づいています。パッケージや起動オプションを変える前に、重要な workflow は保存してください。
torch.cuda.OutOfMemoryError: CUDA out of memory または ComfyUI CUDA out of memory を見た場合、現在の workflow が GPU の VRAM に収まっていません。
多くの場合、ComfyUI のインストールが壊れたわけではありません。解像度、batch size、モデルサイズ、ControlNet、IP-Adapter、LoRA、video nodes などの組み合わせが、空き VRAM を超えています。
まず試すこと
- 画像解像度と batch size を下げる。
- ComfyUI を再起動して、断片化した VRAM を解放する。
- ControlNet、IP-Adapter、LoRA、upscaler、video branch を 1 つずつ外して試す。
- VAE Decode で落ちる場合は tiled VAE Decode を使う。
- エラーが明確に
CUDA out of memoryの間は、Torch を入れ直さない。
どのメモリが足りないか
| エラー文 | メモリ領域 | 最初の安全な対応 |
|---|---|---|
torch.cuda.OutOfMemoryError | GPU VRAM | 解像度、batch size、frame count、追加モデルを下げる |
CUDA out of memory during KSampler | Sampling が VRAM に収まらない | 小さい画像または軽いモデルで試す |
| OOM during VAE Decode | Sampling は通ったが最後の decode が重い | Tiled VAE Decode を使う |
MemoryError | System RAM | 他のアプリを閉じる、workflow を分割する |
DefaultCPUAllocator: not enough memory | CPU/System RAM | 大きな tensor を減らす、段階的に処理する |
Torch not compiled with CUDA enabled | PyTorch runtime | CUDA PyTorch のインストールを確認する |
よくある原因
- 解像度が高すぎる。
- batch size が 1 より大きい。
- SDXL、FLUX、video workflow が GPU の実用 VRAM を超えている。
- 複数のモデルや追加モジュールを同時に読み込んでいる。
- Browser、game、video tool などが VRAM を使っている。
- VAE Decode が最後に大きな VRAM spike を起こしている。
手順
1. 解像度と batch size を下げる
まず保守的な値で試します。
- SD 1.5: 512x512 または 512x768
- SDXL: 768x768 または 832x1216
- FLUX: 768x768 または quantized model
- Batch size: 1
2. メモリ節約オプションを試す
Windows portable build の例:
.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --lowvramそれでも足りない場合は --novram を試します。かなり遅くなりますが、小さい GPU では助けになることがあります。
3. 追加モデルを 1 つずつ外す
一度に全部変えないでください。次を 1 つずつ外して再実行します。
- extra ControlNet branches
- multiple LoRAs
- IP-Adapter stacks
- upscaler in the same run
- large video or frame workflow
これで base model が重いのか、追加 stack が VRAM を超えているのかを切り分けやすくなります。
4. Tiled VAE Decode を使う
Sampling は完了するのに最後の decode で落ちる場合は、通常の VAE Decode の代わりに tiled VAE Decode を使います。画像を小さい単位で decode できます。
5. VRAM 使用量を確認する
nvidia-smiGPU を使うアプリを閉じ、ComfyUI を再起動してから再試行してください。
やらない方がよいこと
- 明確な VRAM OOM なのに PyTorch を入れ直さない。
- ランダムな CUDA toolkit を入れない。
- GPU VRAM OOM の修復として Windows page file だけを増やさない。
- 複数の plugin と model を同時に変更しない。
Wonderful Launcher が役立つ場面
Wonderful Launcher は環境とログを整理し、最新エラーが VRAM、System RAM、Torch/CUDA、plugin import のどれに近いかを見分けやすくします。
関連ガイド
- Python Out of Memory in ComfyUI
- ComfyUI GPU Compatibility
- Torch Not Compiled With CUDA Enabled
- ComfyUI System Requirements
Source References
実際の ComfyUI 環境で起きている問題なら、まず無料で Wonderful Launcher を使って確認してください。ランチャー内の修復フロー、タスクログ、実行環境チェックを一か所で確認できます。クレジットは画像生成と従量ツール用です。
Wonderful Launcher をダウンロードクレジットプランを見るDid this fix your issue?
Your answer helps prioritize verified ComfyUI repairs.