From a4d30a82113da0b870d0eaafc01ba18760ebe65a Mon Sep 17 00:00:00 2001 From: Guancheng Fu <110874468+gc-fu@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:24:19 +0800 Subject: [PATCH] Change logic for detecting if vllm is available (#11657) * fix * fix --- python/llm/src/ipex_llm/transformers/convert.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/llm/src/ipex_llm/transformers/convert.py b/python/llm/src/ipex_llm/transformers/convert.py index aa637577..6791e138 100644 --- a/python/llm/src/ipex_llm/transformers/convert.py +++ b/python/llm/src/ipex_llm/transformers/convert.py @@ -70,12 +70,12 @@ def is_vllm_available(): global _IS_VLLM_AVAILABLE if _IS_VLLM_AVAILABLE is not None: return _IS_VLLM_AVAILABLE - reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'list']) - installed_packages = [r.decode().split(' ')[0] for r in reqs.split()] - if 'vllm' in installed_packages: - _IS_VLLM_AVAILABLE = True - else: - _IS_VLLM_AVAILABLE = False + import sys + original_path = sys.path + # Temporally remove current directory + sys.path = [p for p in sys.path if p != ''] + _IS_VLLM_AVAILABLE = importlib.util.find_spec("vllm") is not None + sys.path = original_path return _IS_VLLM_AVAILABLE