mirror of
https://github.com/bentoml/OpenLLM.git
synced 2026-03-07 16:47:13 -05:00
fix: device imports using strategies (#584)
* fix: device imports using strategies Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> * chore: support trust_remote_code for vLLM runners Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> --------- Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ we won't ensure backward compatibility for these functions. So use with caution.
|
||||
from __future__ import annotations
|
||||
import typing as t
|
||||
|
||||
import functools
|
||||
import openllm_core
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
@@ -14,7 +15,16 @@ if t.TYPE_CHECKING:
|
||||
def generate_labels(llm: openllm.LLM[t.Any, t.Any]) -> dict[str, t.Any]:
|
||||
return {'backend': llm.__llm_backend__, 'framework': 'openllm', 'model_name': llm.config['model_name'], 'architecture': llm.config['architecture'], 'serialisation': llm._serialisation}
|
||||
|
||||
__all__ = ['generate_labels']
|
||||
def available_devices() -> tuple[str, ...]:
|
||||
"""Return available GPU under system. Currently only supports NVIDIA GPUs."""
|
||||
from .._strategies import NvidiaGpuResource
|
||||
return tuple(NvidiaGpuResource.from_system())
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def device_count() -> int:
|
||||
return len(available_devices())
|
||||
|
||||
__all__ = ['generate_labels', 'available_devices', 'device_count']
|
||||
|
||||
def __dir__() -> t.Sequence[str]:
|
||||
return sorted(__all__)
|
||||
|
||||
Reference in New Issue
Block a user