2.5. Accounting Statistics
Set of APIs designed to provide per process information about usage of GPU.
-
All accounting statistics and accounting mode live in nvidia driver and reset to default (Disabled) when driver unloads. It is advised to run with persistence mode enabled.
-
Enabling accounting mode has no negative impact on the GPU performance.
Classes
Functions
- nvmlReturn_t nvmlDeviceClearAccountingPids ( nvmlDevice_t device )
- nvmlReturn_t nvmlDeviceGetAccountingBufferSize ( nvmlDevice_t device, unsigned int* bufferSize )
- nvmlReturn_t nvmlDeviceGetAccountingMode ( nvmlDevice_t device, nvmlEnableState_t* mode )
- nvmlReturn_t nvmlDeviceGetAccountingPids ( nvmlDevice_t device, unsigned int* count, unsigned int* pids )
- nvmlReturn_t nvmlDeviceGetAccountingStats ( nvmlDevice_t device, unsigned int pid, nvmlAccountingStats_t* stats )
- nvmlReturn_t nvmlDeviceSetAccountingMode ( nvmlDevice_t device, nvmlEnableState_t mode )
Functions
- nvmlReturn_t nvmlDeviceClearAccountingPids ( nvmlDevice_t device )
-
Parameters
- device
- The identifier of the target device
Returns
- NVML_SUCCESS if accounting information has been cleared
- NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
- NVML_ERROR_INVALID_ARGUMENT if device are invalid
- NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
- NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
- NVML_ERROR_UNKNOWN on any unexpected error
Description
Clears accounting information about all processes that have already terminated.
For Kepler or newer fully supported devices. Requires root/admin permissions.
See nvmlDeviceGetAccountingMode See nvmlDeviceGetAccountingStats See nvmlDeviceSetAccountingMode
- nvmlReturn_t nvmlDeviceGetAccountingBufferSize ( nvmlDevice_t device, unsigned int* bufferSize )
-
Parameters
- device
- The identifier of the target device
- bufferSize
- Reference in which to provide the size (in number of elements) of the circular buffer for accounting stats.
Returns
- NVML_SUCCESS if buffer size was successfully retrieved
- NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
- NVML_ERROR_INVALID_ARGUMENT if device is invalid or bufferSize is NULL
- NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature or accounting mode is disabled
- NVML_ERROR_UNKNOWN on any unexpected error
Description
Returns the number of processes that the circular buffer with accounting pids can hold.
For Kepler or newer fully supported devices.
This is the maximum number of processes that accounting information will be stored for before information about oldest processes will get overwritten by information about new processes.
See also:
- nvmlReturn_t nvmlDeviceGetAccountingMode ( nvmlDevice_t device, nvmlEnableState_t* mode )
-
Parameters
- device
- The identifier of the target device
- mode
- Reference in which to return the current accounting mode
Returns
- NVML_SUCCESS if the mode has been successfully retrieved
- NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
- NVML_ERROR_INVALID_ARGUMENT if device is invalid or mode are NULL
- NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
- NVML_ERROR_UNKNOWN on any unexpected error
Description
Queries the state of per process accounting mode.
For Kepler or newer fully supported devices.
See nvmlDeviceGetAccountingStats for more details. See nvmlDeviceSetAccountingMode
- nvmlReturn_t nvmlDeviceGetAccountingPids ( nvmlDevice_t device, unsigned int* count, unsigned int* pids )
-
Parameters
- device
- The identifier of the target device
- count
- Reference in which to provide the pids array size, and to return the number of elements ready to be queried
- pids
- Reference in which to return list of process ids
Returns
- NVML_SUCCESS if pids were successfully retrieved
- NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
- NVML_ERROR_INVALID_ARGUMENT if device is invalid or count is NULL
- NVML_ERROR_NOT_SUPPORTED if device doesn't support this feature or accounting mode is disabled or on vGPU host.
- NVML_ERROR_INSUFFICIENT_SIZE if count is too small (count is set to expected value)
- NVML_ERROR_UNKNOWN on any unexpected error
Description
Queries list of processes that can be queried for accounting stats. The list of processes returned can be in running or terminated state.
For Kepler or newer fully supported devices.
To just query the number of processes ready to be queried, call this function with *count = 0 and pids=NULL. The return code will be NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if list is empty.
For more details see nvmlDeviceGetAccountingStats.
Note:In case of PID collision some processes might not be accessible before the circular buffer is full.
See also:
- nvmlReturn_t nvmlDeviceGetAccountingStats ( nvmlDevice_t device, unsigned int pid, nvmlAccountingStats_t* stats )
-
Parameters
- device
- The identifier of the target device
- pid
- Process Id of the target process to query stats for
- stats
- Reference in which to return the process's accounting stats
Returns
- NVML_SUCCESS if stats have been successfully retrieved
- NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
- NVML_ERROR_INVALID_ARGUMENT if device is invalid or stats are NULL
- NVML_ERROR_NOT_FOUND if process stats were not found
- NVML_ERROR_NOT_SUPPORTED if device doesn't support this feature or accounting mode is disabled or on vGPU host.
- NVML_ERROR_UNKNOWN on any unexpected error
Description
Queries process's accounting stats.
For Kepler or newer fully supported devices.
Accounting stats capture GPU utilization and other statistics across the lifetime of a process. Accounting stats can be queried during life time of the process and after its termination. The time field in nvmlAccountingStats_t is reported as 0 during the lifetime of the process and updated to actual running time after its termination. Accounting stats are kept in a circular buffer, newly created processes overwrite information about old processes.
See nvmlAccountingStats_t for description of each returned metric. List of processes that can be queried can be retrieved from nvmlDeviceGetAccountingPids.
Note:-
Accounting Mode needs to be on. See nvmlDeviceGetAccountingMode.
-
Only compute and graphics applications stats can be queried. Monitoring applications stats can't be queried since they don't contribute to GPU utilization.
-
In case of pid collision stats of only the latest process (that terminated last) will be reported
See also:
- nvmlReturn_t nvmlDeviceSetAccountingMode ( nvmlDevice_t device, nvmlEnableState_t mode )
-
Parameters
- device
- The identifier of the target device
- mode
- The target accounting mode
Returns
- NVML_SUCCESS if the new mode has been set
- NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
- NVML_ERROR_INVALID_ARGUMENT if device or mode are invalid
- NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
- NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
- NVML_ERROR_UNKNOWN on any unexpected error
Description
Enables or disables per process accounting.
For Kepler or newer fully supported devices. Requires root/admin permissions.
Note:-
This setting is not persistent and will default to disabled after driver unloads. Enable persistence mode to be sure the setting doesn't switch off to disabled.
-
Enabling accounting mode has no negative impact on the GPU performance.
-
Disabling accounting clears all accounting pids information.
-
On MIG-enabled GPUs, accounting mode would be set to DISABLED and changing it is not supported.
See nvmlDeviceGetAccountingMode See nvmlDeviceGetAccountingStats See nvmlDeviceClearAccountingPids