Skip to content

Commit 1306c08

Browse files
committed
Migrate from pynvml to cuda.core.system
1 parent f532513 commit 1306c08

10 files changed

Lines changed: 56 additions & 174 deletions

conda/environments/all_cuda-129_arch-aarch64.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ channels:
66
- conda-forge
77
dependencies:
88
- click >=8.1
9-
- cuda-core>=0.3.2
9+
- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.*
10+
- cuda-core @ git+https://github.com/nvidia/cuda-python@main#subdirectory=cuda_core
1011
- cuda-nvcc-impl
1112
- cuda-nvrtc
1213
- cuda-version=12.9
@@ -16,7 +17,6 @@ dependencies:
1617
- kvikio==26.6.*,>=0.0.0a0
1718
- numpy>=1.23,<3.0
1819
- numpydoc>=1.1.0
19-
- nvidia-ml-py>=12
2020
- pandas>=1.3
2121
- pre-commit
2222
- pytest

conda/environments/all_cuda-129_arch-x86_64.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ channels:
66
- conda-forge
77
dependencies:
88
- click >=8.1
9-
- cuda-core>=0.3.2
9+
- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.*
10+
- cuda-core @ git+https://github.com/nvidia/cuda-python@main#subdirectory=cuda_core
1011
- cuda-nvcc-impl
1112
- cuda-nvrtc
1213
- cuda-version=12.9
@@ -16,7 +17,6 @@ dependencies:
1617
- kvikio==26.6.*,>=0.0.0a0
1718
- numpy>=1.23,<3.0
1819
- numpydoc>=1.1.0
19-
- nvidia-ml-py>=12
2020
- pandas>=1.3
2121
- pre-commit
2222
- pytest

conda/environments/all_cuda-131_arch-aarch64.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ channels:
66
- conda-forge
77
dependencies:
88
- click >=8.1
9-
- cuda-core>=0.3.2
9+
- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.*
10+
- cuda-core @ git+https://github.com/nvidia/cuda-python@main#subdirectory=cuda_core
1011
- cuda-nvcc-impl
1112
- cuda-nvrtc
1213
- cuda-version=13.1
@@ -16,7 +17,6 @@ dependencies:
1617
- kvikio==26.6.*,>=0.0.0a0
1718
- numpy>=1.23,<3.0
1819
- numpydoc>=1.1.0
19-
- nvidia-ml-py>=12
2020
- pandas>=1.3
2121
- pre-commit
2222
- pytest

conda/environments/all_cuda-131_arch-x86_64.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ channels:
66
- conda-forge
77
dependencies:
88
- click >=8.1
9-
- cuda-core>=0.3.2
9+
- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.*
10+
- cuda-core @ git+https://github.com/nvidia/cuda-python@main#subdirectory=cuda_core
1011
- cuda-nvcc-impl
1112
- cuda-nvrtc
1213
- cuda-version=13.1
@@ -16,7 +17,6 @@ dependencies:
1617
- kvikio==26.6.*,>=0.0.0a0
1718
- numpy>=1.23,<3.0
1819
- numpydoc>=1.1.0
19-
- nvidia-ml-py>=12
2020
- pandas>=1.3
2121
- pre-commit
2222
- pytest

conda/recipes/dask-cuda/recipe.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ requirements:
3737
run:
3838
- python
3939
- click >=8.1
40-
- cuda-core >=0.3
40+
- cuda-core >=0.7.1
4141
- numpy >=1.23,<3.0
42-
# 'nvidia-ml-py' provides the 'pynvml' module
43-
- nvidia-ml-py>=12
4442
- pandas >=1.3
4543
- rapids-dask-dependency =${{ minor_version }}
4644
- zict >=2.0.0

dask_cuda/tests/test_initialize.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from distributed.deploy.local import LocalCluster
2121

2222
from dask_cuda.initialize import initialize
23-
from dask_cuda.utils import get_ucx_config, get_gpu_handle
23+
from dask_cuda.utils import get_ucx_config, get_gpu
2424
from dask_cuda.utils_test import IncreasedCloseTimeoutNanny
2525

2626
if CUDA_CORE_0_5_0():
@@ -39,13 +39,8 @@
3939

4040
def _has_v100_gpu():
4141
"""Return True if the first GPU (index 0) is a V100."""
42-
import pynvml
43-
44-
handle = get_gpu_handle(0)
45-
name = pynvml.nvmlDeviceGetName(handle)
46-
if isinstance(name, bytes):
47-
name = name.decode("utf-8", errors="ignore")
48-
return "V100" in name
42+
device = get_gpu(0)
43+
return "V100" in device.name
4944

5045

5146
def _test_initialize_ucx_tcp():

dask_cuda/tests/test_utils.py

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
from unittest.mock import patch
66

7-
import pynvml
87
import pytest
98

109
try:
@@ -16,6 +15,9 @@
1615
Device = cuda.core.experimental.Device
1716

1817

18+
from cuda.core import system
19+
20+
1921
from dask.config import canonical_name
2022

2123
from dask_cuda.utils import (
@@ -30,7 +32,6 @@
3032
nvml_device_index,
3133
parse_cuda_visible_device,
3234
parse_device_memory_limit,
33-
unpack_bitmask,
3435
)
3536

3637

@@ -62,30 +63,6 @@ def test_get_n_gpus():
6263
assert get_n_gpus() == 3
6364

6465

65-
@pytest.mark.parametrize(
66-
"params",
67-
[
68-
{
69-
"input": [1152920405096267775, 0],
70-
"output": [i for i in range(20)] + [i + 40 for i in range(20)],
71-
},
72-
{
73-
"input": [17293823668613283840, 65535],
74-
"output": [i + 20 for i in range(20)] + [i + 60 for i in range(20)],
75-
},
76-
{"input": [18446744073709551615, 0], "output": [i for i in range(64)]},
77-
{"input": [0, 18446744073709551615], "output": [i + 64 for i in range(64)]},
78-
],
79-
)
80-
def test_unpack_bitmask(params):
81-
assert unpack_bitmask(params["input"]) == params["output"]
82-
83-
84-
def test_unpack_bitmask_single_value():
85-
with pytest.raises(TypeError):
86-
unpack_bitmask(1)
87-
88-
8966
def test_cpu_affinity():
9067
for i in range(get_n_gpus()):
9168
affinity = get_cpu_affinity(i)
@@ -220,15 +197,10 @@ def test_get_ucx_config(enable_tcp_over_ucx, enable_infiniband, enable_nvlink):
220197

221198

222199
def test_parse_visible_devices():
223-
pynvml.nvmlInit()
224200
indices = []
225201
uuids = []
226-
for index in range(get_gpu_count()):
227-
handle = pynvml.nvmlDeviceGetHandleByIndex(index)
228-
try:
229-
uuid = pynvml.nvmlDeviceGetUUID(handle).decode("utf-8")
230-
except AttributeError:
231-
uuid = pynvml.nvmlDeviceGetUUID(handle)
202+
for index, device in enumerate(system.Device.get_all_devices()):
203+
uuid = device.uuid
232204

233205
assert parse_cuda_visible_device(index) == index
234206
assert parse_cuda_visible_device(uuid) == uuid
@@ -350,12 +322,10 @@ def test_has_device_memory_resoure():
350322

351323

352324
def test_parse_visible_mig_devices():
353-
pynvml.nvmlInit()
354-
for index in range(get_gpu_count()):
355-
handle = pynvml.nvmlDeviceGetHandleByIndex(index)
325+
for device in system.Device.get_all_devices():
356326
try:
357-
mode = pynvml.nvmlDeviceGetMigMode(handle)[0]
358-
except pynvml.NVMLError:
327+
mode = device.mig.mode
328+
except system.NvmlError:
359329
# if not a MIG device, i.e. a normal GPU, skip
360330
continue
361331
if mode:
@@ -364,14 +334,6 @@ def test_parse_visible_mig_devices():
364334
# in that GPU is <= to count, where count gives us the
365335
# maximum number of MIG devices/instances that can exist
366336
# under a given parent NVML device.
367-
count = pynvml.nvmlDeviceGetMaxMigDeviceCount(handle)
368-
miguuids = []
369-
for i in range(count):
370-
try:
371-
mighandle = pynvml.nvmlDeviceGetMigDeviceHandleByIndex(
372-
device=handle, index=i
373-
)
374-
miguuids.append(mighandle)
375-
except pynvml.NVMLError:
376-
pass
377-
assert len(miguuids) <= count
337+
mig_devices = list(device.mig.get_all_devices())
338+
count = device.mig.get_device_count()
339+
assert len(mig_devices) <= count

0 commit comments

Comments
 (0)