remove zluda force sync

This commit is contained in:
Seunghoon Lee
2024-02-17 20:56:10 +09:00
parent 6e412d406b
commit 8ae3b5bb43
2 changed files with 5 additions and 15 deletions
+1 -1
View File
@@ -404,7 +404,7 @@ options_templates.update(options_section(('cuda', "Compute Settings"), {
"olive_cache_optimized": OptionInfo(True, 'Olive cache optimized models'),
"zluda_sep": OptionInfo("<h2>ZLUDA</h2>(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"), {
+4 -14
View File
@@ -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.")