From daeabb3fdbee373df389f4c9e77d0c86c8c42882 Mon Sep 17 00:00:00 2001 From: LeagueRaINi Date: Sun, 18 Feb 2024 19:45:01 +0100 Subject: [PATCH] feat: add basic zluda support --- comfy/model_management.py | 19 ++++++++++++++++++- cuda_malloc.py | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/comfy/model_management.py b/comfy/model_management.py index 681208ea0..761ff699f 100644 --- a/comfy/model_management.py +++ b/comfy/model_management.py @@ -254,7 +254,24 @@ def get_torch_device_name(device): return "CUDA {}: {}".format(device, torch.cuda.get_device_name(device)) try: - print("Device:", get_torch_device_name(get_torch_device())) + torch_device_name = get_torch_device_name(get_torch_device()) + + if "[ZLUDA]" in torch_device_name: + print("Detected ZLUDA, support for it is experimental and comfy may not work properly.") + + if torch.backends.cudnn.enabled: + torch.backends.cudnn.enabled = False + print("Disabling cuDNN because ZLUDA does currently not support it.") + + torch.backends.cuda.enable_flash_sdp(True) + torch.backends.cuda.enable_math_sdp(False) + torch.backends.cuda.enable_mem_efficient_sdp(False) + + if ENABLE_PYTORCH_ATTENTION: + print("Disabling pytorch cross attention because ZLUDA does currently not support it.") + ENABLE_PYTORCH_ATTENTION = False + + print("Device:", torch_device_name) except: print("Could not pick default device.") diff --git a/cuda_malloc.py b/cuda_malloc.py index 144cdacd3..cb942bdd8 100644 --- a/cuda_malloc.py +++ b/cuda_malloc.py @@ -50,7 +50,9 @@ def cuda_malloc_supported(): except: names = set() for x in names: - if "NVIDIA" in x: + if "AMD" in x: + return False + elif "NVIDIA" in x: for b in blacklist: if b in x: return False