nvitop.libnvml module
Utilities for the NVML Python bindings (nvidia-ml-py).
Constants
- nvitop.libnvml.NVML_ERROR_UNINITIALIZED: int = 1
Uninitialized. See also class
NVMLErrorandNVMLError_Uninitialized.
- nvitop.libnvml.NVML_ERROR_INVALID_ARGUMENT: int = 2
Invalid Argument. See also class
NVMLErrorandNVMLError_InvalidArgument.
- nvitop.libnvml.NVML_ERROR_NOT_SUPPORTED: int = 3
Not Supported. See also class
NVMLErrorandNVMLError_NotSupported.
- nvitop.libnvml.NVML_ERROR_NO_PERMISSION: int = 4
Insufficient Permissions. See also class
NVMLErrorandNVMLError_NoPermission.
- nvitop.libnvml.NVML_ERROR_ALREADY_INITIALIZED: int = 5
Already Initialized. See also class
NVMLErrorandNVMLError_AlreadyInitialized.
- nvitop.libnvml.NVML_ERROR_NOT_FOUND: int = 6
Not Found. See also class
NVMLErrorandNVMLError_NotFound.
- nvitop.libnvml.NVML_ERROR_INSUFFICIENT_SIZE: int = 7
Insufficient Size. See also class
NVMLErrorandNVMLError_InsufficientSize.
- nvitop.libnvml.NVML_ERROR_INSUFFICIENT_POWER: int = 8
Insufficient External Power. See also class
NVMLErrorandNVMLError_InsufficientPower.
- nvitop.libnvml.NVML_ERROR_DRIVER_NOT_LOADED: int = 9
Driver Not Loaded. See also class
NVMLErrorandNVMLError_DriverNotLoaded.
- nvitop.libnvml.NVML_ERROR_TIMEOUT: int = 10
Timeout. See also class
NVMLErrorandNVMLError_Timeout.
- nvitop.libnvml.NVML_ERROR_IRQ_ISSUE: int = 11
Interrupt Request Issue. See also class
NVMLErrorandNVMLError_IrqIssue.
- nvitop.libnvml.NVML_ERROR_LIBRARY_NOT_FOUND: int = 12
NVML Shared Library Not Found. See also class
NVMLErrorandNVMLError_LibraryNotFound.
- nvitop.libnvml.NVML_ERROR_FUNCTION_NOT_FOUND: int = 13
Function Not Found. See also class
NVMLErrorandNVMLError_FunctionNotFound.
- nvitop.libnvml.NVML_ERROR_CORRUPTED_INFOROM: int = 14
Corrupted infoROM. See also class
NVMLErrorandNVMLError_CorruptedInforom.
- nvitop.libnvml.NVML_ERROR_GPU_IS_LOST: int = 15
GPU is lost. See also class
NVMLErrorandNVMLError_GpuIsLost.
- nvitop.libnvml.NVML_ERROR_RESET_REQUIRED: int = 16
GPU requires restart. See also class
NVMLErrorandNVMLError_ResetRequired.
- nvitop.libnvml.NVML_ERROR_OPERATING_SYSTEM: int = 17
The operating system has blocked the request. See also class
NVMLErrorandNVMLError_OperatingSystem.
- nvitop.libnvml.NVML_ERROR_LIB_RM_VERSION_MISMATCH: int = 18
RM has detected an NVML/RM version mismatch. See also class
NVMLErrorandNVMLError_LibRmVersionMismatch.
- nvitop.libnvml.NVML_ERROR_MEMORY: int = 20
Insufficient Memory. See also class
NVMLErrorandNVMLError_Memory.
- nvitop.libnvml.NVML_ERROR_UNKNOWN: int = 999
Unknown Error. See also class
NVMLErrorandNVMLError_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
withstatement.
- exception nvitop.libnvml.NVMLError(value)[source]
Bases:
ExceptionBase exception class for NVML query errors.
- nvitop.libnvml.nvmlCheckReturn(retval: Any, types: type | tuple[type, ...] | None = None, /) bool[source]
Check whether the return value is not
nvitop.NAand is one of the given types.
- 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 thepynvmlmodule 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 thepynvmlmodule is overridden by other modules. Need to reinstall packagenvidia-ml-py.
- 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-pyis 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: LP_struct_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.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_AlreadyInitialized(*args)
Bases:
NVMLErrorAlready Initialized. Code:
NVML_ERROR_ALREADY_INITIALIZED(5)
- exception nvitop.libnvml.NVMLError_CorruptedInforom(*args)
Bases:
NVMLErrorCorrupted infoROM. Code:
NVML_ERROR_CORRUPTED_INFOROM(14)
- exception nvitop.libnvml.NVMLError_DriverNotLoaded(*args)
Bases:
NVMLErrorDriver Not Loaded. Code:
NVML_ERROR_DRIVER_NOT_LOADED(9)
- exception nvitop.libnvml.NVMLError_FunctionNotFound(*args)
Bases:
NVMLErrorFunction Not Found. Code:
NVML_ERROR_FUNCTION_NOT_FOUND(13)
- exception nvitop.libnvml.NVMLError_GpuIsLost(*args)
Bases:
NVMLErrorGPU is lost. Code:
NVML_ERROR_GPU_IS_LOST(15)
- exception nvitop.libnvml.NVMLError_InsufficientPower(*args)
Bases:
NVMLErrorInsufficient External Power. Code:
NVML_ERROR_INSUFFICIENT_POWER(8)
- exception nvitop.libnvml.NVMLError_InsufficientSize(*args)
Bases:
NVMLErrorInsufficient Size. Code:
NVML_ERROR_INSUFFICIENT_SIZE(7)
- exception nvitop.libnvml.NVMLError_InvalidArgument(*args)
Bases:
NVMLErrorInvalid Argument. Code:
NVML_ERROR_INVALID_ARGUMENT(2)
- exception nvitop.libnvml.NVMLError_IrqIssue(*args)
Bases:
NVMLErrorInterrupt Request Issue. Code:
NVML_ERROR_IRQ_ISSUE(11)
- exception nvitop.libnvml.NVMLError_LibraryNotFound(*args)
Bases:
NVMLErrorNVML Shared Library Not Found. Code:
NVML_ERROR_LIBRARY_NOT_FOUND(12)
- exception nvitop.libnvml.NVMLError_LibRmVersionMismatch(*args)
Bases:
NVMLErrorRM has detected an NVML/RM version mismatch. Code:
NVML_ERROR_LIB_RM_VERSION_MISMATCH(18)
- exception nvitop.libnvml.NVMLError_Memory(*args)
Bases:
NVMLErrorInsufficient Memory. Code:
NVML_ERROR_MEMORY(20)
- exception nvitop.libnvml.NVMLError_NotFound(*args)
Bases:
NVMLErrorNot Found. Code:
NVML_ERROR_NOT_FOUND(6)
- exception nvitop.libnvml.NVMLError_NotSupported(*args)
Bases:
NVMLErrorNot Supported. Code:
NVML_ERROR_NOT_SUPPORTED(3)
- exception nvitop.libnvml.NVMLError_NoPermission(*args)
Bases:
NVMLErrorInsufficient Permissions. Code:
NVML_ERROR_NO_PERMISSION(4)
- exception nvitop.libnvml.NVMLError_OperatingSystem(*args)
Bases:
NVMLErrorThe operating system has blocked the request. Code:
NVML_ERROR_OPERATING_SYSTEM(17)
- exception nvitop.libnvml.NVMLError_ResetRequired(*args)
Bases:
NVMLErrorGPU requires restart. Code:
NVML_ERROR_RESET_REQUIRED(16)
- exception nvitop.libnvml.NVMLError_Timeout(*args)
Bases:
NVMLErrorTimeout. Code:
NVML_ERROR_TIMEOUT(10)
- exception nvitop.libnvml.NVMLError_Uninitialized(*args)
Bases:
NVMLErrorUninitialized. Code:
NVML_ERROR_UNINITIALIZED(1)
- exception nvitop.libnvml.NVMLError_Unknown(*args)
Bases:
NVMLErrorUnknown Error. Code:
NVML_ERROR_UNKNOWN(999)
- nvitop.libnvml.nvmlExceptionClass(nvmlErrorCode)[source]
Map value to a proper subclass of
NVMLError.
- nvitop.libnvml.nvmlSystemEventSetCreate(version)[source]
Create an NVML system event set. :param version: The version of the request. :return: A ctypes pointer to the created c_nvmlSystemEventSet_t structure.
- nvitop.libnvml.nvmlSystemEventSetFree(version, setHandle)[source]
Free an NVML system event set. :param version: The version of the request. :param setHandle: A ctypes pointer to a c_nvmlSystemEventSet_t structure.
- nvitop.libnvml.nvmlSystemRegisterEvents(version, eventTypes, setHandle)[source]
Register events for an NVML system event set. :param version: The version of the request. :param eventTypes: A bitmask of event types to register. :param setHandle: A ctypes pointer to a c_nvmlSystemEventSet_t structure.
- nvitop.libnvml.nvmlSystemEventSetWait(version, setHandle, timeoutMs, eventData, eventDataSize)[source]
Wait for events in an NVML system event set. :param version: The version of the request. :param setHandle: A ctypes pointer to a c_nvmlSystemEventSet_t structure. :param timeoutMs: Timeout in milliseconds. :param eventData: A ctypes array of c_nvmlSystemEventData_v1_t for event data. :param eventDataSize: Number of c_nvmlSystemEventData_v1_t in evenData array.. :return: A list of dictionaries containing event data.
- nvitop.libnvml.nvmlDeviceGetTemperature(handle: LP_struct_c_nvmlDevice_t, sensor: int) int[source]
Retrieve the current temperature readings (in degrees C) for the given device.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit().NVMLError_InvalidArgument – If device is invalid, sensorType is invalid or temp is NULL.
NVMLError_NotSupported – If the device does not have the specified sensor.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_Unknown – On any unexpected error.
- 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.nvmlDeviceGetDriverModel(handle: LP_struct_c_nvmlDevice_t) list[int][source]
Retrieve the driver model (WDDM or WDM/TCC) for the device.
Returns a list of two values: [current driver model, pending driver model].
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit().NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_NotSupported – If the device does not support this feature (e.g. on Linux).
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceGetCurrentDriverModel(handle: LP_struct_c_nvmlDevice_t) int[source]
Retrieve the current driver model (WDDM or WDM/TCC) for the device.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit().NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_NotSupported – If the device does not support this feature (e.g. on Linux).
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceGetPendingDriverModel(handle: LP_struct_c_nvmlDevice_t) int[source]
Retrieve the pending driver model (WDDM or WDM/TCC) for the device.
- Raises:
NVMLError_Uninitialized – If NVML was not first initialized with
nvmlInit().NVMLError_InvalidArgument – If device is invalid.
NVMLError_GpuIsLost – If the target GPU has fallen off the bus or is otherwise inaccessible.
NVMLError_NotSupported – If the device does not support this feature (e.g. on Linux).
NVMLError_Unknown – On any unexpected error.
- nvitop.libnvml.nvmlDeviceGetComputeRunningProcesses(handle: LP_struct_c_nvmlDevice_t) list[c_nvmlProcessInfo_v3_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: LP_struct_c_nvmlDevice_t) list[c_nvmlProcessInfo_v3_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: LP_struct_c_nvmlDevice_t) list[c_nvmlProcessInfo_v3_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.nvmlDeviceGetClkMonStatus(handle, c_clkMonInfo=<pynvml.nvmlClkMonStatus_t object>)[source]
- nvitop.libnvml.nvmlDeviceSetApplicationsClocks(handle, maxMemClockMHz, maxGraphicsClockMHz)[source]
- nvitop.libnvml.nvmlDeviceSetNvLinkUtilizationControl(device, link, counter, control, reset)[source]
- nvitop.libnvml.nvmlDeviceGetVgpuTypeSupportedPlacements(handle, vgpuTypeId, mode=0, version=1)[source]
- nvitop.libnvml.nvmlDeviceGetGspFirmwareMode(handle, isEnabled=c_uint(0), defaultMode=c_uint(0))[source]
- nvitop.libnvml.nvmlGpuInstanceGetVgpuTypeCreatablePlacements(gpuInstance, c_vgpu_placements)[source]
- nvitop.libnvml.nvmlGpuInstanceGetVgpuSchedulerState_v2(gpuInstance, c_vgpu_sched_state_info_v2)[source]
- nvitop.libnvml.nvmlGpuInstanceGetVgpuSchedulerLog_v2(gpuInstance, c_vgpu_sched_log_info_v2)[source]
- nvitop.libnvml.nvmlDeviceGetGpuInstanceProfileInfoV(device, profile, version=2)
- nvitop.libnvml.nvmlDeviceGetGpuInstanceProfileInfoByIdV(device, profileId)
- 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]
- nvitop.libnvml.nvmlDeviceGetDynamicPstatesInfo(device, c_dynamicpstatesinfo=<pynvml.c_nvmlGpuDynamicPstatesInfo_t object>)[source]
- nvitop.libnvml.nvmlDeviceGetThermalSettings(device, sensorindex, c_thermalsettings=<pynvml.c_nvmlGpuThermalSettings_t object>)[source]
- nvitop.libnvml.nvmlDeviceGetMinMaxClockOfPState(device, clockType, pstate, minClockMHz=c_uint(0), maxClockMHz=c_uint(0))[source]
- nvitop.libnvml.nvmlDeviceGetGpcClkMinMaxVfOffset(device, minOffset=c_int(0), maxOffset=c_int(0))[source]
- nvitop.libnvml.nvmlDeviceGetMemClkMinMaxVfOffset(device, minOffset=c_int(0), maxOffset=c_int(0))[source]
- nvitop.libnvml.nvmlDeviceSetPowerManagementLimit_v2(device, powerScope, powerLimit, version=33554444)[source]
- nvitop.libnvml.nvmlDeviceWorkloadPowerProfileSetRequestedProfiles(device, requestedProfiles)[source]