Skip to content

Commit 43af7de

Browse files
authored
Initial import of cuda.core.system (#1393)
* First pass at cuda.core.system * Fix fallback to non-working NVML * Precommit fixes * Move exceptions related to NVML to their own module. * Update version check * Add verbose logging for doc build * Try to get doc failure info * Try to get more info * No implicit init, and fix docs build * Use cimport where possible * Move some tests * Improve docs * Fix cyclical imports * Remove more cimports * Fix exposure of unpack_bitmask * Fix tests that use cuda.core.system * Move system.utils to device_utils.pxi * Document the diff between cuda.core.Device and cuda.core.system.Device * Redo the "get_version" APIs * Address comments in PR * Fix typo * Fix array conversion * Remove 'experimental' from the docstring * Windows fix * Remove initialize from docs
1 parent 492cc20 commit 43af7de

File tree

17 files changed

+1112
-169
lines changed

17 files changed

+1112
-169
lines changed

cuda_core/cuda/core/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
finally:
2929
del bindings, importlib, subdir, cuda_major, cuda_minor
3030

31-
from cuda.core import utils # noqa: E402
31+
from cuda.core import system, utils # noqa: E402
3232
from cuda.core._device import Device # noqa: E402
3333
from cuda.core._event import Event, EventOptions # noqa: E402
3434
from cuda.core._graph import ( # noqa: E402
@@ -62,8 +62,3 @@
6262
from cuda.core._module import Kernel, ObjectCode # noqa: E402
6363
from cuda.core._program import Program, ProgramOptions # noqa: E402
6464
from cuda.core._stream import Stream, StreamOptions # noqa: E402
65-
from cuda.core._system import System # noqa: E402
66-
67-
system = System()
68-
__import__("sys").modules[__spec__.name + ".system"] = system
69-
del System

cuda_core/cuda/core/_system.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

cuda_core/cuda/core/experimental/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _warn_deprecated():
3838
_warn_deprecated()
3939

4040

41-
from cuda.core import utils # noqa: E402
41+
from cuda.core import system, utils # noqa: E402
4242

4343
# Make utils accessible as a submodule for backward compatibility
4444
__import__("sys").modules[__spec__.name + ".utils"] = utils
@@ -73,8 +73,3 @@ def _warn_deprecated():
7373
from cuda.core._module import Kernel, ObjectCode # noqa: E402
7474
from cuda.core._program import Program, ProgramOptions # noqa: E402
7575
from cuda.core._stream import Stream, StreamOptions # noqa: E402
76-
from cuda.core._system import System # noqa: E402
77-
78-
system = System()
79-
__import__("sys").modules[__spec__.name + ".system"] = system
80-
del System
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# ruff: noqa: F403, F405
6+
7+
8+
# NOTE: We must maintain that it is always possible to import this module
9+
# without CUDA being installed, and without CUDA being initialized or any
10+
# contexts created, so that a user can use NVML to explore things about their
11+
# system without loading CUDA.
12+
13+
14+
__all__ = [
15+
"get_driver_version",
16+
"get_driver_version_full",
17+
"get_num_devices",
18+
"get_process_name",
19+
"CUDA_BINDINGS_NVML_IS_COMPATIBLE",
20+
]
21+
22+
23+
from ._system import *
24+
25+
if CUDA_BINDINGS_NVML_IS_COMPATIBLE:
26+
from ._device import Device, DeviceArchitecture
27+
from .exceptions import *
28+
from .exceptions import __all__ as _exceptions_all
29+
30+
__all__.extend(
31+
[
32+
"get_nvml_version",
33+
"Device",
34+
"DeviceArchitecture",
35+
]
36+
)
37+
38+
__all__.extend(_exceptions_all)

0 commit comments

Comments
 (0)