From 8ae3b5bb43b8118c8f5e990dbc0f84f55d3c0360 Mon Sep 17 00:00:00 2001 From: Seunghoon Lee Date: Sat, 17 Feb 2024 20:56:10 +0900 Subject: [PATCH] remove zluda force sync --- modules/shared.py | 2 +- modules/zluda.py | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/modules/shared.py b/modules/shared.py index 412ccfdbe..a192d9b9b 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -404,7 +404,7 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "olive_cache_optimized": OptionInfo(True, 'Olive cache optimized models'), "zluda_sep": OptionInfo("

ZLUDA

(experimental)", "", gr.HTML, {"visible": devices.backend == "cuda"}), - "zluda_force_sync": OptionInfo(False, 'ZLUDA force synchronization (experimental, restart required)', gr.Checkbox, {"visible": devices.backend == "cuda"}), + "zluda_enable_cudnn": OptionInfo(False, 'ZLUDA enable cuDNN (restart required)', gr.Checkbox, {"visible": devices.backend == "cuda"}), })) options_templates.update(options_section(('advanced', "Inference Settings"), { diff --git a/modules/zluda.py b/modules/zluda.py index 48f5dee8a..e2d7d15bb 100644 --- a/modules/zluda.py +++ b/modules/zluda.py @@ -1,23 +1,13 @@ import platform import torch -from diffusers.models.attention_processor import AttnProcessor from modules import shared, devices def initialize_zluda(): if platform.system() == "Windows" and devices.cuda_ok and torch.cuda.get_device_name(devices.get_optimal_device()).endswith("[ZLUDA]"): shared.log.warning("Detected ZLUDA device. Currently, ZLUDA support is experimental and unstable.") - torch.backends.cudnn.enabled = False + torch.backends.cudnn.enabled = shared.opts.zluda_enable_cudnn + if torch.backends.cudnn.enabled: + shared.log.warning("cuDNN with ZLUDA won't work at this moment. Please wait for future update.") if shared.opts.cross_attention_optimization == "Scaled-Dot-Product": - shared.opts.cross_attention_optimization = "Batch matrix-matrix" - if shared.opts.zluda_force_sync: - patch_attention_processor(AttnProcessor) - - -def patch_attention_processor(cls): - forward = cls.__call__ - def patched(self, *args, **kwargs): - R = forward(self, *args, **kwargs) - torch.cuda.synchronize() - return R - cls.__call__ = patched + shared.log.warning("ZLUDA does not support Scaled-Dot-Product attention. Please consider changing it to Batch matrix-matrix.")