From 75e3d1bcbd6270e65611e399e1266fb79a38d608 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 30 Jan 2026 10:51:33 -0500 Subject: [PATCH] Revert "Make cuda.bindings.nvml public (#1544)" This reverts commit dd12efe450189e07f9c0d9f04178e14786b6350d. --- .../_internal/{nvml.pxd => _nvml.pxd} | 2 +- .../{nvml_linux.pyx => _nvml_linux.pyx} | 0 .../{nvml_windows.pyx => _nvml_windows.pyx} | 0 .../cuda/bindings/{nvml.pxd => _nvml.pxd} | 2 +- .../cuda/bindings/{nvml.pyx => _nvml.pyx} | 0 .../cuda/bindings/_test_helpers/arch_check.py | 2 +- .../cuda/bindings/{cynvml.pxd => cy_nvml.pxd} | 0 .../cuda/bindings/{cynvml.pyx => cy_nvml.pyx} | 2 +- cuda_bindings/tests/nvml/conftest.py | 4 ++-- cuda_bindings/tests/nvml/test_compute_mode.py | 2 +- cuda_bindings/tests/nvml/test_cuda.py | 4 ++-- cuda_bindings/tests/nvml/test_device.py | 2 +- cuda_bindings/tests/nvml/test_gpu.py | 2 +- cuda_bindings/tests/nvml/test_init.py | 4 ++-- cuda_bindings/tests/nvml/test_nvlink.py | 4 ++-- .../tests/nvml/test_page_retirement.py | 4 ++-- cuda_bindings/tests/nvml/test_pci.py | 2 +- cuda_bindings/tests/nvml/test_pynvml.py | 4 ++-- cuda_bindings/tests/nvml/util.py | 4 ++-- cuda_core/cuda/core/system/_device.pyx | 2 +- cuda_core/cuda/core/system/_nvml_context.pyx | 4 ++-- cuda_core/cuda/core/system/_system.pyx | 20 ++++++++----------- cuda_core/cuda/core/system/_system_events.pyx | 4 ++-- cuda_core/cuda/core/system/exceptions.py | 4 ++-- cuda_core/tests/system/test_system_device.py | 2 +- 25 files changed, 38 insertions(+), 42 deletions(-) rename cuda_bindings/cuda/bindings/_internal/{nvml.pxd => _nvml.pxd} (99%) rename cuda_bindings/cuda/bindings/_internal/{nvml_linux.pyx => _nvml_linux.pyx} (100%) rename cuda_bindings/cuda/bindings/_internal/{nvml_windows.pyx => _nvml_windows.pyx} (100%) rename cuda_bindings/cuda/bindings/{nvml.pxd => _nvml.pxd} (99%) rename cuda_bindings/cuda/bindings/{nvml.pyx => _nvml.pyx} (100%) rename cuda_bindings/cuda/bindings/{cynvml.pxd => cy_nvml.pxd} (100%) rename cuda_bindings/cuda/bindings/{cynvml.pyx => cy_nvml.pyx} (99%) diff --git a/cuda_bindings/cuda/bindings/_internal/nvml.pxd b/cuda_bindings/cuda/bindings/_internal/_nvml.pxd similarity index 99% rename from cuda_bindings/cuda/bindings/_internal/nvml.pxd rename to cuda_bindings/cuda/bindings/_internal/_nvml.pxd index e62b29b2c8..b04df67558 100644 --- a/cuda_bindings/cuda/bindings/_internal/nvml.pxd +++ b/cuda_bindings/cuda/bindings/_internal/_nvml.pxd @@ -4,7 +4,7 @@ # # This code was automatically generated across versions from 12.9.1 to 13.1.1. Do not modify it directly. -from ..cynvml cimport * +from ..cy_nvml cimport * ############################################################################### diff --git a/cuda_bindings/cuda/bindings/_internal/nvml_linux.pyx b/cuda_bindings/cuda/bindings/_internal/_nvml_linux.pyx similarity index 100% rename from cuda_bindings/cuda/bindings/_internal/nvml_linux.pyx rename to cuda_bindings/cuda/bindings/_internal/_nvml_linux.pyx diff --git a/cuda_bindings/cuda/bindings/_internal/nvml_windows.pyx b/cuda_bindings/cuda/bindings/_internal/_nvml_windows.pyx similarity index 100% rename from cuda_bindings/cuda/bindings/_internal/nvml_windows.pyx rename to cuda_bindings/cuda/bindings/_internal/_nvml_windows.pyx diff --git a/cuda_bindings/cuda/bindings/nvml.pxd b/cuda_bindings/cuda/bindings/_nvml.pxd similarity index 99% rename from cuda_bindings/cuda/bindings/nvml.pxd rename to cuda_bindings/cuda/bindings/_nvml.pxd index 6cf00356c8..36ab860e64 100644 --- a/cuda_bindings/cuda/bindings/nvml.pxd +++ b/cuda_bindings/cuda/bindings/_nvml.pxd @@ -6,7 +6,7 @@ from libc.stdint cimport intptr_t -from .cynvml cimport * +from .cy_nvml cimport * ############################################################################### diff --git a/cuda_bindings/cuda/bindings/nvml.pyx b/cuda_bindings/cuda/bindings/_nvml.pyx similarity index 100% rename from cuda_bindings/cuda/bindings/nvml.pyx rename to cuda_bindings/cuda/bindings/_nvml.pyx diff --git a/cuda_bindings/cuda/bindings/_test_helpers/arch_check.py b/cuda_bindings/cuda/bindings/_test_helpers/arch_check.py index e063fd4ff8..f9666c8a18 100644 --- a/cuda_bindings/cuda/bindings/_test_helpers/arch_check.py +++ b/cuda_bindings/cuda/bindings/_test_helpers/arch_check.py @@ -5,7 +5,7 @@ from contextlib import contextmanager import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml @contextmanager diff --git a/cuda_bindings/cuda/bindings/cynvml.pxd b/cuda_bindings/cuda/bindings/cy_nvml.pxd similarity index 100% rename from cuda_bindings/cuda/bindings/cynvml.pxd rename to cuda_bindings/cuda/bindings/cy_nvml.pxd diff --git a/cuda_bindings/cuda/bindings/cynvml.pyx b/cuda_bindings/cuda/bindings/cy_nvml.pyx similarity index 99% rename from cuda_bindings/cuda/bindings/cynvml.pyx rename to cuda_bindings/cuda/bindings/cy_nvml.pyx index b395a6ac53..82b4bf88bd 100644 --- a/cuda_bindings/cuda/bindings/cynvml.pyx +++ b/cuda_bindings/cuda/bindings/cy_nvml.pyx @@ -4,7 +4,7 @@ # # This code was automatically generated across versions from 12.9.1 to 13.1.1. Do not modify it directly. -from ._internal cimport nvml as _nvml +from ._internal cimport _nvml as _nvml ############################################################################### diff --git a/cuda_bindings/tests/nvml/conftest.py b/cuda_bindings/tests/nvml/conftest.py index 9b7ef6abd1..3bbbe2cb0a 100644 --- a/cuda_bindings/tests/nvml/conftest.py +++ b/cuda_bindings/tests/nvml/conftest.py @@ -1,10 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE from collections import namedtuple import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from cuda.bindings._test_helpers.arch_check import unsupported_before # noqa: F401 diff --git a/cuda_bindings/tests/nvml/test_compute_mode.py b/cuda_bindings/tests/nvml/test_compute_mode.py index 1eb8b08288..0e9a67861f 100644 --- a/cuda_bindings/tests/nvml/test_compute_mode.py +++ b/cuda_bindings/tests/nvml/test_compute_mode.py @@ -5,7 +5,7 @@ import sys import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from .conftest import unsupported_before diff --git a/cuda_bindings/tests/nvml/test_cuda.py b/cuda_bindings/tests/nvml/test_cuda.py index 20ef7ed24e..7be70a62dc 100644 --- a/cuda_bindings/tests/nvml/test_cuda.py +++ b/cuda_bindings/tests/nvml/test_cuda.py @@ -1,8 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE import cuda.bindings.driver as cuda -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from .conftest import NVMLInitializer diff --git a/cuda_bindings/tests/nvml/test_device.py b/cuda_bindings/tests/nvml/test_device.py index 82030e4408..96f1777c5f 100644 --- a/cuda_bindings/tests/nvml/test_device.py +++ b/cuda_bindings/tests/nvml/test_device.py @@ -5,7 +5,7 @@ from functools import cache import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from .conftest import unsupported_before diff --git a/cuda_bindings/tests/nvml/test_gpu.py b/cuda_bindings/tests/nvml/test_gpu.py index f692133ce4..6d2c9d2ec7 100644 --- a/cuda_bindings/tests/nvml/test_gpu.py +++ b/cuda_bindings/tests/nvml/test_gpu.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from . import util from .conftest import unsupported_before diff --git a/cuda_bindings/tests/nvml/test_init.py b/cuda_bindings/tests/nvml/test_init.py index 8bf95ded0a..7970dc380a 100644 --- a/cuda_bindings/tests/nvml/test_init.py +++ b/cuda_bindings/tests/nvml/test_init.py @@ -1,11 +1,11 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE import sys import warnings import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml def assert_nvml_is_initialized(): diff --git a/cuda_bindings/tests/nvml/test_nvlink.py b/cuda_bindings/tests/nvml/test_nvlink.py index d8e782831e..99407abc19 100644 --- a/cuda_bindings/tests/nvml/test_nvlink.py +++ b/cuda_bindings/tests/nvml/test_nvlink.py @@ -1,8 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml def test_nvlink_get_link_count(all_devices): diff --git a/cuda_bindings/tests/nvml/test_page_retirement.py b/cuda_bindings/tests/nvml/test_page_retirement.py index 2f33c46050..4aa5260443 100644 --- a/cuda_bindings/tests/nvml/test_page_retirement.py +++ b/cuda_bindings/tests/nvml/test_page_retirement.py @@ -1,8 +1,8 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from . import util diff --git a/cuda_bindings/tests/nvml/test_pci.py b/cuda_bindings/tests/nvml/test_pci.py index 90605783d8..3e57f0267c 100644 --- a/cuda_bindings/tests/nvml/test_pci.py +++ b/cuda_bindings/tests/nvml/test_pci.py @@ -4,7 +4,7 @@ import contextlib -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from .conftest import unsupported_before diff --git a/cuda_bindings/tests/nvml/test_pynvml.py b/cuda_bindings/tests/nvml/test_pynvml.py index 5a25f66f6f..4157bfb772 100644 --- a/cuda_bindings/tests/nvml/test_pynvml.py +++ b/cuda_bindings/tests/nvml/test_pynvml.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE # A set of tests ported from https://github.com/gpuopenanalytics/pynvml/blob/11.5.3/pynvml/tests/test_nvml.py @@ -7,7 +7,7 @@ import time import pytest -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from . import util from .conftest import unsupported_before diff --git a/cuda_bindings/tests/nvml/util.py b/cuda_bindings/tests/nvml/util.py index 545826a2eb..e815231423 100644 --- a/cuda_bindings/tests/nvml/util.py +++ b/cuda_bindings/tests/nvml/util.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE @@ -6,7 +6,7 @@ import platform from pathlib import Path -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml current_os = platform.system() if current_os == "VMkernel": diff --git a/cuda_core/cuda/core/system/_device.pyx b/cuda_core/cuda/core/system/_device.pyx index f661c4e685..ac633a3fea 100644 --- a/cuda_core/cuda/core/system/_device.pyx +++ b/cuda_core/cuda/core/system/_device.pyx @@ -8,7 +8,7 @@ from libc.math cimport ceil from multiprocessing import cpu_count from typing import Iterable -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from ._nvml_context cimport initialize diff --git a/cuda_core/cuda/core/system/_nvml_context.pyx b/cuda_core/cuda/core/system/_nvml_context.pyx index e32ff51835..d6d9c46060 100644 --- a/cuda_core/cuda/core/system/_nvml_context.pyx +++ b/cuda_core/cuda/core/system/_nvml_context.pyx @@ -1,10 +1,10 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 import threading -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from . import exceptions diff --git a/cuda_core/cuda/core/system/_system.pyx b/cuda_core/cuda/core/system/_system.pyx index 606c8aed8d..3e15420dc8 100644 --- a/cuda_core/cuda/core/system/_system.pyx +++ b/cuda_core/cuda/core/system/_system.pyx @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 @@ -19,17 +19,13 @@ else: if CUDA_BINDINGS_NVML_IS_COMPATIBLE: - try: - from cuda.bindings import nvml - except ModuleNotFoundError: - CUDA_BINDINGS_NVML_IS_COMPATIBLE = False - else: - # TODO: We need to be even more specific than version numbers for development. - # This can be removed once we have a release including everything we need. - for member in ["FieldId", "ClocksEventReasons"]: - if not hasattr(nvml, member): - CUDA_BINDINGS_NVML_IS_COMPATIBLE = False - break + from cuda.bindings import _nvml as nvml + # TODO: We need to be even more specific than version numbers for development. + # This can be removed once we have a release including everything we need. + for member in ["FieldId", "ClocksEventReasons"]: + if not hasattr(nvml, member): + CUDA_BINDINGS_NVML_IS_COMPATIBLE = False + break if CUDA_BINDINGS_NVML_IS_COMPATIBLE: from ._nvml_context import initialize diff --git a/cuda_core/cuda/core/system/_system_events.pyx b/cuda_core/cuda/core/system/_system_events.pyx index d8a64b619b..8b1a91d7bd 100644 --- a/cuda_core/cuda/core/system/_system_events.pyx +++ b/cuda_core/cuda/core/system/_system_events.pyx @@ -1,11 +1,11 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 from libc.stdint cimport intptr_t -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml from ._nvml_context cimport initialize diff --git a/cuda_core/cuda/core/system/exceptions.py b/cuda_core/cuda/core/system/exceptions.py index 990648e531..65bcdd27b5 100644 --- a/cuda_core/cuda/core/system/exceptions.py +++ b/cuda_core/cuda/core/system/exceptions.py @@ -1,9 +1,9 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 -from cuda.bindings import nvml +from cuda.bindings import _nvml as nvml NvmlError = nvml.NvmlError UninitializedError = nvml.UninitializedError diff --git a/cuda_core/tests/system/test_system_device.py b/cuda_core/tests/system/test_system_device.py index 7f6996a439..39eff6176b 100644 --- a/cuda_core/tests/system/test_system_device.py +++ b/cuda_core/tests/system/test_system_device.py @@ -19,7 +19,7 @@ from cuda.core import system if system.CUDA_BINDINGS_NVML_IS_COMPATIBLE: - from cuda.bindings import nvml + from cuda.bindings import _nvml as nvml from cuda.core.system import DeviceArch, _device