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

Skip pyNVML to support Tegra devices #402

Open
wants to merge 3 commits into
base: branch-0.17
Choose a base branch
from
Open
Changes from 1 commit
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
31 changes: 25 additions & 6 deletions dask_cuda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def nvtx_annotate(message=None, color="blue", domain=None):
yield


@toolz.memoize
def _is_tegra():
import os

return os.path.isdir("/sys/class/tegra-firmware/") or os.path.isfile(
"/etc/nv_tegra_release"
)


class CPUAffinity:
def __init__(self, cores):
self.cores = cores
Expand Down Expand Up @@ -96,8 +105,13 @@ def get_cpu_count():

@toolz.memoize
def get_gpu_count():
pynvml.nvmlInit()
return pynvml.nvmlDeviceGetCount()
if _is_tegra():
import numba.cuda

return len(numba.cuda.gpus)
else:
pynvml.nvmlInit()
return pynvml.nvmlDeviceGetCount()


def get_cpu_affinity(device_index):
jakirkham marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -153,10 +167,15 @@ def get_device_total_memory(index=0):
"""
Return total memory of CUDA device with index
"""
pynvml.nvmlInit()
return pynvml.nvmlDeviceGetMemoryInfo(
pynvml.nvmlDeviceGetHandleByIndex(index)
).total
if _is_tegra():
import numba.cuda

return numba.cuda.current_context().get_memory_info()[1]
else:
pynvml.nvmlInit()
return pynvml.nvmlDeviceGetMemoryInfo(
pynvml.nvmlDeviceGetHandleByIndex(index)
).total


def get_ucx_net_devices(
Expand Down