From 91294d56e1b9e3e7e5cd8fa2ec4d45b126941598 Mon Sep 17 00:00:00 2001 From: sasha0552 Date: Mon, 12 Aug 2024 23:07:20 +0000 Subject: [PATCH] [Bugfix] Handle PackageNotFoundError when checking for xpu version (#7398) --- vllm/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vllm/utils.py b/vllm/utils.py index 3bcf240d5e501..9b5f5589340e2 100644 --- a/vllm/utils.py +++ b/vllm/utils.py @@ -344,8 +344,11 @@ def is_tpu() -> bool: @lru_cache(maxsize=None) def is_xpu() -> bool: - from importlib.metadata import version - is_xpu_flag = "xpu" in version("vllm") + from importlib.metadata import PackageNotFoundError, version + try: + is_xpu_flag = "xpu" in version("vllm") + except PackageNotFoundError: + return False # vllm is not build with xpu if not is_xpu_flag: return False