From 814778bc8d0649c05ac30747b325afbc2e80cf74 Mon Sep 17 00:00:00 2001 From: Seunghoon Lee Date: Thu, 9 May 2024 11:32:10 +0900 Subject: [PATCH] zluda restore torch <2.3 compatibility --- modules/zluda.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/zluda.py b/modules/zluda.py index 7192d6d64..945f434d8 100644 --- a/modules/zluda.py +++ b/modules/zluda.py @@ -36,13 +36,14 @@ def initialize_zluda(): if platform.system() == "Windows" and devices.cuda_ok and is_zluda(device): torch.backends.cudnn.enabled = shared.cmd_opts.use_zluda_dnn torch.backends.cuda.enable_flash_sdp(False) - torch.backends.cuda.enable_math_sdp(True) - torch.backends.cuda.enable_mem_efficient_sdp(False) - torch.backends.cuda.enable_cudnn_sdp(shared.cmd_opts.use_zluda_dnn and shared.cmd_opts.experimental) torch.backends.cuda.enable_flash_sdp = do_nothing + torch.backends.cuda.enable_math_sdp(True) torch.backends.cuda.enable_math_sdp = do_nothing + torch.backends.cuda.enable_mem_efficient_sdp(False) torch.backends.cuda.enable_mem_efficient_sdp = do_nothing - torch.backends.cuda.enable_cudnn_sdp = do_nothing + if hasattr(torch.backends.cuda, "enable_cudnn_sdp"): + torch.backends.cuda.enable_cudnn_sdp(shared.cmd_opts.use_zluda_dnn and shared.cmd_opts.experimental) + torch.backends.cuda.enable_cudnn_sdp = do_nothing shared.opts.sdp_options = ['Math attention'] if shared.cmd_opts.use_zluda_dnn and not shared.cmd_opts.experimental: torch.nn.functional.conv2d = conv2d_cudnn_disabled