From 68206fbc0583c283b5448ce6b13f92a10b6db3a3 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Wed, 13 Dec 2023 18:19:08 +0300 Subject: [PATCH] IPEX update to PyTorch 2.1 wheels for Linux --- CHANGELOG.md | 1 + installer.py | 2 +- modules/intel/ipex/__init__.py | 6 ------ modules/intel/ipex/hijacks.py | 8 ++++---- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6e6f255f..c8ca24915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - **Extra networks** new *settting -> extra networks -> build info on first access* indexes all networks on first access instead of server startup - **IPEX** + - Update to **Torch 2.1 - This Update Requires Intel OneApi 2024.0**, thanks @disty0 - Fix IPEX Optimize not applying with Diffusers backend, thanks @disty0 - Disable 32 bit workarounds if the GPU supports 64 bit, thanks @disty0 - More compatibility improvements, thanks @disty0 diff --git a/installer.py b/installer.py index e9d8e20c7..bb957f9b4 100644 --- a/installer.py +++ b/installer.py @@ -424,7 +424,7 @@ def check_torch(): os.environ.setdefault('NEOReadDebugKeys', '1') os.environ.setdefault('ClDeviceGlobalMemSizeAvailablePercent', '100') if "linux" in sys.platform: - torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.0.1a0 torchvision==0.15.2a0 intel_extension_for_pytorch==2.0.110+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/') + torch_command = os.environ.get('TORCH_COMMAND', 'torch==2.1.0a0 torchvision==0.16.0a0 intel-extension-for-pytorch==2.1.10+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/') os.environ.setdefault('TENSORFLOW_PACKAGE', 'tensorflow==2.13.0 intel-extension-for-tensorflow[gpu]') else: pytorch_pip = 'https://github.com/Nuullll/intel-extension-for-pytorch/releases/download/v2.0.110%2Bxpu-master%2Bdll-bundle/torch-2.0.0a0+gite9ebda2-cp310-cp310-win_amd64.whl' diff --git a/modules/intel/ipex/__init__.py b/modules/intel/ipex/__init__.py index 0eecb8ff3..c78547915 100644 --- a/modules/intel/ipex/__init__.py +++ b/modules/intel/ipex/__init__.py @@ -156,12 +156,6 @@ def ipex_init(): # pylint: disable=too-many-statements torch.cuda.get_device_properties.minor = 7 torch.cuda.ipc_collect = lambda *args, **kwargs: None torch.cuda.utilization = lambda *args, **kwargs: 0 - if hasattr(torch.xpu, 'getDeviceIdListForCard'): - torch.cuda.getDeviceIdListForCard = torch.xpu.getDeviceIdListForCard - torch.cuda.get_device_id_list_per_card = torch.xpu.getDeviceIdListForCard - else: - torch.cuda.getDeviceIdListForCard = torch.xpu.get_device_id_list_per_card - torch.cuda.get_device_id_list_per_card = torch.xpu.get_device_id_list_per_card ipex_hijacks() if not torch.xpu.has_fp64_dtype(): diff --git a/modules/intel/ipex/hijacks.py b/modules/intel/ipex/hijacks.py index a03cdf626..554fe320b 100644 --- a/modules/intel/ipex/hijacks.py +++ b/modules/intel/ipex/hijacks.py @@ -157,10 +157,10 @@ def ipex_hijacks(): lambda orig_func, f, map_location=None, pickle_module=None, *, weights_only=False, mmap=None, **kwargs: orig_func(orig_func, f, map_location=return_xpu(map_location), pickle_module=pickle_module, weights_only=weights_only, mmap=mmap, **kwargs), lambda orig_func, f, map_location=None, pickle_module=None, *, weights_only=False, mmap=None, **kwargs: check_device(map_location)) - - CondFunc('torch.Generator', - lambda orig_func, device=None: torch.xpu.Generator(return_xpu(device)), - lambda orig_func, device=None: device is not None and device != torch.device("cpu") and device != "cpu") + if hasattr(torch.xpu, "Generator"): + CondFunc('torch.Generator', + lambda orig_func, device=None: torch.xpu.Generator(return_xpu(device)), + lambda orig_func, device=None: device is not None and device != torch.device("cpu") and device != "cpu") # TiledVAE and ControlNet: CondFunc('torch.batch_norm',