Skip to content

Commit

Permalink
Re-add SD_LORA_DIFFUSERS flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Disty0 committed Dec 2, 2023
1 parent 24250ac commit 7195087
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions extensions-builtin/Lora/lora_patches.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import torch
import networks
from modules import patches, shared
Expand All @@ -18,7 +19,7 @@ def __init__(self):
self.MultiheadAttention_load_state_dict = None

def apply(self):
if self.active or (shared.opts.cuda_compile and shared.opts.cuda_compile_backend == "openvino_fx"): # OpenVINO only works with Diffusers LoRa loading
if self.active or (os.environ.get('SD_LORA_DIFFUSERS', None) is not None): # OpenVINO only works with Diffusers LoRa loading
return
self.Linear_forward = patches.patch(__name__, torch.nn.Linear, 'forward', networks.network_Linear_forward)
self.Linear_load_state_dict = patches.patch(__name__, torch.nn.Linear, '_load_from_state_dict', networks.network_Linear_load_state_dict)
Expand All @@ -36,7 +37,7 @@ def apply(self):
self.active = True

def undo(self):
if not self.active or (shared.opts.cuda_compile and shared.opts.cuda_compile_backend == "openvino_fx"): # OpenVINO only works with Diffusers LoRa loading
if not self.active or (os.environ.get('SD_LORA_DIFFUSERS', None) is not None): # OpenVINO only works with Diffusers LoRa loading
return
self.Linear_forward = patches.undo(__name__, torch.nn.Linear, 'forward') # pylint: disable=E1128
self.Linear_load_state_dict = patches.undo(__name__, torch.nn.Linear, '_load_from_state_dict') # pylint: disable=E1128
Expand Down
3 changes: 1 addition & 2 deletions extensions-builtin/Lora/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ def load_networks(names, te_multipliers=None, unet_multipliers=None, dyn_dims=No
try:
if recompile_model:
shared.compiled_model_state.lora_model.append(f"{name}:{te_multipliers[i] if te_multipliers else 1.0}")
if shared.backend == shared.Backend.DIFFUSERS and (os.environ.get('SD_LORA_DIFFUSERS', None) is not None
or (shared.opts.cuda_compile and shared.opts.cuda_compile_backend == "openvino_fx")): # OpenVINO only works with Diffusers LoRa loading.
if shared.backend == shared.Backend.DIFFUSERS and (os.environ.get('SD_LORA_DIFFUSERS', None) is not None): # OpenVINO only works with Diffusers LoRa loading.
# or getattr(network_on_disk, 'shorthash', '').lower() == 'aaebf6360f7d' # sd15-lcm
# or getattr(network_on_disk, 'shorthash', '').lower() == '3d18b05e4f56' # sdxl-lcm
# or getattr(network_on_disk, 'shorthash', '').lower() == '813ea5fb1c67' # turbo sdxl-turbo
Expand Down
1 change: 1 addition & 0 deletions installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ def check_torch():
install('openvino==2023.2.0', 'openvino')
install('onnxruntime-openvino', 'onnxruntime-openvino', ignore=True) # TODO openvino: numpy version conflicts with tensorflow and doesn't support Python 3.11
os.environ.setdefault('PYTORCH_TRACING_MODE', 'TORCHFX')
os.environ.setdefault('SD_LORA_DIFFUSERS', '1')
os.environ.setdefault('NEOReadDebugKeys', '1')
os.environ.setdefault('ClDeviceGlobalMemSizeAvailablePercent', '100')
if args.profile:
Expand Down

0 comments on commit 7195087

Please sign in to comment.