Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaosu-zhu committed Mar 25, 2022
1 parent bd7c281 commit 205313d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions vlutils/base/registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Module of Registry."""
import functools
import os
import logging
from typing import Callable, Dict, Union, Generic, TypeVar
from vlutils.utils import pPrint
Expand Down Expand Up @@ -60,15 +61,15 @@ def insert(value):
return key

@classmethod
def get(cls, key: str, default = None, logger: Union[logging.Logger, "vlutils.logger.LoggerBase"] = logging.root) -> T:
def get(cls, key: str, logger: Union[logging.Logger, "vlutils.logger.LoggerBase"] = logging.root) -> T:
"""Get an object from registry.
Args:
key (str): The key for the registered object.
"""
result = cls._map.get(key, default)
result = cls._map.get(key)
if result is None:
logger.debug("Get None from \"%s\".", cls.__name__)
raise KeyError(f"No entry for {cls.__name__}. Avaliable entries are: {os.linesep + cls.summary()}.")
elif isinstance(result, functools.partial):
logger.debug("Get <%s.%s> from \"%s\".", result.func.__module__, result.func.__qualname__, cls.__name__)
else:
Expand Down
4 changes: 2 additions & 2 deletions vlutils/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def queryGPU(wantsMore: bool = False, givenList: list = None, needGPUs: int = -1
gpuList = []
for i, g in gpus:
if needVRamEachGPU < 0:
if g['memory.used'] < 64:
if g['memory.used'] < 1000:
# give space for basic vram
gpuList.append((i, (g['memory.total'] - g['memory.used'] - 64)))
gpuList.append((i, (g['memory.total'] - g['memory.used'] - 1000)))
logger.debug("adding gpu[%d] with %.2fMB free.", i, g['memory.total'] - g['memory.used'])
elif g['memory.total'] - g['memory.used'] > needVRamEachGPU + 64:
gpuList.append((i, (g['memory.total'] - g['memory.used'] - 64)))
Expand Down

0 comments on commit 205313d

Please sign in to comment.