Comfy-Org / Comfy-Org/ComfyUI

ComfyUI Crashes on VAE Encode While Using --fast Flag on A100

Open
#9,728 4 comments 0 reactions 0 assignees View on GitHub
Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 10h
Merged PRs (30d)
153

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

Workflow produces an image.

### Actual Behavior

Workflow crashes on VAE Encode and complains about CUDA OOM. Seems to be an issue with loading WAN VAEs, as this isn't exclusive to Qwen (it happens on WAN workflows too but this proof-of-concept is simpler).

### Steps to Reproduce

1.) You may need to replicate my environment, possibly specific to A100, but doesn't seem to matter what CUDA/pytorch/Python/etc. you go with as long as ComfyUI itself works.
2.) Launch ComfyUI with the --fast flag.
3.) Load up the cursed workflow: [Cursed Workflow.json](https://github.com/user-attachments/files/22166074/Cursed.Workflow.json)
4.) Try to run it.
5.) Watch it crash!

### Debug Logs

```powershell
OS: Ubuntu 22.04.5 LTS x86_64
Shell: /bin/bash
GPU: NVIDIA A100-SXM4-80GB
CPU: 8 x Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
Storage: 86G free of 194G
Memory: 63 GB

Python executable: /home/ubuntu/comfy-env/bin/python
Python version: 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0]
Torch version: 2.5.1+cu121
CUDA available: True
CUDA version (compiled): 12.1
cuDNN version: 91100
Device count: 1
Device 0: NVIDIA A100 80GB PCIe, 81152 MB VRAM, CC 8.0

(comfy-env) ubuntu@client-instance-01g1l9y0:~/ComfyUI$ python main.py --port 8888 --fast --disable-all-custom-nodes

Checkpoint files will always be loaded safely.
Total VRAM 81153 MB, total RAM 64306 MB
pytorch version: 2.5.1+cu121
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA A100 80GB PCIe : cudaMallocAsync
Torch version too old to set sdpa backend priority.
Using pytorch attention
Python version: 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0]
ComfyUI version: 0.3.57
ComfyUI frontend version: 1.25.11
[Prompt Server] web root: /home/ubuntu/comfy-env/lib/python3.10/site-packages/comfyui_frontend_package/static
Skipping loading of custom nodes
Context impl SQLiteImpl.
Will assume non-transactional DDL.
No target revision found.
Starting server

To see the GUI go to: http://127.0.0.1:8888
got prompt
Using pytorch attention in VAE
Using pytorch attention in VAE
VAE load device: cuda:0, offload device: cpu, dtype: torch.bfloat16
Requested to load WanVAE
loaded completely 41825.125 242.02829551696777 True
terminate called after throwing an instance of 'c10::Error'
what(): CUDA error: out of memory
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

Exception raised from c10_cuda_check_implementation at ../c10/cuda/CUDAException.cpp:43 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x96 (0x7be84feb9446 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::string const&)+ 0x64 (0x7be84fe636e4 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libc10.so)
frame #2: c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x118 (0x7be84ffa5a18 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libc10_cuda.so)
frame #3: + 0x600eb (0x7be84ffad0eb in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libc10_cuda.so)
frame #4: + 0x10a8c3b (0x7be8052a8c3b in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so)
frame #5: + 0x10a937b (0x7be8052a937b in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so)
frame #6: + 0x108bb6d (0x7be80528bb6d in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so)
frame #7: at::native::cudnn_convolution(at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, long, bool, bool, bool) + 0x53f (0x7be80528c4ef in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so)
frame #8: + 0x347170e (0x7be80767170e in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so)
frame #9: + 0x3485b11 (0x7be807685b11 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so)
frame #10: at::_ops::cudnn_convolution::call(at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, c10::SymInt, bool, bool, bool) + 0x2bb (0x7be83c242e2b in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #11: at::native::_convolution(at::Tensor const&, at::Tensor const&, std::optional const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, bool, c10::ArrayRef, long, bool, bool, bool, bool) + 0x1a73 (0x7be83b438f83 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #12: + 0x2e03e8f (0x7be83c603e8f in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #13: + 0x2e0ff9c (0x7be83c60ff9c in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #14: at::_ops::_convolution::call(at::Tensor const&, at::Tensor const&, std::optional const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef,bool, c10::ArrayRef, c10::SymInt, bool, bool, bool, bool) + 0x344 (0x7be83bd3cb94 in/home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #15: at::native::convolution(at::Tensor const&, at::Tensor const&, std::optional const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, bool, c10::ArrayRef, long) + 0x3b8 (0x7be83b42bae8 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #16: + 0x2e033cc (0x7be83c6033cc in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #17: + 0x2e0fc88 (0x7be83c60fc88 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #18: at::_ops::convolution::call(at::Tensor const&, at::Tensor const&, std::optional const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, bool, c10::ArrayRef, c10::SymInt) + 0x2d4 (0x7be83bd3b994 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #19: + 0x19831b0 (0x7be83b1831b0 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #20: at::native::conv3d_symint(at::Tensor const&, at::Tensor const&, std::optional const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, c10::SymInt) + 0x16f (0x7be83b42f8ef in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #21: + 0x3009033 (0x7be83c809033 in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #22: + 0x30092cd (0x7be83c8092cd in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #23: at::_ops::conv3d::call(at::Tensor const&, at::Tensor const&, std::optionalconst&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, c10::SymInt) + 0x26e (0x7be83c24030e in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so)
frame #24: + 0x7442bd (0x7be84ed442bd in /home/ubuntu/comfy-env/lib/python3.10/site-packages/torch/lib/libtorch_python.so)

[Cursed Workflow.json](https://github.com/user-attachments/files/22165902/Cursed.Workflow.json)
```

### Other

Definitely nothing I'm overlooking, this problem lies within how ComfyUI handles the --fast flag. I've spent 25 or so hours debugging - I've nailed the cause down, even if I don't know what under the hood is causing it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.