diff --git a/launch.py b/launch.py index c2e29d1db..4617e5f60 100755 --- a/launch.py +++ b/launch.py @@ -186,8 +186,6 @@ if __name__ == "__main__": except Exception: pass installer.read_options() - from modules.onnx_impl import initialize_olive - initialize_olive() if args.skip_all: args.quick = True installer.check_python() diff --git a/modules/loader.py b/modules/loader.py index a3fdb04ea..7c8d44a43 100644 --- a/modules/loader.py +++ b/modules/loader.py @@ -22,6 +22,7 @@ try: errors.log.debug(f'Load IPEX=={ipex.__version__}') except Exception: pass + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvision") import torchvision # pylint: disable=W0611,C0411 @@ -36,6 +37,10 @@ if ".dev" in torch.__version__ or "+git" in torch.__version__: torch.__version__ = re.search(r'[\d.]+[\d]', torch.__version__).group(0) timer.startup.record("torch") +from modules.onnx_impl import initialize_olive # pylint: disable=ungrouped-imports +initialize_olive() +timer.startup.record("olive") + from fastapi import FastAPI # pylint: disable=W0611,C0411 import gradio # pylint: disable=W0611,C0411 timer.startup.record("gradio") diff --git a/modules/onnx_impl/__init__.py b/modules/onnx_impl/__init__.py index a8174d11b..8e5ef7121 100644 --- a/modules/onnx_impl/__init__.py +++ b/modules/onnx_impl/__init__.py @@ -175,18 +175,24 @@ def initialize(): def initialize_olive(): + global run_olive_workflow # pylint: disable=global-statement from installer import installed, log - if not installed("olive-ai"): return - - global run_olive_workflow # pylint: disable=global-statement - + import sys + import importlib + orig_sys_path = sys.path try: - from olive.workflows import run as run_olive_workflow # pylint: disable=redefined-outer-name + spec = importlib.util.find_spec('onnxruntime.transformers') + sys.path = [d for d in spec.submodule_search_locations + sys.path if sys.path[1] not in d] + from onnxruntime.transformers import convert_generation # pylint: disable=unused-import + spec = importlib.util.find_spec('olive') + sys.path = spec.submodule_search_locations + sys.path + run_olive_workflow = importlib.import_module('olive.workflows').run except Exception as e: run_olive_workflow = None log.error(f'Olive: Failed to load olive-ai: {e}') + sys.path = orig_sys_path def install_olive():