[Bugfix] Enable V1 usage stats (#16986)
Signed-off-by: mgoin <mgoin64@gmail.com> Signed-off-by: Nick Hill <nhill@redhat.com> Co-authored-by: Nick Hill <nhill@redhat.com>
This commit is contained in:
co-authored by
Nick Hill
parent
46e678bcff
commit
ed50f46641
+19
-1
@@ -38,11 +38,13 @@ from asyncio import FIRST_COMPLETED, AbstractEventLoop, Task
|
||||
from collections import UserDict, defaultdict
|
||||
from collections.abc import (AsyncGenerator, Awaitable, Generator, Hashable,
|
||||
Iterable, Iterator, KeysView, Mapping)
|
||||
from concurrent.futures.process import ProcessPoolExecutor
|
||||
from dataclasses import dataclass, field
|
||||
from functools import cache, lru_cache, partial, wraps
|
||||
from types import MappingProxyType
|
||||
from typing import (TYPE_CHECKING, Any, Callable, Generic, Literal, NamedTuple,
|
||||
Optional, Tuple, Type, TypeVar, Union, cast, overload)
|
||||
Optional, Sequence, Tuple, Type, TypeVar, Union, cast,
|
||||
overload)
|
||||
from uuid import uuid4
|
||||
|
||||
import cachetools
|
||||
@@ -1235,6 +1237,22 @@ def cuda_is_initialized() -> bool:
|
||||
return torch.cuda.is_initialized()
|
||||
|
||||
|
||||
def cuda_get_device_properties(device,
|
||||
names: Sequence[str],
|
||||
init_cuda=False) -> tuple[Any, ...]:
|
||||
"""Get specified CUDA device property values without initializing CUDA in
|
||||
the current process."""
|
||||
if init_cuda or cuda_is_initialized():
|
||||
props = torch.cuda.get_device_properties(device)
|
||||
return tuple(getattr(props, name) for name in names)
|
||||
|
||||
# Run in subprocess to avoid initializing CUDA as a side effect.
|
||||
mp_ctx = multiprocessing.get_context("fork")
|
||||
with ProcessPoolExecutor(max_workers=1, mp_context=mp_ctx) as executor:
|
||||
return executor.submit(cuda_get_device_properties, device, names,
|
||||
True).result()
|
||||
|
||||
|
||||
def weak_bind(bound_method: Callable[..., Any], ) -> Callable[..., None]:
|
||||
"""Make an instance method that weakly references
|
||||
its associated instance and no-ops once that
|
||||
|
||||
Reference in New Issue
Block a user