From 9241c00e1289dbd7bab3cf6509f1438acd70aa1c Mon Sep 17 00:00:00 2001 From: Qiacheng Date: Thu, 16 Nov 2023 10:28:54 -0800 Subject: [PATCH] simplify installation process --- modules/launch_utils.py | 10 +++++++--- requirements.txt | 6 +++--- requirements_versions.txt | 4 ++-- scripts/openvino_accelerate.py | 17 ++++++++++++++++- webui-user.bat | 6 +++++- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 6e54d06367c..885dd68a2e6 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -308,9 +308,13 @@ def requirements_met(requirements_file): def prepare_environment(): - torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu118") - torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url {torch_index_url}") - requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt") + if os.environ.get("USE_OPENVINO") == "1": + torch_command = os.environ.get('TORCH_COMMAND', "pip install torch==2.1.0 torchvision==0.16.0") + requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt") + else: + torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu118") + torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url {torch_index_url}") + requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt") xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.20') clip_package = os.environ.get('CLIP_PACKAGE', "https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip") diff --git a/requirements.txt b/requirements.txt index 6aa782ce83d..3f5613efc54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,8 +31,8 @@ tomesd torch torchdiffeq torchsde -diffusers==0.21.1 -openvino==2023.1.0.dev20230811 +diffusers +openvino invisible-watermark -transformers==4.30.2 +transformers diff --git a/requirements_versions.txt b/requirements_versions.txt index 2ba1c7b4073..cbc6d0bf221 100644 --- a/requirements_versions.txt +++ b/requirements_versions.txt @@ -30,8 +30,8 @@ torch torchdiffeq==0.2.3 torchsde==0.2.5 transformers==4.30.2 -diffusers==0.21.1 -openvino==2023.1.0.dev20230811 +diffusers==0.23.0 +openvino==2023.2.0 invisible-watermark diff --git a/scripts/openvino_accelerate.py b/scripts/openvino_accelerate.py index 20dde2f0bb7..240e44382ca 100644 --- a/scripts/openvino_accelerate.py +++ b/scripts/openvino_accelerate.py @@ -63,6 +63,21 @@ AutoencoderKL, ) +#ignore future warnings +import warnings +warnings.simplefilter(action='ignore', category=FutureWarning) + +##hack eval_frame.py for windows support, could be removed after official windows support from pytorch +def check_if_dynamo_supported(): + import sys + # Skip checking for Windows support for the OpenVINO backend + if sys.version_info >= (3, 12): + raise RuntimeError("Python 3.12+ not yet supported for torch.compile") + +torch._dynamo.eval_frame.check_if_dynamo_supported = check_if_dynamo_supported + + + ## hack for pytorch def BUILD_MAP_UNPACK(self, inst): @@ -801,7 +816,7 @@ def infotext(iteration=0, position_in_batch=0): cn_params = p.extra_generation_params[key] cn_param_elements = [part.strip() for part in cn_params.split(', ')] for element in cn_param_elements: - if (element.split(':')[0] == "Model"): + if (element.split(':')[0] == "model"): cn_model = (element.split(':')[1]).split(' ')[1] if (cn_model != "None"): diff --git a/webui-user.bat b/webui-user.bat index e5a257bef06..f30e476d330 100644 --- a/webui-user.bat +++ b/webui-user.bat @@ -1,8 +1,12 @@ + @echo off set PYTHON= set GIT= set VENV_DIR= -set COMMANDLINE_ARGS= +set COMMANDLINE_ARGS=--skip-torch-cuda-test --precision full --no-half +set PYTORCH_TRACING_MODE=TORCHFX +set USE_OPENVINO=1 call webui.bat +