From 417dbcb32f3ffa49fd9d1952c65fedfd94aaa356 Mon Sep 17 00:00:00 2001 From: Christopher Anderson Date: Sat, 8 Nov 2025 03:37:46 +1100 Subject: [PATCH] Add env TORCH_AMD_CUDNN_ENABLED --- comfy/model_management.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/comfy/model_management.py b/comfy/model_management.py index 7012df858..949d21dbd 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -338,8 +338,11 @@ try: if is_amd(): arch = torch.cuda.get_device_properties(get_torch_device()).gcnArchName if not (any((a in arch) for a in AMD_RDNA2_AND_OLDER_ARCH)): - torch.backends.cudnn.enabled = False # Seems to improve things a lot on AMD - logging.info("Set: torch.backends.cudnn.enabled = False for better AMD performance.") + torch.backends.cudnn.enabled = os.environ.get("TORCH_AMD_CUDNN_ENABLED", "0").strip().lower() not in { + "0", "off", "false", "disable", "disabled", "no"} + if not torch.backends.cudnn.enabled: + logging.info( + "ComfyUI has set torch.backends.cudnn.enabled to False for better AMD performance. Set environment var TORCH_AMD_CUDDNN_ENABLED=1 to enable it again.") try: rocm_version = tuple(map(int, str(torch.version.hip).split(".")[:2]))