Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Cache some utils #3474

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import uuid
import gc
from functools import cache
from platform import uname
from typing import List, Tuple, Union
from packaging.version import parse, Version
Expand Down Expand Up @@ -120,6 +121,7 @@ def is_hip() -> bool:
return torch.version.hip is not None


@cache
def is_neuron() -> bool:
try:
import transformers_neuronx
Expand All @@ -128,6 +130,7 @@ def is_neuron() -> bool:
return transformers_neuronx is not None


@cache
def get_max_shared_memory_bytes(gpu: int = 0) -> int:
"""Returns the maximum shared memory per thread block in bytes."""
# NOTE: This import statement should be executed lazily since
Expand All @@ -151,6 +154,7 @@ def random_uuid() -> str:
return str(uuid.uuid4().hex)


@cache
def in_wsl() -> bool:
# Reference: https://github.com/microsoft/WSL/issues/4071
return "microsoft" in " ".join(uname()).lower()
Expand Down Expand Up @@ -225,6 +229,7 @@ def set_cuda_visible_devices(device_ids: List[int]) -> None:
os.environ["CUDA_VISIBLE_DEVICES"] = ",".join(map(str, device_ids))


@cache
def get_nvcc_cuda_version() -> Optional[Version]:
cuda_home = os.environ.get('CUDA_HOME')
if not cuda_home:
Expand Down
Loading