Disables torch.backends.cudnn.benchmark on Python 3.12 to prevent
severe VRAM allocation spikes that occur during model operations.
The CUDNN benchmarking feature, introduced in v0.3.57 (commit e2d1e5da),
tests multiple convolution algorithms and allocates temporary VRAM.
This interacts poorly with Python 3.12's garbage collection behavior,
causing multi-GB VRAM spikes before and after model inference.
Solution:
- Preserves CUDNN benchmarking performance benefit on other Python versions
- Only disables the problematic behavior on Python 3.12
- Maintains full functionality while fixing memory management issues
- No impact on users not using --fast autotune flag
Tested with TTS model wrappers that reproduce the issue consistently
on Python 3.12 with ComfyUI v0.3.57+.
Fixes: VRAM spikes in Python 3.12 environments
Related: ComfyUI v0.3.57 regression affecting model memory management