mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-07-07 02:17:09 +08:00
[Misc] Warn if the vLLM version can't be retrieved (#13501)
Signed-off-by: Alex-Brooks <Alex.brooks@ibm.com>
This commit is contained in:
parent
8c755c3b6d
commit
9621667874
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
from contextlib import suppress
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
@ -14,6 +15,21 @@ from .interface import CpuArchEnum, Platform, PlatformEnum
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def vllm_version_matches_substr(substr: str) -> bool:
|
||||||
|
"""
|
||||||
|
Check to see if the vLLM version matches a substring.
|
||||||
|
"""
|
||||||
|
from importlib.metadata import PackageNotFoundError, version
|
||||||
|
try:
|
||||||
|
vllm_version = version("vllm")
|
||||||
|
except PackageNotFoundError as e:
|
||||||
|
logger.warning(
|
||||||
|
"The vLLM package was not found, so its version could not be "
|
||||||
|
"inspected. This may cause platform detection to fail.")
|
||||||
|
raise e
|
||||||
|
return substr in vllm_version
|
||||||
|
|
||||||
|
|
||||||
def tpu_platform_plugin() -> Optional[str]:
|
def tpu_platform_plugin() -> Optional[str]:
|
||||||
is_tpu = False
|
is_tpu = False
|
||||||
try:
|
try:
|
||||||
@ -33,8 +49,6 @@ def cuda_platform_plugin() -> Optional[str]:
|
|||||||
is_cuda = False
|
is_cuda = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from importlib.metadata import version
|
|
||||||
|
|
||||||
from vllm.utils import import_pynvml
|
from vllm.utils import import_pynvml
|
||||||
pynvml = import_pynvml()
|
pynvml = import_pynvml()
|
||||||
pynvml.nvmlInit()
|
pynvml.nvmlInit()
|
||||||
@ -45,7 +59,7 @@ def cuda_platform_plugin() -> Optional[str]:
|
|||||||
# Otherwise, vllm will always activate cuda plugin
|
# Otherwise, vllm will always activate cuda plugin
|
||||||
# on a GPU machine, even if in a cpu build.
|
# on a GPU machine, even if in a cpu build.
|
||||||
is_cuda = (pynvml.nvmlDeviceGetCount() > 0
|
is_cuda = (pynvml.nvmlDeviceGetCount() > 0
|
||||||
and "cpu" not in version("vllm"))
|
and not vllm_version_matches_substr("cpu"))
|
||||||
finally:
|
finally:
|
||||||
pynvml.nvmlShutdown()
|
pynvml.nvmlShutdown()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -113,8 +127,7 @@ def xpu_platform_plugin() -> Optional[str]:
|
|||||||
def cpu_platform_plugin() -> Optional[str]:
|
def cpu_platform_plugin() -> Optional[str]:
|
||||||
is_cpu = False
|
is_cpu = False
|
||||||
try:
|
try:
|
||||||
from importlib.metadata import version
|
is_cpu = vllm_version_matches_substr("cpu")
|
||||||
is_cpu = "cpu" in version("vllm")
|
|
||||||
if not is_cpu:
|
if not is_cpu:
|
||||||
import platform
|
import platform
|
||||||
is_cpu = platform.machine().lower().startswith("arm")
|
is_cpu = platform.machine().lower().startswith("arm")
|
||||||
@ -138,11 +151,8 @@ def neuron_platform_plugin() -> Optional[str]:
|
|||||||
|
|
||||||
def openvino_platform_plugin() -> Optional[str]:
|
def openvino_platform_plugin() -> Optional[str]:
|
||||||
is_openvino = False
|
is_openvino = False
|
||||||
try:
|
with suppress(Exception):
|
||||||
from importlib.metadata import version
|
is_openvino = vllm_version_matches_substr("openvino")
|
||||||
is_openvino = "openvino" in version("vllm")
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return "vllm.platforms.openvino.OpenVinoPlatform" if is_openvino else None
|
return "vllm.platforms.openvino.OpenVinoPlatform" if is_openvino else None
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user