CUDNN Toggle Ovum
Toggle cuDNN around a single node
- any_input
- any_output
- prev_cudnn
This node exists for one very specific audience: people running ComfyUI on an AMD GPU through ZLUDA - the translation layer that lets CUDA software run on AMD hardware. If that's not you, you can probably skip it. If it is you, this might be worth a couple of percentage points you didn't know you were leaving on the table.
The idea is simple. torch.backends.cudnn.enabled is a global torch flag that decides whether cuDNN (CUDA's neural-network library) is used for convolutions. Under ZLUDA, cuDNN isn't running on native CUDA hardware - it's being emulated, and the emulation's heuristics can be catastrophically bad for certain operations. The author's claim, and the reason the node exists: disabling cuDNN around VAE Encode and VAE Decode can give up to 2× speedup on ZLUDA. That tracks with real community reports - people on 7900XTX/7900GRE setups building faster ZLUDA stacks have found that cuDNN/miOpen behaves unpredictably and some ops get faster with it off. The catch: you don't want it off for the whole graph, only for the ops it hurts.
How it works
The node sets torch.backends.cudnn.enabled (and sets benchmark to match) to whatever enable_cudnn says. It's a passthrough in both directions:
- any_input / any_output - carry an IMAGE or LATENT through the node, so you can place it immediately before and after the node you're targeting. This is what guarantees execution order: the toggle runs right before the VAE, the VAE runs, the toggle runs right after.
- prev_cudnn (BOOLEAN) - the previous state, captured before the flip. Wire this into the
enable_cudnninput of a second CUDNN Toggle placed after the target node, and the graph restores whatever the original setting was, no matter what it was. That's the right pattern:
[Toggle, enable_cudnn=false] → [VAE Decode] → [Toggle, enable_cudnn=<prev_cudnn>]
Intercept the tensor on both sides so the toggles execute in the right order, and you've wrapped the VAE in a cuDNN-free sandwich that re-enables itself afterward.
The inputs you actually touch
Just one, really: enable_cudnn. Set it false on the disabling node before the slow op, and let prev_cudnn restore things after. The passthroughs are plumbing, not settings.
Installing it
It's in comfy-ovum:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart, or grab it via ComfyUI Manager ("comfy-ovum"). No extra dependencies - it only touches torch, which you obviously already have.
Gotchas
This is not a magic button. On a plain NVIDIA setup cuDNN is doing real work and you almost certainly want it on; toggling it will just slow you down. On ZLUDA the wins are real but vary by op, driver, and ZLUDA build, so benchmark before and after - the whole point of the passthrough design is that it's easy to A/B. And remember the flag is global to the process, which is exactly why the node exists in a save/restore pair. Don't leave the graph in a "cuDNN off" state and run other things expecting default behavior.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| enable_cudnn | BOOLEAN | true | — |
| any_inputopt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| any_output | * | — |
| prev_cudnn | BOOLEAN | — |