mirror of
https://github.com/vladmandic/automatic
synced 2026-09-17 08:19:11 +02:00
monkey-patch sdnq to use sdnext devices/shared
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+1
-1
Submodule extensions-builtin/sdnq updated: 27a54aed65...01bc5b460e
+28
-10
@@ -551,16 +551,34 @@ def check_python(supported_minors=None, experimental_minors=None, reason=None):
|
||||
|
||||
|
||||
# register sdnq package from github submodule
|
||||
def register_sdnq():
|
||||
t_start = time.time()
|
||||
fn = os.path.join('extensions-builtin', 'sdnq', 'src', 'sdnq', '__init__.py')
|
||||
name = "sdnq"
|
||||
spec = importlib.util.spec_from_file_location(name, fn)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[name] = module
|
||||
spec.loader.exec_module(module) # this is where actual import happens
|
||||
import sdnq # pylint: disable=unused-import # test import
|
||||
ts('sdnq', t_start)
|
||||
def register_sdnq(skip=False, devices=None, shared=None):
|
||||
if not skip:
|
||||
print('HERE1')
|
||||
t_start = time.time()
|
||||
fn = os.path.join('extensions-builtin', 'sdnq', 'src', 'sdnq', '__init__.py')
|
||||
name = "sdnq"
|
||||
spec = importlib.util.spec_from_file_location(name, fn)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[name] = module
|
||||
spec.loader.exec_module(module) # this is where actual import happens
|
||||
import sdnq # pylint: disable=unused-import # test import
|
||||
ts('sdnq', t_start)
|
||||
if devices is not None:
|
||||
import sdnq
|
||||
sdnq.sdnext.devices = devices
|
||||
sdnq.quantizer.devices = devices
|
||||
sdnq.dequantizer.devices = devices
|
||||
sdnq.quant_utils.devices = devices
|
||||
sdnq.kernel_wrappers.devices = devices
|
||||
if shared is not None:
|
||||
import sdnq
|
||||
sdnq.sdnext.shared = shared
|
||||
sdnq.quantizer.shared = shared
|
||||
sdnq.dequantizer.shared = shared
|
||||
sdnq.quant_utils.shared = shared
|
||||
sdnq.kernel_wrappers.shared = shared
|
||||
sdnq.common.shared = shared
|
||||
sdnq.loader.shared = shared
|
||||
|
||||
|
||||
# check diffusers version
|
||||
|
||||
@@ -77,6 +77,9 @@ def initialize():
|
||||
log.debug('Initializing: modules')
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
|
||||
from installer import register_sdnq
|
||||
register_sdnq(skip=True, devices=modules.devices, shared=shared) # monkey-patch sdnq to use sdnext devices and shared modules
|
||||
|
||||
from modules.models_hf import hf_init
|
||||
hf_init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user