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

use HAS_GPU to determine of cuda is available #364

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 3 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
17 changes: 4 additions & 13 deletions merlin/core/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

from merlin.core.has_gpu import HAS_GPU # noqa pylint: disable=unused-import

if not cuda.is_available():
cuda = None
cuda = False if not HAS_GPU else cuda

try:
import psutil
Expand Down Expand Up @@ -98,17 +97,9 @@ def device_mem_size(kind="total", cpu=False):

if kind not in ["free", "total"]:
raise ValueError(f"{kind} not a supported option for device_mem_size.")
try:
if kind == "free":
return int(cuda.current_context().get_memory_info()[0])
else:
return int(cuda.current_context().get_memory_info()[1])
except NotImplementedError:
if kind == "free":
# Not using NVML "free" memory, because it will not include RMM-managed memory
warnings.warn("get_memory_info is not supported. Using total device memory from NVML.")
size = pynvml_mem_size(kind="total", index=0)
return size

return pynvml_mem_size(kind=kind)



try:
Expand Down
Loading