Coverage for cuda/core/system/__init__.py: 100.00%

14 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-03 02:41 +0000

1# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 

2# 

3# SPDX-License-Identifier: Apache-2.0 

4 

5 

6# NOTE: We must maintain that it is always possible to import this module 

7# without CUDA being installed, and without CUDA being initialized or any 

8# contexts created, so that a user can use NVML to explore things about their 

9# system without loading CUDA. 

10 

11from typing import TYPE_CHECKING 

12 

13__all__ = [ 

14 "CUDA_BINDINGS_NVML_IS_COMPATIBLE", 

15 "get_driver_branch", 

16 "get_kernel_mode_driver_version", 

17 "get_num_devices", 

18 "get_nvml_version", 

19 "get_process_name", 

20 "get_user_mode_driver_version", 

21] 

22 

23 

24from cuda.core.system import typing 

25 

26from ._system import * 

27 

28# The TYPE_CHECKING branch is split out from the runtime branch so that 

29# stubgen-pyx, which only recognizes the literal `if TYPE_CHECKING:` form, 

30# preserves these imports in the generated .pyi. When 

31# CUDA_BINDINGS_NVML_IS_COMPATIBLE is no longer necessary, this complexity can 

32# be removed. 

33if TYPE_CHECKING: 

34 from ._device import * 

35 from ._system_events import * 

36 from .exceptions import * 

37elif CUDA_BINDINGS_NVML_IS_COMPATIBLE: 

38 from ._device import * 

39 from ._device import __all__ as _device_all 

40 from ._system_events import * 

41 from ._system_events import __all__ as _system_events_all 

42 from .exceptions import * 

43 from .exceptions import __all__ as _exceptions_all 

44 

45 __all__.extend(_device_all) 

46 __all__.extend(_system_events_all) 

47 __all__.extend(_exceptions_all)