nvitop.libnvml module
Utilities for the NVML Python bindings (nvidia-ml-py).
Constants
- nvitop.libnvml.NVML_ERROR_UNINITIALIZED: int = 1
Uninitialized. See also class
NVMLError
andNVMLError_Uninitialized
.
- nvitop.libnvml.NVML_ERROR_INVALID_ARGUMENT: int = 2
Invalid Argument. See also class
NVMLError
andNVMLError_InvalidArgument
.
- nvitop.libnvml.NVML_ERROR_NOT_SUPPORTED: int = 3
Not Supported. See also class
NVMLError
andNVMLError_NotSupported
.
- nvitop.libnvml.NVML_ERROR_NO_PERMISSION: int = 4
Insufficient Permissions. See also class
NVMLError
andNVMLError_NoPermission
.
- nvitop.libnvml.NVML_ERROR_ALREADY_INITIALIZED: int = 5
Already Initialized. See also class
NVMLError
andNVMLError_AlreadyInitialized
.
- nvitop.libnvml.NVML_ERROR_NOT_FOUND: int = 6
Not Found. See also class
NVMLError
andNVMLError_NotFound
.
- nvitop.libnvml.NVML_ERROR_INSUFFICIENT_SIZE: int = 7
Insufficient Size. See also class
NVMLError
andNVMLError_InsufficientSize
.
- nvitop.libnvml.NVML_ERROR_INSUFFICIENT_POWER: int = 8
Insufficient External Power. See also class
NVMLError
andNVMLError_InsufficientPower
.
- nvitop.libnvml.NVML_ERROR_DRIVER_NOT_LOADED: int = 9
Driver Not Loaded. See also class
NVMLError
andNVMLError_DriverNotLoaded
.
- nvitop.libnvml.NVML_ERROR_TIMEOUT: int = 10
Timeout. See also class
NVMLError
andNVMLError_Timeout
.
- nvitop.libnvml.NVML_ERROR_IRQ_ISSUE: int = 11
Interrupt Request Issue. See also class
NVMLError
andNVMLError_IrqIssue
.
- nvitop.libnvml.NVML_ERROR_LIBRARY_NOT_FOUND: int = 12
NVML Shared Library Not Found. See also class
NVMLError
andNVMLError_LibraryNotFound
.
- nvitop.libnvml.NVML_ERROR_FUNCTION_NOT_FOUND: int = 13
Function Not Found. See also class
NVMLError
andNVMLError_FunctionNotFound
.
- nvitop.libnvml.NVML_ERROR_CORRUPTED_INFOROM: int = 14
Corrupted infoROM. See also class
NVMLError
andNVMLError_CorruptedInforom
.
- nvitop.libnvml.NVML_ERROR_GPU_IS_LOST: int = 15
GPU is lost. See also class
NVMLError
andNVMLError_GpuIsLost
.
- nvitop.libnvml.NVML_ERROR_RESET_REQUIRED: int = 16
GPU requires restart. See also class
NVMLError
andNVMLError_ResetRequired
.
- nvitop.libnvml.NVML_ERROR_OPERATING_SYSTEM: int = 17
The operating system has blocked the request. See also class
NVMLError
andNVMLError_OperatingSystem
.
- nvitop.libnvml.NVML_ERROR_LIB_RM_VERSION_MISMATCH: int = 18
RM has detected an NVML/RM version mismatch. See also class
NVMLError
andNVMLError_LibRmVersionMismatch
.
- nvitop.libnvml.NVML_ERROR_MEMORY: int = 20
Insufficient Memory. See also class
NVMLError
andNVMLError_Memory
.
- nvitop.libnvml.NVML_ERROR_UNKNOWN: int = 999
Unknown Error. See also class
NVMLError
andNVMLError_Unknown
.
- nvitop.libnvml.NVML_VALUE_NOT_AVAILABLE_ulonglong: c_ulong = c_ulong(18446744073709551615)
- nvitop.libnvml.NVML_VALUE_NOT_AVAILABLE_uint: c_uint = c_uint(4294967295)
Functions and Exceptions
- nvitop.libnvml.__enter__() libnvml
Entry of the context manager for
with
statement.
- nvitop.libnvml.nvmlCheckReturn(retval: _Any, types: type | tuple[type, ...] | None = None) bool [source]
Check whether the return value is not
nvitop.NA
and is one of the given types.
- nvitop.libnvml.nvmlQuery(func: _Callable[..., _Any] | str, *args: _Any, default: _Any = 'N/A', ignore_errors: bool = True, ignore_function_not_found: bool = False, **kwargs: _Any) _Any [source]
Call a function with the given arguments from NVML.
The NVML context will be automatically initialized.
- Parameters:
func (Union[Callable[..., Any], str]) – The function to call. If it is given by string, lookup for the function first from module
pynvml
.default (Any) – The default value if the query fails.
ignore_errors (bool) – Whether to ignore errors and return the default value.
ignore_function_not_found (bool) – Whether to ignore function not found errors and return the default value. If set to
False
, an error message will be logged to the logger.*args – Positional arguments to pass to the query function.
**kwargs – Keyword arguments to pass to the query function.
- Raises:
NVMLError_LibraryNotFound – If cannot find the NVML library, usually the NVIDIA driver is not installed.
NVMLError_DriverNotLoaded – If NVIDIA driver is not loaded.
NVMLError_LibRmVersionMismatch – If RM detects a driver/library version mismatch, usually after an upgrade for NVIDIA driver without reloading the kernel module.
NVMLError_FunctionNotFound – If the function is not found, usually the installed
nvidia-ml-py
is not compatible with the installed NVIDIA driver.NVMLError_NotSupported – If the function is not supported by the driver or the device.
NVMLError_InvalidArgument – If passed with an invalid argument.
- nvitop.libnvml.nvmlQueryFieldValues(handle: c_nvmlDevice_t, field_ids: list[int | tuple[int, int]]) list[tuple[float | int | NaType, int]] [source]
Query multiple field values from NVML.
Request values for a list of fields for a device. This API allows multiple fields to be queried at once. If any of the underlying fieldIds are populated by the same driver call, the results for those field IDs will be populated from a single call rather than making a driver call for each fieldId.
- Raises:
NVMLError_InvalidArgument – If device or field_ids is invalid.
- nvitop.libnvml.nvmlInit() None [source]
Initialize the NVML context with default flag (0).
- Raises:
NVMLError_LibraryNotFound – If cannot find the NVML library, usually the NVIDIA driver is not installed.
NVMLError_DriverNotLoaded – If NVIDIA driver is not loaded.
NVMLError_LibRmVersionMismatch – If RM detects a driver/library version mismatch, usually after an upgrade for NVIDIA driver without reloading the kernel module.
AttributeError – If cannot find function
pynvml.nvmlInitWithFlags()
, usually thepynvml
module is overridden by other modules. Need to reinstall packagenvidia-ml-py
.
- nvitop.libnvml.nvmlInitWithFlags(flags: int) None [source]
Initialize the NVML context with the given flags.
- Raises:
NVMLError_LibraryNotFound – If cannot find the NVML library, usually the NVIDIA driver is not installed.
NVMLError_DriverNotLoaded – If NVIDIA driver is not loaded.
NVMLError_LibRmVersionMismatch – If RM detects a driver/library version mismatch, usually after an upgrade for NVIDIA driver without reloading the kernel module.
AttributeError – If cannot find function
pynvml.nvmlInitWithFlags()
, usually thepynvml
module is overridden by other modules. Need to reinstall packagenvidia-ml-py
.
- nvitop.libnvml.nvmlShutdown() None [source]
Shutdown the NVML context.
- Raises:
NVMLError_LibraryNotFound – If cannot find the NVML library, usually the NVIDIA driver is not installed.
NVMLError_DriverNotLoaded – If NVIDIA driver is not loaded.
NVMLError_LibRmVersionMismatch – If RM detects a driver/library version mismatch, usually after an upgrade for NVIDIA driver without reloading the kernel module.
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit()
.
- exception nvitop.libnvml.NVMLError(value)[source]
Bases:
Exception
Base exception class for NVML query errors.
- exception nvitop.libnvml.NVMLError_AlreadyInitialized
Bases:
NVMLError
Already Initialized. Code:
NVML_ERROR_ALREADY_INITIALIZED
(5)
- exception nvitop.libnvml.NVMLError_CorruptedInforom
Bases:
NVMLError
Corrupted infoROM. Code:
NVML_ERROR_CORRUPTED_INFOROM
(14)
- exception nvitop.libnvml.NVMLError_DriverNotLoaded
Bases:
NVMLError
Driver Not Loaded. Code:
NVML_ERROR_DRIVER_NOT_LOADED
(9)
- exception nvitop.libnvml.NVMLError_FunctionNotFound
Bases:
NVMLError
Function Not Found. Code:
NVML_ERROR_FUNCTION_NOT_FOUND
(13)
- exception nvitop.libnvml.NVMLError_GpuIsLost
Bases:
NVMLError
GPU is lost. Code:
NVML_ERROR_GPU_IS_LOST
(15)
- exception nvitop.libnvml.NVMLError_InsufficientPower
Bases:
NVMLError
Insufficient External Power. Code:
NVML_ERROR_INSUFFICIENT_POWER
(8)
- exception nvitop.libnvml.NVMLError_InsufficientSize
Bases:
NVMLError
Insufficient Size. Code:
NVML_ERROR_INSUFFICIENT_SIZE
(7)
- exception nvitop.libnvml.NVMLError_InvalidArgument
Bases:
NVMLError
Invalid Argument. Code:
NVML_ERROR_INVALID_ARGUMENT
(2)
- exception nvitop.libnvml.NVMLError_IrqIssue
Bases:
NVMLError
Interrupt Request Issue. Code:
NVML_ERROR_IRQ_ISSUE
(11)
- exception nvitop.libnvml.NVMLError_LibraryNotFound
Bases:
NVMLError
NVML Shared Library Not Found. Code:
NVML_ERROR_LIBRARY_NOT_FOUND
(12)
- exception nvitop.libnvml.NVMLError_LibRmVersionMismatch
Bases:
NVMLError
RM has detected an NVML/RM version mismatch. Code:
NVML_ERROR_LIB_RM_VERSION_MISMATCH
(18)
- exception nvitop.libnvml.NVMLError_Memory
Bases:
NVMLError
Insufficient Memory. Code:
NVML_ERROR_MEMORY
(20)
- exception nvitop.libnvml.NVMLError_NotFound
Bases:
NVMLError
Not Found. Code:
NVML_ERROR_NOT_FOUND
(6)
- exception nvitop.libnvml.NVMLError_NotSupported
Bases:
NVMLError
Not Supported. Code:
NVML_ERROR_NOT_SUPPORTED
(3)
- exception nvitop.libnvml.NVMLError_NoPermission
Bases:
NVMLError
Insufficient Permissions. Code:
NVML_ERROR_NO_PERMISSION
(4)
- exception nvitop.libnvml.NVMLError_OperatingSystem
Bases:
NVMLError
The operating system has blocked the request. Code:
NVML_ERROR_OPERATING_SYSTEM
(17)
- exception nvitop.libnvml.NVMLError_ResetRequired
Bases:
NVMLError
GPU requires restart. Code:
NVML_ERROR_RESET_REQUIRED
(16)
- exception nvitop.libnvml.NVMLError_Timeout
Bases:
NVMLError
Timeout. Code:
NVML_ERROR_TIMEOUT
(10)
- exception nvitop.libnvml.NVMLError_Uninitialized
Bases:
NVMLError
Uninitialized. Code:
NVML_ERROR_UNINITIALIZED
(1)
- exception nvitop.libnvml.NVMLError_Unknown
Bases:
NVMLError
Unknown Error. Code:
NVML_ERROR_UNKNOWN
(999)
- nvitop.libnvml.nvmlExceptionClass(nvmlErrorCode)[source]
Map value to a proper subclass of
NVMLError
.
- nvitop.libnvml.nvmlDeviceGetMemoryInfo(handle: LP_struct_c_nvmlDevice_t) c_nvmlMemory_v2_t [source]
Retrieve the amount of used, free, reserved and total memory available on the device, in bytes.
Note
The version 2 API adds additional memory information. The reserved amount is supported on version 2 only.
In MIG mode, if device handle is provided, the API returns aggregate information, only if the caller has appropriate privileges. Per-instance information can be queried by using specific MIG device handles.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit()
.NVMLError_NoPermission – If the user doesn’t have permission to perform this operation.
NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceGetMemoryErrorCounter(handle, errorType, counterType, locationType)[source]
- nvitop.libnvml.nvmlDeviceGetComputeRunningProcesses(handle: c_nvmlDevice_t) list[c_nvmlProcessInfo_t] [source]
Get information about processes with a compute context on a device.
Note
In MIG mode, if device handle is provided, the API returns aggregate information, only if the caller has appropriate privileges. Per-instance information can be queried by using specific MIG device handles.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit()
.NVMLError_NoPermission – If the user doesn’t have permission to perform this operation.
NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceGetGraphicsRunningProcesses(handle: c_nvmlDevice_t) list[c_nvmlProcessInfo_t] [source]
Get information about processes with a graphics context on a device.
Note
In MIG mode, if device handle is provided, the API returns aggregate information, only if the caller has appropriate privileges. Per-instance information can be queried by using specific MIG device handles.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit()
.NVMLError_NoPermission – If the user doesn’t have permission to perform this operation.
NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceGetMPSComputeRunningProcesses(handle: c_nvmlDevice_t) list[c_nvmlProcessInfo_t] [source]
Get information about processes with a MPS compute context on a device.
Note
In MIG mode, if device handle is provided, the API returns aggregate information, only if the caller has appropriate privileges. Per-instance information can be queried by using specific MIG device handles.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit()
.NVMLError_NoPermission – If the user doesn’t have permission to perform this operation.
NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceSetApplicationsClocks(handle, maxMemClockMHz, maxGraphicsClockMHz)[source]
- nvitop.libnvml.nvmlDeviceSetNvLinkUtilizationControl(device, link, counter, control, reset)[source]
- nvitop.libnvml.nvmlDeviceGetGpuInstanceProfileInfoV(device, profile, version=2)
- nvitop.libnvml.nvmlDeviceGetGpuInstancePossiblePlacements(device, profileId, placementsRef, countRef)[source]
- nvitop.libnvml.nvmlGpuInstanceGetComputeInstanceProfileInfo(device, profile, engProfile, version=2)[source]
- nvitop.libnvml.nvmlGpuInstanceGetComputeInstanceProfileInfoV(device, profile, engProfile, version=2)
- nvitop.libnvml.nvmlGpuInstanceGetComputeInstancePossiblePlacements(gpuInstance, profileId, placementsRef, countRef)[source]
- nvitop.libnvml.nvmlGpuInstanceCreateComputeInstanceWithPlacement(gpuInstance, profileId, placement)[source]
- nvitop.libnvml.nvmlGpuInstanceGetComputeInstances(gpuInstance, profileId, computeInstancesRef, countRef)[source]