Change logic for detecting if vllm is available (#11657)

* fix

* fix
This commit is contained in:
Guancheng Fu 2024-07-25 15:24:19 +08:00 committed by GitHub
parent 0c6e0b86c0
commit a4d30a8211
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -70,12 +70,12 @@ def is_vllm_available():
global _IS_VLLM_AVAILABLE global _IS_VLLM_AVAILABLE
if _IS_VLLM_AVAILABLE is not None: if _IS_VLLM_AVAILABLE is not None:
return _IS_VLLM_AVAILABLE return _IS_VLLM_AVAILABLE
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'list']) import sys
installed_packages = [r.decode().split(' ')[0] for r in reqs.split()] original_path = sys.path
if 'vllm' in installed_packages: # Temporally remove current directory
_IS_VLLM_AVAILABLE = True sys.path = [p for p in sys.path if p != '']
else: _IS_VLLM_AVAILABLE = importlib.util.find_spec("vllm") is not None
_IS_VLLM_AVAILABLE = False sys.path = original_path
return _IS_VLLM_AVAILABLE return _IS_VLLM_AVAILABLE