Skip to content

Commit

Permalink
force cpu ep for zluda
Browse files Browse the repository at this point in the history
  • Loading branch information
lshqqytiger committed May 29, 2024
1 parent 93c40d6 commit 7a19dad
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/zluda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Union
import torch
from torch._prims_common import DeviceLikeType
import onnxruntime as ort
from modules import shared, devices


Expand Down Expand Up @@ -57,8 +58,14 @@ def initialize_zluda():
if hasattr(torch.backends.cuda, "enable_cudnn_sdp"):
torch.backends.cuda.enable_cudnn_sdp(False)
torch.backends.cuda.enable_cudnn_sdp = do_nothing

shared.opts.sdp_options = ['Math attention']

# ONNX Runtime is not supported
ort.capi._pybind_state.get_available_providers = lambda: [v for v in ort.get_available_providers() if v != 'CUDAExecutionProvider'] # pylint: disable=protected-access
ort.get_available_providers = ort.capi._pybind_state.get_available_providers # pylint: disable=protected-access
if shared.opts.onnx_execution_provider == 'CUDAExecutionProvider':
shared.opts.onnx_execution_provider = 'CPUExecutionProvider'

devices.device_codeformer = devices.cpu

result = test(device)
Expand Down

0 comments on commit 7a19dad

Please sign in to comment.