From 4e4ecd509528264042eb0f4ce64bc82f5005e024 Mon Sep 17 00:00:00 2001 From: Qiyuan Gong Date: Thu, 27 Jun 2024 17:21:45 +0800 Subject: [PATCH] Control sys.modules ipex duplicate check with BIGDL_CHECK_DUPLICATE_IMPORT (#11453) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Control sys.modules ipex duplicate check with BIGDL_CHECK_DUPLICATE_IMPORT。 --- python/llm/src/ipex_llm/utils/ipex_importer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/llm/src/ipex_llm/utils/ipex_importer.py b/python/llm/src/ipex_llm/utils/ipex_importer.py index aa02b15f..98f02037 100644 --- a/python/llm/src/ipex_llm/utils/ipex_importer.py +++ b/python/llm/src/ipex_llm/utils/ipex_importer.py @@ -124,9 +124,10 @@ class IPEXImporter: """ if self.is_xpu_version_installed(): # Check if user import ipex manually - if 'ipex' in sys.modules or 'intel_extension_for_pytorch' in sys.modules: - log4Error.invalidInputError(False, - ipex_duplicate_import_error) + if BIGDL_CHECK_DUPLICATE_IMPORT: + if 'ipex' in sys.modules or 'intel_extension_for_pytorch' in sys.modules: + log4Error.invalidInputError(False, + ipex_duplicate_import_error) self.directly_import_ipex() self.ipex_version = ipex.__version__ # Replace builtin import to avoid duplicate ipex import