From b1ea529c08ae522fc6177d6f44e20b826335fb0c Mon Sep 17 00:00:00 2001 From: Disty0 Date: Tue, 15 Aug 2023 00:50:46 +0300 Subject: [PATCH] Cleanup --- modules/ipex_specific/__init__.py | 4 +++- modules/ipex_specific/openvino.py | 1 - webui.sh | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/ipex_specific/__init__.py b/modules/ipex_specific/__init__.py index f8fdca2eb..7de07d78b 100644 --- a/modules/ipex_specific/__init__.py +++ b/modules/ipex_specific/__init__.py @@ -1,4 +1,5 @@ import os +import sys import contextlib import torch import intel_extension_for_pytorch as ipex @@ -39,6 +40,8 @@ def ipex_init(): torch.Tensor.is_cuda = torch.Tensor.is_xpu #Memory: + if 'linux' in sys.platform and "WSL2" in os.popen("uname -a").read(): + torch.xpu.empty_cache = lambda: None torch.cuda.empty_cache = torch.xpu.empty_cache torch.cuda.memory_stats = torch.xpu.memory_stats torch.cuda.memory_summary = torch.xpu.memory_summary @@ -76,7 +79,6 @@ def ipex_init(): #Fix functions with ipex: torch.cuda.mem_get_info = lambda device=None: [(torch.xpu.get_device_properties(device).total_memory - torch.xpu.memory_allocated(device)), torch.xpu.get_device_properties(device).total_memory] torch._utils._get_available_device_type = lambda: "xpu" # pylint: disable=protected-access - torch.xpu.empty_cache = torch.xpu.empty_cache if "WSL2" not in os.popen("uname -a").read() else lambda: None torch.cuda.get_device_properties.major = 2023 torch.cuda.get_device_properties.minor = 2 torch.backends.cuda.sdp_kernel = return_null_context diff --git a/modules/ipex_specific/openvino.py b/modules/ipex_specific/openvino.py index 5101c7d8e..917d3231f 100644 --- a/modules/ipex_specific/openvino.py +++ b/modules/ipex_specific/openvino.py @@ -5,7 +5,6 @@ from openvino.frontend.pytorch.torchdynamo.execute import execute from openvino.frontend.pytorch.torchdynamo.partition import Partitioner from torch._dynamo.backends.common import fake_tensor_unsupported from torch._dynamo.backends.registry import register_backend -from torch._inductor.compile_fx import compile_fx from torch.fx.experimental.proxy_tensor import make_fx class ModelState: diff --git a/webui.sh b/webui.sh index 59f235aac..38fc189b1 100755 --- a/webui.sh +++ b/webui.sh @@ -96,6 +96,10 @@ if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v then echo "Launching accelerate launch.py..." exec accelerate launch --num_cpu_threads_per_process=6 launch.py "$@" +elif [[ "$@" == *"--use-ipex"* ]] && [[ -z "${first_launch}" ]] && [ -x "$(command -v ipexrun)" ] && [ -x "$(command -v sycl-ls)" ] +then + echo "Launching ipexrun launch.py..." + exec ipexrun --multi-task-manager 'taskset' launch.py "$@" else echo "Launching launch.py..." exec "${python_cmd}" launch.py "$@"