diff --git a/conda/environments/all_cuda-129_arch-aarch64.yaml b/conda/environments/all_cuda-129_arch-aarch64.yaml index 9d8b654f88..1deef1820c 100644 --- a/conda/environments/all_cuda-129_arch-aarch64.yaml +++ b/conda/environments/all_cuda-129_arch-aarch64.yaml @@ -9,6 +9,8 @@ dependencies: - ccache - certifi - cmake>=4.0 +- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.* +- cuda-core>=1.0.0 - cuda-cudart-dev - cuda-nvcc - cuda-profiler-api @@ -53,7 +55,6 @@ dependencies: - numpydoc - numpydoc<1.9 - nvforest==26.8.*,>=0.0.0a0 -- nvidia-ml-py>=12 - onnxruntime - packaging - pre-commit diff --git a/conda/environments/all_cuda-129_arch-x86_64.yaml b/conda/environments/all_cuda-129_arch-x86_64.yaml index 315657c5b3..9b3eaac3e8 100644 --- a/conda/environments/all_cuda-129_arch-x86_64.yaml +++ b/conda/environments/all_cuda-129_arch-x86_64.yaml @@ -9,6 +9,8 @@ dependencies: - ccache - certifi - cmake>=4.0 +- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.* +- cuda-core>=1.0.0 - cuda-cudart-dev - cuda-nvcc - cuda-profiler-api @@ -52,7 +54,6 @@ dependencies: - numpydoc - numpydoc<1.9 - nvforest==26.8.*,>=0.0.0a0 -- nvidia-ml-py>=12 - onnxruntime - packaging - pre-commit diff --git a/conda/environments/all_cuda-132_arch-aarch64.yaml b/conda/environments/all_cuda-132_arch-aarch64.yaml index 5d88b8ad52..fb7b1b8b81 100644 --- a/conda/environments/all_cuda-132_arch-aarch64.yaml +++ b/conda/environments/all_cuda-132_arch-aarch64.yaml @@ -9,6 +9,8 @@ dependencies: - ccache - certifi - cmake>=4.0 +- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.* +- cuda-core>=1.0.0 - cuda-cudart-dev - cuda-nvcc - cuda-profiler-api @@ -53,7 +55,6 @@ dependencies: - numpydoc - numpydoc<1.9 - nvforest==26.8.*,>=0.0.0a0 -- nvidia-ml-py>=12 - onnxruntime - packaging - pre-commit diff --git a/conda/environments/all_cuda-132_arch-x86_64.yaml b/conda/environments/all_cuda-132_arch-x86_64.yaml index 81c78755f1..edb5a0c827 100644 --- a/conda/environments/all_cuda-132_arch-x86_64.yaml +++ b/conda/environments/all_cuda-132_arch-x86_64.yaml @@ -9,6 +9,8 @@ dependencies: - ccache - certifi - cmake>=4.0 +- cuda-bindings>=12.9.6,!=13.0.*,!=13.1.* +- cuda-core>=1.0.0 - cuda-cudart-dev - cuda-nvcc - cuda-profiler-api @@ -52,7 +54,6 @@ dependencies: - numpydoc - numpydoc<1.9 - nvforest==26.8.*,>=0.0.0a0 -- nvidia-ml-py>=12 - onnxruntime - packaging - pre-commit diff --git a/dependencies.yaml b/dependencies.yaml index f7a4945164..05a533ddca 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -621,8 +621,8 @@ dependencies: - nltk # upstream sklearn docstring tests require numpydoc<1.9 - numpydoc<1.9 - # 'nvidia-ml-py' provides the 'pynvml' module - - nvidia-ml-py>=12 + - cuda-bindings>=12.9.6,!=13.0.*,!=13.1.* + - cuda-core>=1.0.0 # TODO: uncomment these two lines once `onnxruntime` has Python 3.14 support (and conda packages built) # - *onnxruntime # - *skl2onnx diff --git a/python/cuml/pyproject.toml b/python/cuml/pyproject.toml index 4ccfb5a049..6cb6208969 100644 --- a/python/cuml/pyproject.toml +++ b/python/cuml/pyproject.toml @@ -110,6 +110,8 @@ classifiers = [ [project.optional-dependencies] test = [ "certifi", + "cuda-bindings>=12.9.6,!=13.0.*,!=13.1.*", + "cuda-core>=1.0.0", "cython>=3.2.2", "hdbscan>=0.8.39", "hypothesis>=6.0,<7", @@ -118,7 +120,6 @@ test = [ "msgspec", "nltk", "numpydoc<1.9", - "nvidia-ml-py>=12", "pynndescent", "pytest", "pytest-benchmark", diff --git a/python/cuml/tests/conftest.py b/python/cuml/tests/conftest.py index 9f5e190325..d6afb7f99b 100644 --- a/python/cuml/tests/conftest.py +++ b/python/cuml/tests/conftest.py @@ -12,8 +12,8 @@ import cupy as cp import hypothesis import numpy as np -import pynvml import pytest +from cuda.core import system from sklearn import datasets from cuml.testing.datasets import make_text_classification_dataset @@ -277,7 +277,7 @@ def pytest_pyfunc_call(pyfuncitem): pytest.skip("Test requires cudf.pandas accelerator") -def _get_pynvml_device_handle(device_id=0): +def _get_nvml_device_handle(device_id=0): """Get GPU handle from device index or UUID. Parameters @@ -289,36 +289,32 @@ def _get_pynvml_device_handle(device_id=0): ------ ValueError If acquiring the device handle for the device specified failed. - pynvml.NVMLError + cuda.core.system.NvmlError If any NVML error occurred while initializing. Returns ------- - A pynvml handle to the device. + A cuda.core.system.Device. Examples -------- - >>> _get_pynvml_device_handle(device_id=0) + >>> _get_nvml_device_handle(device_id=0) - >>> _get_pynvml_device_handle(device_id="GPU-9fb42d6f-7d6b-368f-f79c-3c3e784c93f6") + >>> _get_nvml_device_handle(device_id="GPU-9fb42d6f-7d6b-368f-f79c-3c3e784c93f6") """ - pynvml.nvmlInit() - try: if device_id and not str(device_id).isnumeric(): # This means device_id is UUID. # This works for both MIG and non-MIG device UUIDs. - handle = pynvml.nvmlDeviceGetHandleByUUID(str.encode(device_id)) - if pynvml.nvmlDeviceIsMigDeviceHandle(handle): + device = system.Device(uuid=device_id) + if device.mig.is_mig_device: # Additionally get parent device handle # if the device itself is a MIG instance - handle = pynvml.nvmlDeviceGetDeviceHandleFromMigDeviceHandle( - handle - ) + device = device.mig.parent else: - handle = pynvml.nvmlDeviceGetHandleByIndex(device_id) - return handle - except pynvml.NVMLError: + device = system.Device(index=device_id) + return device + except system.NvmlError: raise ValueError(f"Invalid device index or UUID: {device_id}") @@ -336,12 +332,12 @@ def _get_gpu_memory(device_index=0): have a dedicated memory resource, as is usually the case for system on a chip (SoC) devices. """ - handle = _get_pynvml_device_handle(device_index) + device = _get_nvml_device_handle(device_index) try: # Return total memory in GB - return ceil(pynvml.nvmlDeviceGetMemoryInfo(handle).total / 2**30) - except pynvml.NVMLError_NotSupported: + return ceil(device.memory_info.total / 2**30) + except system.NotSupportedError: return None