NVML API Reference Guide (PDF) - vR515 (older) - Last updated May 4, 2022 - Send Feedback

2.5. Accounting Statistics

Set of APIs designed to provide per process information about usage of GPU.

Note:
  • 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

struct 

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

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

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:

nvmlDeviceGetAccountingStats

nvmlDeviceGetAccountingPids

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

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

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:

nvmlDeviceGetAccountingBufferSize

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

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:

nvmlDeviceGetAccountingBufferSize

nvmlReturn_t nvmlDeviceSetAccountingMode ( nvmlDevice_t device, nvmlEnableState_t mode )
Parameters
device
The identifier of the target device
mode
The target accounting mode
Returns

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


NVML API Reference Guide (PDF) - vR515 (older) - Last updated May 4, 2022 - Send Feedback