2022-10-11 16:06:32 +02:00
# Requirements
* python 3.6 64-bit
2022-11-09 16:17:43 +01:00
* driver must be loaded for amdsmi_init() to pass
2022-10-11 16:06:32 +02:00
# Overview
## Folder structure:
File Name | Note
---|---
`__init__.py` | Python package initialization file
2022-11-09 16:17:43 +01:00
`amdsmi_interface.py` | Amdsmi library python interface
`amdsmi_wrapper.py` | Python wrapper around amdsmi binary
`amdsmi_exception.py` | Amdsmi exceptions python file
2022-10-11 16:06:32 +02:00
`README.md` | Documentation
## Usage:
`amdsmi` folder should be copied and placed next to importing script. It should be imported as:
```python
from amdsmi import *
try :
2022-11-09 16:17:43 +01:00
amdsmi_init ()
2022-10-11 16:06:32 +02:00
# amdsmi calls ...
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
finally :
try :
2022-11-09 16:17:43 +01:00
amdsmi_shut_down ()
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
To initialize amdsmi lib, amdsmi_init() must be called before all other calls to amdsmi lib.
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
To close connection to driver, amdsmi_shut_down() must be the last call.
2022-10-11 16:06:32 +02:00
# Exceptions
2022-11-09 16:17:43 +01:00
All exceptions are in `amdsmi_exception.py` file.
2022-10-11 16:06:32 +02:00
Exceptions that can be thrown are:
2022-11-09 16:17:43 +01:00
* `AmdSmiException` : base amdsmi exception class
* `AmdSmiLibraryException` : derives base `AmdSmiException` class and represents errors that can occur in amdsmi-lib.
2022-10-11 16:06:32 +02:00
When this exception is thrown, `err_code` and `err_info` are set. `err_code` is an integer that corresponds to errors that can occur
2022-11-09 16:17:43 +01:00
in amdsmi-lib and `err_info` is a string that explains the error that occurred.
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
num_of_GPUs = len ( amdsmi_get_device_handles ())
2022-10-11 16:06:32 +02:00
if num_of_GPUs == 0 :
print ( "No GPUs on machine" )
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( "Error code: {} " . format ( e . err_code ))
2022-11-09 16:17:43 +01:00
if e . err_code == AmdSmiRetCode . ERR_RETRY :
2022-10-11 16:06:32 +02:00
print ( "Error info: {} " . format ( e . err_info ))
```
2022-11-09 16:17:43 +01:00
* `AmdSmiRetryException` : Derives `AmdSmiLibraryException` class and signals device is busy and call should be retried.
* `AmdSmiTimeoutException` : Derives `AmdSmiLibraryException` class and represents that call had timed out.
* `AmdSmiParameterException` : Derives base `AmdSmiException` class and represents errors related to invaild parameters passed to functions. When this exception is thrown, err_msg is set and it explains what is the actual and expected type of the parameters.
* `AmdSmiBdfFormatException` : Derives base `AmdSmiException` class and represents invalid bdf format.
2022-10-11 16:06:32 +02:00
# API
2022-11-09 16:17:43 +01:00
## amdsmi_init
Description: Initialize amdsmi lib and connect to driver
2022-10-11 16:06:32 +02:00
Input parameters: `None`
Output: `None`
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_init` function:
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
amdsmi_init ()
2022-10-11 16:06:32 +02:00
# continue with amdsmi
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( "Init failed" )
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_shut_down
2022-10-11 16:06:32 +02:00
Description: Finalize and close connection to driver
Input parameters: `None`
Output: `None`
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_shut_down` function:
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
amdsmi_init ()
amdsmi_shut_down ()
except AmdSmiException as e :
print ( "Shut down failed" )
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_device_type
Description: Checks the type of device with provided handle.
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Input parameters: device handle as an instance of `amdsmi_device_handle`
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Output: Integer, type of gpu
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_device_type` function:
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
type_of_GPU = amdsmi_get_device_type ( device_handle )
if type_of_GPU == 1 :
print ( "This is an AMD GPU" )
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_device_handles
2022-10-11 16:06:32 +02:00
Description: Returns list of GPU device handle objects on current machine
Input parameters: `None`
Output: List of GPU device handle objects
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_device_handles` function:
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
print ( amdsmi_get_device_uuid ( device ))
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-14 12:49:13 +01:00
## amdsmi_get_socket_handles
**Note: CURRENTLY HARDCODED TO RETURN DUMMY DATA**
Description: Returns list of socket device handle objects on current machine
Input parameters: `None`
Output: List of socket device handle objects
Exceptions that can be thrown by `amdsmi_get_socket_handles` function:
* `AmdSmiLibraryException`
Example:
```python
try :
sockets = amdsmi_get_socket_handles ()
print ( 'Socket numbers: {} ' . format ( len ( sockets )))
except AmdSmiException as e :
print ( e )
```
## amdsmi_get_socket_info
**Note: CURRENTLY HARDCODED TO RETURN EMPTY VALUES**
Description: Return socket name
Input parameters:
`socket_handle` socket handle
Output: Socket name
Exceptions that can be thrown by `amdsmi_get_socket_info` function:
* `AmdSmiLibraryException`
Example:
```python
try :
socket_handles = amdsmi_get_socket_handles ()
if len ( socket_handles ) == 0 :
print ( "No sockets on machine" )
else :
for socket in socket_handles :
print ( amdsmi_get_socket_info ( socket ))
except AmdSmiException as e :
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_device_handle_from_bdf
2022-10-11 16:06:32 +02:00
Description: Returns device handle from the given BDF
Input parameters: bdf string in form of either `<domain>:<bus>:<device>.<function>` or `<bus>:<device>.<function>` in hexcode format.
Where:
* `<domain>` is 4 hex digits long from 0000-FFFF interval
* `<bus>` is 2 hex digits long from 00-FF interval
* `<device>` is 2 hex digits long from 00-1F interval
* `<function>` is 1 hex digit long from 0-7 interval
Output: device handle object
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_device_handle_from_bdf` function:
* `AmdSmiLibraryException`
* `AmdSmiBdfFormatException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
device = amdsmi_get_device_handle_from_bdf ( "0000:23:00.0" )
print ( amdsmi_get_device_uuid ( device ))
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_device_bdf
2022-10-11 16:06:32 +02:00
Description: Returns BDF of the given device
Input parameters:
* `device_handle` dev for which to query
Output: BDF string in form of `<domain>:<bus>:<device>.<function>` in hexcode format.
Where:
* `<domain>` is 4 hex digits long from 0000-FFFF interval
* `<bus>` is 2 hex digits long from 00-FF interval
* `<device>` is 2 hex digits long from 00-1F interval
* `<function>` is 1 hex digit long from 0-7 interval
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_device_bdf` function:
* `AmdSmiParameterException`
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
device = amdsmi_get_device_handles ()[ 0 ]
print ( "Device's bdf:" , amdsmi_get_device_bdf ( device ))
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_device_uuid
2022-10-11 16:06:32 +02:00
Description: Returns the UUID of the device
Input parameters:
* `device_handle` dev for which to query
Output: UUID string unique to the device
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_device_uuid` function:
* `AmdSmiParameterException`
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
device = amdsmi_get_device_handles ()[ 0 ]
print ( "Device UUID: " , amdsmi_get_device_uuid ( device ))
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_driver_version
2022-10-11 16:06:32 +02:00
Description: Returns the version string of the driver
Input parameters:
* `device_handle` dev for which to query
Output: Driver version string that is handling the device
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_driver_version` function:
* `AmdSmiParameterException`
* `AmdSmiLibraryException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
device = amdsmi_get_device_handles ()[ 0 ]
print ( "Driver version: " , amdsmi_get_driver_version ( device ))
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_asic_info
2022-10-11 16:06:32 +02:00
Description: Returns asic information for the given GPU
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Content
---|---
`market_name` | market name
`family` | family
`vendor_id` | vendor id
`device_id` | device id
`rev_id` | revision id
2022-11-09 16:17:43 +01:00
`asic_serial` | asic serial
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_asic_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
asic_info = amdsmi_get_asic_info ( device )
2022-10-11 16:06:32 +02:00
print ( asic_info [ 'market_name' ])
print ( hex ( asic_info [ 'family' ]))
print ( hex ( asic_info [ 'vendor_id' ]))
print ( hex ( asic_info [ 'device_id' ]))
print ( hex ( asic_info [ 'rev_id' ]))
2022-11-09 16:17:43 +01:00
print ( asic_info [ 'asic_serial' ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_power_cap_info
2022-10-11 16:06:32 +02:00
Description: Returns dictionary of power capabilities as currently configured
on the given GPU
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
`dpm_cap` | dynamic power management capability
`power_cap` | power capability
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_power_cap_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
power_info = amdsmi_get_power_cap_info ( device )
2022-10-11 16:06:32 +02:00
print ( power_info [ 'dpm_cap' ])
print ( power_info [ 'power_cap' ])
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_caps_info
2022-10-11 16:06:32 +02:00
Description: Returns capabilities as currently configured for the given GPU
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`gfx` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>`gfxip_major` </td><td> major revision of GFX IP</td></tr><tr><td>`gfxip_minor` </td><td>minor revision of GFX IP</td></tr><tr><td>`gfxip_cu_count` </td><td>number of GFX compute units</td></tr></tbody></table>
`mm_ip_list` | List of MM engines on the device, of AmdSmiMmIp type
2022-10-11 16:06:32 +02:00
`ras_supported` | `True` if ecc is supported, `False` if not
`gfx_ip_count` | Number of GFX engines on the device
`dma_ip_count` | Number of DMA engines on the device
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_caps_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
caps_info = amdsmi_get_caps_info ( device )
2022-10-11 16:06:32 +02:00
print ( caps_info [ 'ras_supported' ])
print ( caps_info [ 'gfx' ][ 'gfxip_major' ])
print ( caps_info [ 'gfx' ][ 'gfxip_minor' ])
print ( caps_info [ 'gfx' ][ 'gfxip_cu_count' ])
2022-11-09 16:17:43 +01:00
print ( caps_info [ 'mm_ip_list' ])
2022-10-11 16:06:32 +02:00
print ( caps_info [ 'gfx_ip_count' ])
print ( caps_info [ 'dma_ip_count' ])
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_vbios_info
2022-10-11 16:06:32 +02:00
Description: Returns the static information for the VBIOS on the device.
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`name` | vbios name
2022-10-11 16:06:32 +02:00
`vbios_version` | vbios current version
2022-11-09 16:17:43 +01:00
`build_date` | vbios build date
`part_number` | vbios part number
2022-10-11 16:06:32 +02:00
`vbios_version_string` | vbios version string
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_vbios_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
vbios_info = amdsmi_get_vbios_info ( device )
print ( vbios_info [ 'name' ])
2022-10-11 16:06:32 +02:00
print ( vbios_info [ 'vbios_version' ])
2022-11-09 16:17:43 +01:00
print ( vbios_info [ 'build_date' ])
print ( vbios_info [ 'part_number' ])
2022-10-11 16:06:32 +02:00
print ( vbios_info [ 'vbios_version_string' ])
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_fw_info
Description: Returns GPU firmware related information.
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
Output: Dictionary with fields
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-12-28 16:11:10 +01:00
`fw_list` | List of dictionaries that contain information about a certain firmware block
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_fw_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-28 16:11:10 +01:00
firmware_list = amdsmi_get_fw_info ( device )[ 'fw_list' ]
for firmware_block in firmware_list :
print ( firmware_block [ 'fw_name' ])
print ( firmware_block [ 'fw_version' ])
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_gpu_activity
2022-10-11 16:06:32 +02:00
Description: Returns the engine usage for the given GPU
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`gfx_activity` | graphics engine usage percentage (0 - 100)
`umc_activity` | memory engine usage percentage (0 - 100)
`mm_activity` | list of multimedia engine usages in percentage (0 - 100)
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_gpu_activity` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
engine_usage = amdsmi_get_gpu_activity ( device )
print ( engine_usage [ 'gfx_activity' ])
print ( engine_usage [ 'umc_activity' ])
print ( engine_usage [ 'mm_activity' ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_power_measure
2022-10-11 16:06:32 +02:00
Description: Returns the current power and voltage for the given GPU
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`average_socket_power` | average socket power
`voltage_gfx` | voltage gfx
`energy_accumulator` | energy accumulator
2023-01-20 10:54:01 +01:00
`power_limit` | power limit
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_power_measure` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
power_measure = amdsmi_get_power_measure ( device )
print ( power_measure [ 'average_socket_power' ])
print ( power_measure [ 'voltage_gfx' ])
print ( power_measure [ 'energy_accumulator' ])
2023-01-20 10:54:01 +01:00
print ( power_measure [ 'power_limit' ])
2022-11-09 16:17:43 +01:00
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_vram_usage
Description: Returns total VRAM and VRAM in use
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`vram_used` | VRAM currently in use
`vram_total` | VRAM total
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_vram_usage` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
vram_usage = amdsmi_get_vram_usage ( device )
print ( vram_usage [ 'vram_used' ])
print ( vram_usage [ 'vram_total' ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_clock_measure
Description: Returns the clock measure for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
2022-11-09 16:17:43 +01:00
* `device_handle` device which to query
2022-12-28 12:55:15 +01:00
* `clock_type` one of `AmdSmiClkType` enum values:
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Field | Description
---|---
`SYS` | SYS clock type
`GFX` | GFX clock type
`DF` | DF clock type
`DCEF` | DCEF clock type
`SOC` | SOC clock type
`MEM` | MEM clock type
`PCIE` | PCIE clock type
`VCLK0` | VCLK0 clock type
`VCLK1` | VCLK1 clock type
`DCLK0` | DCLK0 clock type
`DCLK1` | DCLK1 clock type
Output: Dictionary with fields
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`cur_clk` | Current clock for given clock type
`avg_clk` | Average clock for given clock type
`min_clk` | Minimum clock for given clock type
`max_clk` | Maximum clock for given clock type
Exceptions that can be thrown by `amdsmi_get_clock_measure` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-28 12:55:15 +01:00
clock_measure = amdsmi_get_clock_measure ( device , AmdSmiClkType . GFX )
2022-11-09 16:17:43 +01:00
print ( clock_measure [ 'cur_clk' ])
print ( clock_measure [ 'avg_clk' ])
print ( clock_measure [ 'min_clk' ])
print ( clock_measure [ 'max_clk' ])
except AmdSmiException as e :
print ( e )
```
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
## amdsmi_get_pcie_link_status
Description: Returns the pcie link status for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
2022-11-09 16:17:43 +01:00
2022-10-11 16:06:32 +02:00
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`pcie_lanes` | pcie lanes in use
`pcie_speed` | current pcie speed
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_pcie_link_status` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
pcie_link_status = amdsmi_get_pcie_link_status ( device )
print ( pcie_link_status [ "pcie_lanes" ])
print ( pcie_link_status [ "pcie_speed" ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_pcie_link_caps
Description: Returns the max pcie link capabilities for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`pcie_lanes` | Number of PCIe lanes
`pcie_speed` | PCIe speed in MT/s
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_pcie_link_caps` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
pcie_caps = amdsmi_get_pcie_link_caps ( device )
print ( pcie_caps [ 'pcie_lanes' ])
print ( pcie_caps [ 'pcie_speed' ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_bad_page_info
Description: Returns bad page info for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
Output: List consisting of dictionaries with fields for each bad page found
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`value` | Value of page
`page_address` | Address of bad page
`page_size` | Size of bad page
`status` | Status of bad page
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_bad_page_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
bad_page_info = amdsmi_get_bad_page_info ( device )
if not len ( bad_page_info ):
print ( "No bad pages found" )
continue
for bad_page in bad_page_info :
print ( bad_page [ "value" ])
print ( bad_page [ "page_address" ])
print ( bad_page [ "page_size" ])
print ( bad_page [ "status" ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_target_frequency_range
Description: Returns the supported frequency target range for the given GPU
2022-10-11 16:06:32 +02:00
`Note: Not Supported`
Input parameters:
* `device_handle` device which to query
2022-12-28 12:55:15 +01:00
* `clock_type` one of `AmdSmiClkType` enum values:
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`SYS` | SYS clock type
`GFX` | GFX clock type
`DF` | DF clock type
`DCEF` | DCEF clock type
`SOC` | SOC clock type
`MEM` | MEM clock type
`PCIE` | PCIE clock type
`VCLK0` | VCLK0 clock type
`VCLK1` | VCLK1 clock type
`DCLK0` | DCLK0 clock type
`DCLK1` | DCLK1 clock type
2022-10-11 16:06:32 +02:00
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`supported_upper_bound` | Maximal value of target supported frequency in MHz
`supported_lower_bound` | Minimal value of target supported frequency in MHz
`current_upper_bound` | Maximal value of target current frequency in MHz
`current_lower_bound` | Minimal value of target current frequency in MHz
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_target_frequency_range` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
print ( "=============== GFX DOMAIN ================" )
2022-11-09 16:17:43 +01:00
freq_range = amdsmi_get_target_frequency_range ( device ,
2022-12-28 12:55:15 +01:00
AmdSmiClkType . GFX )
2022-11-09 16:17:43 +01:00
print ( freq_range [ 'supported_upper_bound' ])
print ( freq_range [ 'supported_lower_bound' ])
print ( freq_range [ 'current_upper_bound' ])
print ( freq_range [ 'current_lower_bound' ])
2022-10-11 16:06:32 +02:00
print ( "=============== MEM DOMAIN ================" )
2022-11-09 16:17:43 +01:00
freq_range = amdsmi_get_target_frequency_range ( device ,
2022-12-28 12:55:15 +01:00
AmdSmiClkType . MEM )
2022-11-09 16:17:43 +01:00
print ( freq_range [ 'supported_upper_bound' ])
print ( freq_range [ 'supported_lower_bound' ])
print ( freq_range [ 'current_upper_bound' ])
print ( freq_range [ 'current_lower_bound' ])
print ( "=============== VCLK0 DOMAIN ================" )
freq_range = amdsmi_get_target_frequency_range ( device ,
2022-12-28 12:55:15 +01:00
AmdSmiClkType . VCLK0 )
2022-11-09 16:17:43 +01:00
print ( freq_range [ 'supported_upper_bound' ])
print ( freq_range [ 'supported_lower_bound' ])
print ( freq_range [ 'current_upper_bound' ])
print ( freq_range [ 'current_lower_bound' ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_process_list
Description: Returns the list of processes for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
Output: List of process handles found
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_process_list` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
processes = amdsmi_get_process_list ( device )
print ( processes )
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_process_info
Description: Returns the info for the given process
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
* `process_handle` process which to query
2022-10-11 16:06:32 +02:00
Output: Dictionary with fields
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`name` | Name of process
`pid` | Process ID
`mem` | Process memory usage
2023-01-09 15:50:00 +01:00
`engine_usage` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gfx` </td><td>GFX engine usage in ns</td></tr><tr><td>`compute` </td><td>Compute engine usage in ns</td></tr><tr><td>`dma` </td><td>DMA engine usage in ns </td></tr><tr><td>`enc` </td><td>Encode engine usage in ns</td></tr><tr><td>`dec` </td><td>Decode engine usage in ns</td></tr></tbody></table>
2022-10-11 16:06:32 +02:00
`memory_usage` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gtt_mem` </td><td>GTT memory usage</td></tr><tr><td>`cpu_mem` </td><td>CPU memory usage</td></tr><tr><td>`vram_mem` </td><td>VRAM memory usage</td></tr> </tbody></table>
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_process_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
processes = amdsmi_get_process_list ( device )
for process in processes :
print ( amdsmi_get_process_info ( device , process ))
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_ecc_error_count
Description: Returns the ECC error count for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
Output: Dictionary with fields
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`correctable_count` | Correctable ECC error count
`uncorrectable_count` | Uncorrectable ECC error count
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_ecc_error_count` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
ecc_error_count = amdsmi_get_ecc_error_count ( device )
print ( ecc_error_count [ "correctable_count" ])
print ( ecc_error_count [ "uncorrectable_count" ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_board_info
Description: Returns board info for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
Output: Dictionary with fields correctable and uncorrectable
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`serial_number` | Board serial number
`product_serial` | Product serial
`product_name` | Product name
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_board_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
device = amdsmi_get_device_handle_from_bdf ( "0000:23.00.0" )
board_info = amdsmi_get_board_info ( device )
print ( board_info [ "serial_number" ])
print ( board_info [ "product_serial" ])
print ( board_info [ "product_name" ])
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 16:17:43 +01:00
## amdsmi_get_ras_block_features_enabled
Description: Returns status of each RAS block for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
* `device_handle` device which to query
2022-11-09 16:17:43 +01:00
Output: List containing dictionaries with fields for each RAS block
2022-10-11 16:06:32 +02:00
Field | Description
---|---
2022-11-09 16:17:43 +01:00
`block` | RAS block
`status` | RAS block status
2022-10-11 16:06:32 +02:00
2022-11-09 16:17:43 +01:00
Exceptions that can be thrown by `amdsmi_get_ras_block_features_enabled` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
2022-10-11 16:06:32 +02:00
Example:
```python
try :
2022-11-09 16:17:43 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-11-09 16:17:43 +01:00
ras_block_features = amdsmi_get_ras_block_features_enabled ( device )
print ( ras_block_features )
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
```
2022-11-09 15:38:30 +01:00
## AmdSmiEventReader class
2022-10-11 16:06:32 +02:00
2022-11-09 15:38:30 +01:00
Description: Providing methods for event monitoring. This is context manager class.
Can be used with `with` statement for automatic cleanup.
2022-10-11 16:06:32 +02:00
Methods:
## Constructor
2022-11-09 15:38:30 +01:00
Description: Allocates a new event reader notifier to monitor different types of events for the given GPU
2022-10-11 16:06:32 +02:00
Input parameters:
2022-11-09 15:38:30 +01:00
* `device_handle` device handle corresponding to the device on which to listen for events
* `event_types` list of event types from AmdSmiEvtNotificationType enum. Specifying which events to collect for the given device.
Event Type | Description
---|------
`VMFAULT` | VM page fault
`THERMAL_THROTTLE` | thermal throttle
`GPU_PRE_RESET` | gpu pre reset
`GPU_POST_RESET` | gpu post reset
2022-10-11 16:06:32 +02:00
## read
2022-11-09 15:38:30 +01:00
Description: Reads events on the given device. When event is caught, device handle, message and event type are returned. Reading events stops when timestamp passes without event reading.
2022-10-11 16:06:32 +02:00
Input parameters:
2022-11-09 15:38:30 +01:00
* `timestamp` number of milliseconds to wait for an event to occur. If event does not happen monitoring is finished
* `num_elem` number of events. This is optional parameter. Default value is 10.
2022-10-11 16:06:32 +02:00
2022-11-09 15:38:30 +01:00
## stop
Description: Any resources used by event notification for the the given device will be freed with this function. This can be used explicitly or
automatically using `with` statement, like in the examples below. This should be called either manually or automatically for every created AmdSmiEventReader object.
Input parameters: `None`
Example with manual cleanup of AmdSmiEventReader:
2022-10-11 16:06:32 +02:00
```python
try :
2022-11-09 15:38:30 +01:00
devices = amdsmi_get_device_handles ()
2022-10-11 16:06:32 +02:00
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
2022-11-09 15:38:30 +01:00
event = AmdSmiEventReader ( device [ 0 ], AmdSmiEvtNotificationType . GPU_PRE_RESET , AmdSmiEvtNotificationType . GPU_POST_RESET )
event . read ( 10000 )
except AmdSmiException as e :
2022-10-11 16:06:32 +02:00
print ( e )
2022-11-09 15:38:30 +01:00
finally :
event . stop ()
2022-10-11 16:06:32 +02:00
```
2022-11-09 15:38:30 +01:00
Example with automatic cleanup using `with` statement:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
with AmdSmiEventReader ( device [ 0 ], AmdSmiEvtNotificationType . GPU_PRE_RESET , AmdSmiEvtNotificationType . GPU_POST_RESET ) as event :
event . read ( 10000 )
except AmdSmiException as e :
print ( e )
2022-11-09 15:21:42 +01:00
2022-11-09 15:38:30 +01:00
```
2022-11-09 15:21:42 +01:00
2022-12-15 08:17:34 -06:00
## amdsmi_dev_open_supported_func_iterator
2022-11-09 15:21:42 +01:00
Description: Get a function name iterator of supported AMDSMI functions for a device
Input parameters:
* `device_handle` device which to query
Output: Handle for a function iterator
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_open_supported_func_iterator` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
obj_handle = amdsmi_dev_open_supported_func_iterator ( device )
2022-11-09 15:21:42 +01:00
print ( obj_handle )
2022-12-15 08:17:34 -06:00
amdsmi_dev_close_supported_func_iterator ( obj_handle )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_open_supported_variant_iterator
2022-11-09 15:21:42 +01:00
Description: Get a variant iterator for a given handle
Input parameters:
* `obj_handle` Object handle for witch to return a variant handle
Output: Variant iterator handle
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_open_supported_variant_iterator` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
obj_handle = amdsmi_dev_open_supported_func_iterator ( device )
var_iter = amdsmi_dev_open_supported_variant_iterator ( obj_handle )
2022-11-09 15:21:42 +01:00
print ( var_iter )
2022-12-15 08:17:34 -06:00
amdsmi_dev_close_supported_func_iterator ( obj_handle )
amdsmi_dev_close_supported_func_iterator ( var_iter )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_next_func_iter
2022-11-09 15:21:42 +01:00
Description: Advance an object identifier iterator
Input parameters:
* `obj_handle` Object handle to advance
Output: Next iterator handle
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_next_func_iter` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
obj_handle = amdsmi_dev_open_supported_func_iterator ( device )
2022-11-09 15:21:42 +01:00
print ( obj_handle )
2022-12-15 08:17:34 -06:00
obj_handle = amdsmi_next_func_iter ( obj_handle )
2022-11-09 15:21:42 +01:00
print ( obj_handle )
2022-12-15 08:17:34 -06:00
amdsmi_dev_close_supported_func_iterator ( obj_handle )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_close_supported_func_iterator
2022-11-09 15:21:42 +01:00
Description: Close a variant iterator handle
Input parameters:
* `obj_handle` Object handle to be closed
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_close_supported_func_iterator` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
obj_handle = amdsmi_dev_open_supported_func_iterator ( device )
amdsmi_dev_close_supported_func_iterator ( obj_handle )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_get_func_iter_value
2022-11-09 15:21:42 +01:00
Description: Get the value associated with a function/variant iterator
Input parameters:
* `obj_handle` Object handle to query
Output: Data associated with a function/variant iterator
Field | Description
---|---
`id` | Internal ID of the function/variant
`name` | Descriptive name of the function/variant
`amd_id_0` | <table> <thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`memory_type` </td><td>Memory type</td></tr><tr><td>`temp_metric` </td><td>Temperature metric</td></tr><tr><td>`evnt_type` </td><td>Event type</td></tr><tr><td>`evnt_group` </td><td>Event group</td></tr><tr><td>`clk_type` </td><td>Clock type</td></tr></tr><tr><td>`fw_block` </td><td>Firmware block</td></tr><tr><td>`gpu_block_type` </td><td>GPU block type</td></tr></tbody></table>
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_get_func_iter_value` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
obj_handle = amdsmi_dev_open_supported_func_iterator ( device )
value = amdsmi_get_func_iter_value ( obj_handle )
2022-11-09 15:21:42 +01:00
print ( value )
2022-12-15 08:17:34 -06:00
amdsmi_dev_close_supported_func_iterator ( obj_handle )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_pci_bandwidth
2022-11-09 15:21:42 +01:00
Description: Control the set of allowed PCIe bandwidths that can be used
Input parameters:
* `device_handle` handle for the given device
* `bw_bitmask` A bitmask indicating the indices of the bandwidths that are
to be enabled (1) and disabled (0)
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_pci_bandwidth` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_pci_bandwidth ( device , 0 )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_power_cap
2022-11-09 15:21:42 +01:00
Description: Set the power cap value
Input parameters:
* `device_handle` handle for the given device
* `sensor_ind` a 0-based sensor index. Normally, this will be 0. If a
device has more than one sensor, it could be greater than 0
* `cap` int that indicates the desired power cap, in microwatts
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_power_cap` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
power_cap = 250 * 1000000
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_power_cap ( device , 0 , power_cap )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_power_profile
2022-11-09 15:21:42 +01:00
Description: Set the power profile
Input parameters:
* `device_handle` handle for the given device
* `reserved` Not currently used, set to 0
* `profile` a amdsmi_power_profile_preset_masks_t that hold the mask of
the desired new power profile
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_power_profile` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
profile = ...
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_power_profile ( device , 0 , profile )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-11-10 16:18:27 +01:00
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_clk_range
2022-11-09 15:21:42 +01:00
Description: This function sets the clock range information
Input parameters:
* `device_handle` handle for the given device
* `min_clk_value` minimum clock value for desired clock range
* `max_clk_value` maximum clock value for desired clock range
* `clk_type` AMDSMI_CLK_TYPE_SYS | AMDSMI_CLK_TYPE_MEM range type
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_set_clk_range` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-28 12:55:15 +01:00
amdsmi_dev_set_clk_range ( device , 0 , 1000 , AmdSmiClkType . AMDSMI_CLK_TYPE_SYS )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-11-10 16:18:27 +01:00
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_pci_id
2022-11-10 16:18:27 +01:00
Description: Get the unique PCI device identifier associated for a device
Input parameters:
* `device_handle` device which to query
Output: device bdf
The format of bdfid will be as follows:
BDFID = ((DOMAIN & 0xffffffff) << 32) | ((BUS & 0xff) << 8) |
((DEVICE & 0x1f) <<3 ) | (FUNCTION & 0x7)
| Name | Field |
---------- | ------- |
| Domain | [64:32] |
| Reserved | [31:16] |
| Bus | [15: 8] |
| Device | [ 7: 3] |
| Function | [ 2: 0] |
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_pci_id` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
bdfid = amdsmi_dev_get_pci_id ( device )
2022-11-10 16:18:27 +01:00
print ( bdfid )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_pci_bandwidth
2022-11-10 16:18:27 +01:00
Description: Get the list of possible PCIe bandwidths that are available.
Input parameters:
* `device_handle` device which to query
Output: Dictionary with the possible T/s values and associated number of lanes
Field | Content
---|---
`transfer_rate` | transfer_rate dictionary
`lanes` | lanes
transfer_rate dictionary
Field | Content
---|---
`num_supported` | num_supported
`current` | current
`frequency` | list of frequency
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_pci_bandwidth` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
bandwidth = amdsmi_dev_get_pci_bandwidth ( device )
2022-11-10 16:18:27 +01:00
print ( bandwidth )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_pci_throughput
2022-11-10 16:18:27 +01:00
Description: Get PCIe traffic information
Input parameters:
* `device_handle` device which to query
Output: Dictionary with the fields
Field | Content
---|---
`sent` | number of bytes sent in 1 second
`received` | the number of bytes received
`max_pkt_sz` | maximum packet size
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_pci_throughput` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
pci = amdsmi_dev_get_pci_throughput ( device )
2022-11-10 16:18:27 +01:00
print ( pci )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_pci_replay_counter
2022-11-10 16:18:27 +01:00
Description: Get PCIe replay counter
Input parameters:
* `device_handle` device which to query
Output: counter value
The sum of the NAK's received and generated by the GPU
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_pci_replay_counter` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
counter = amdsmi_dev_get_pci_replay_counter ( device )
2022-11-10 16:18:27 +01:00
print ( counter )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_topo_get_numa_affinity
2022-11-10 16:18:27 +01:00
Description: Get the NUMA node associated with a device
Input parameters:
* `device_handle` device which to query
Output: NUMA node value
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_topo_get_numa_affinity` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
numa_node = amdsmi_topo_get_numa_affinity ( device )
2022-11-10 16:18:27 +01:00
print ( numa_node )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_power_ave
2022-11-10 16:18:27 +01:00
Description: Get the average power consumption of the device
Input parameters:
* `device_handle` device which to query
* `sensor_id` a 0-based sensor index. Normally, this will be 0.
If a device has more than one sensor, it could be greater than 0.
Output: the average power consumption
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_power_ave` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
power = amdsmi_dev_get_power_ave ( device )
2022-11-10 16:18:27 +01:00
print ( power )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_energy_count
2022-11-10 16:18:27 +01:00
Description: Get the energy accumulator counter of the device.
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Content
---|---
`power` | power
`counter_resolution` | counter resolution
`timestamp` | timestamp
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_energy_count` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
power = amdsmi_dev_get_energy_count ( device )
2022-11-10 16:18:27 +01:00
print ( power )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_memory_total
2022-11-10 16:18:27 +01:00
Description: Get the total amount of memory that exists
Input parameters:
* `device_handle` device which to query
* `mem_type` enum AmdSmiMemoryType
Output: total amount of memory
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_memory_total` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
memory = amdsmi_dev_get_memory_total ( device )
2022-11-10 16:18:27 +01:00
print ( memory )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_od_clk_info
2022-11-09 15:21:42 +01:00
Description: This function sets the clock frequency information
Input parameters:
* `device_handle` handle for the given device
* `level` AMDSMI_FREQ_IND_MIN|AMDSMI_FREQ_IND_MAX to set the minimum (0)
or maximum (1) speed
* `clk_value` value to apply to the clock range
* `clk_type` AMDSMI_CLK_TYPE_SYS | AMDSMI_CLK_TYPE_MEM range type
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_od_clk_info` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_od_clk_info (
2022-11-09 15:21:42 +01:00
device ,
AmdSmiFreqInd . AMDSMI_FREQ_IND_MAX ,
1000 ,
2022-12-28 12:55:15 +01:00
AmdSmiClkType . AMDSMI_CLK_TYPE_SYS
2022-11-09 15:21:42 +01:00
)
except AmdSmiException as e :
print ( e )
```
2022-11-10 16:18:27 +01:00
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_memory_usage
2022-11-10 16:18:27 +01:00
Description: Get the current memory usage
Input parameters:
* `device_handle` device which to query
* `mem_type` enum AmdSmiMemoryType
Output: the amount of memory currently being used
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_memory_usage` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
memory = amdsmi_dev_get_memory_usage ( device )
2022-11-10 16:18:27 +01:00
print ( memory )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_od_volt_info
2022-11-09 15:21:42 +01:00
Description: This function sets 1 of the 3 voltage curve points
Input parameters:
* `device_handle` handle for the given device
* `vpoint` voltage point [0|1|2] on the voltage curve
* `clk_value` clock value component of voltage curve point
* `volt_value` voltage value component of voltage curve point
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_od_volt_info` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_od_volt_info ( device , 1 , 1000 , 980 )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
```
2022-11-10 16:18:27 +01:00
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_memory_busy_percent
2022-11-10 16:18:27 +01:00
Description: Get percentage of time any device memory is being used
Input parameters:
* `device_handle` device which to query
Output: percentage of time that any device memory is being used for the specified device.
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_memory_busy_percent` function:
2022-11-10 16:18:27 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = gpuvsmi_get_devices ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
busy_percent = amdsmi_dev_get_memory_busy_percent ( device )
2022-11-10 16:18:27 +01:00
print ( busy_percent )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_perf_level_v1
2022-11-09 15:21:42 +01:00
Description: Set the PowerPlay performance level associated with the device
with provided device handle with the provided value
Input parameters:
* `device_handle` handle for the given device
* `perf_lvl` the value to which the performance level should be set
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_perf_level_v1` function:
2022-11-09 15:21:42 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_perf_level_v1 ( device , AmdSmiDevPerfLevel . AMDSMI_DEV_PERF_LEVEL_HIGH )
2022-11-09 15:21:42 +01:00
except AmdSmiException as e :
print ( e )
2022-11-09 16:17:43 +01:00
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_fan_rpms
2022-11-09 17:32:55 +01:00
Description: Get the fan speed in RPMs of the device with the specified device
handle and 0-based sensor index.
Input parameters:
* `device_handle` handle for the given device
* `sensor_idx` a 0-based sensor index. Normally, this will be 0. If a device has
more than one sensor, it could be greater than 0.
Output: Fan speed in rpms as integer
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_fan_rpms` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
fan_rpm = amdsmi_dev_get_fan_rpms ( device , 0 )
2022-11-09 17:32:55 +01:00
print ( fan_rpm )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_fan_speed
2022-11-09 17:32:55 +01:00
Description: Get the fan speed for the specified device as a value relative to
AMDSMI_MAX_FAN_SPEED
Input parameters:
* `device_handle` handle for the given device
* `sensor_idx` a 0-based sensor index. Normally, this will be 0. If a device has
more than one sensor, it could be greater than 0.
Output: Fan speed in relative to MAX
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_fan_speed` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
fan_speed = amdsmi_dev_get_fan_speed ( device , 0 )
2022-11-09 17:32:55 +01:00
print ( fan_speed )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_fan_speed_max
2022-11-09 17:32:55 +01:00
Description: Get the max fan speed of the device with provided device handle
Input parameters:
* `device_handle` handle for the given device
* `sensor_idx` a 0-based sensor index. Normally, this will be 0. If a device has
more than one sensor, it could be greater than 0.
Output: Max fan speed as integer
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_fan_speed_max` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
max_fan_speed = amdsmi_dev_get_fan_speed_max ( device , 0 )
2022-11-09 17:32:55 +01:00
print ( max_fan_speed )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_temp_metric
2022-11-09 17:32:55 +01:00
Description: Get the temperature metric value for the specified metric, from the
specified temperature sensor on the specified device
Input parameters:
* `device_handle` handle for the given device
* `sensor_type` part of device from which temperature should be obtained
* `metric` enum indicated which temperature value should be retrieved
Output: Temperature as integer in millidegrees Celcius
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_temp_metric` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
temp_metric = amdsmi_dev_get_temp_metric ( device , AmdSmiTemperatureType . EDGE ,
2022-11-09 17:32:55 +01:00
AmdSmiTemperatureMetric . CURRENT )
print ( temp_metric )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_volt_metric
2022-11-09 17:32:55 +01:00
Description: Get the voltage metric value for the specified metric, from the
specified voltage sensor on the specified device
Input parameters:
* `device_handle` handle for the given device
* `sensor_type` part of device from which voltage should be obtained
* `metric` enum indicated which voltage value should be retrieved
Output: Voltage as integer in millivolts
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_volt_metric` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
voltage = amdsmi_dev_get_volt_metric ( device , AmdSmiVoltageType . VDDGFX ,
2022-11-09 17:32:55 +01:00
AmdSmiVoltageMetric . AVERAGE )
print ( voltage )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_busy_percent
2022-11-09 17:32:55 +01:00
Description: Get percentage of time device is busy doing any processing
Input parameters:
* `device_handle` handle for the given device
Output: How busy the device is (as percentage of time)
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_busy_percent` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
busy = amdsmi_dev_get_busy_percent ( dev )
2022-11-09 17:32:55 +01:00
print ( busy )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_get_utilization_count
2022-11-09 17:32:55 +01:00
Description: Get coarse grain utilization counter of the specified device
Input parameters:
* `device_handle` handle for the given device
* `counter_types` variable number of counter types desired
Output: List containing dictionaries with fields
Field | Description
---|---
`timestamp` | The timestamp when the counter is retreived - Resolution: 1 ns
`Dictionary for each counter` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>`type` </td><td>Type of utilization counter</td></tr><tr><td>`value` </td><td>Value gotten for utilization counter</td></tr></tbody></table>
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_get_utilization_count` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
utilization = amdsmi_get_utilization_count (
2022-11-10 10:11:59 +01:00
device ,
2022-11-09 17:32:55 +01:00
AmdSmiUtilizationCounterType . COARSE_GRAIN_GFX_ACTIVITY
)
print ( utilization )
2022-12-15 08:17:34 -06:00
utilization = amdsmi_get_utilization_count (
2022-11-10 10:11:59 +01:00
device ,
2022-11-09 17:32:55 +01:00
AmdSmiUtilizationCounterType . COARSE_GRAIN_GFX_ACTIVITY ,
AmdSmiUtilizationCounterType . COARSE_GRAIN_MEM_ACTIVITY
)
print ( utilization )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_perf_level
2022-11-09 17:32:55 +01:00
Description: Get the performance level of the device with provided device handle
Input parameters:
* `device_handle` handle for the given device
Output: Performance level as enum value of dev_perf_level_t
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_perf_level` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
perf_level = amdsmi_dev_get_perf_level ( dev )
2022-11-09 17:32:55 +01:00
print ( perf_level )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_set_perf_determinism_mode
2022-11-09 17:32:55 +01:00
Description: Enter performance determinism mode with provided device handle
Input parameters:
* `device_handle` handle for the given device
* `clkvalue` softmax value for GFXCLK in MHz
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_set_perf_determinism_mode` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
amdsmi_set_perf_determinism_mode ( device , 1333 )
2022-11-09 17:32:55 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_overdrive_level
2022-11-09 17:32:55 +01:00
Description: Get the overdrive percent associated with the device with provided
device handle
Input parameters:
* `device_handle` handle for the given device
Output: Overdrive percentage as integer
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by `amdsmi_dev_get_overdrive_level` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
od_level = amdsmi_dev_get_overdrive_level ( dev )
2022-11-09 17:32:55 +01:00
print ( od_level )
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_gpu_clk_freq
2022-11-09 17:32:55 +01:00
Description: Get the list of possible system clock speeds of device for a
specified clock type
Input parameters:
* `device_handle` handle for the given device
* `clk_type` the type of clock for which the frequency is desired
Output: Dictionary with fields
Field | Description
---|---
`num_supported` | The number of supported frequencies
`current` | The current frequency index
`frequency` | List of frequencies, only the first num_supported frequencies are valid
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_gpu_clk_freq` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-28 12:55:15 +01:00
amdsmi_dev_get_gpu_clk_freq ( device , AmdSmiClkType . SYS )
2022-11-09 17:32:55 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_od_volt_info
2022-11-09 17:32:55 +01:00
Description: This function retrieves the voltage/frequency curve information
Input parameters:
* `device_handle` handle for the given device
Output: Dictionary with fields
Field | Description
---|---
`curr_sclk_range` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>`lower_bound` </td><td>lower bound sclk range</td></tr><tr><td>`upper_bound` </td><td>upper bound sclk range</td></tr></tbody></table>
`curr_mclk_range` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>`lower_bound` </td><td>lower bound mclk range</td></tr><tr><td>`upper_bound` </td><td>upper bound mclk range</td></tr></tbody></table>
`sclk_freq_limits` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>`lower_bound` </td><td>lower bound sclk range limt</td></tr><tr><td>`upper_bound` </td><td>upper bound sclk range limit</td></tr></tbody></table>
`mclk_freq_limits` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>`lower_bound` </td><td>lower bound mclk range limit</td></tr><tr><td>`upper_bound` </td><td>upper bound mclk range limit</td></tr></tbody></table>
`curve.vc_points` | The number of supported frequencies
`num_regions` | The current frequency index
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_od_volt_info` function:
2022-11-09 17:32:55 +01:00
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try :
devices = amdsmi_get_device_handles ()
if len ( devices ) == 0 :
print ( "No GPUs on machine" )
else :
for device in devices :
2022-12-15 08:17:34 -06:00
amdsmi_dev_get_od_volt_info ( dev )
2022-11-09 17:32:55 +01:00
except AmdSmiException as e :
print ( e )
```
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_gpu_metrics_info
2022-11-09 17:32:55 +01:00
Description: This function retrieves the gpu metrics information
Input parameters:
* `device_handle` handle for the given device
Output: Dictionary with fields
Field | Description
`---|---
` temperature_edge` | edge temperature value
` temperature_hotspot` | hotspot temperature value
` temperature_mem` | memory temperature value
` temperature_vrgfx` | vrgfx temperature value
` temperature_vrsoc` | vrsoc temperature value
` temperature_vrmem` | vrmem temperature value
` average_gfx_activity` | average gfx activity
` average_umc_activity` | average umc activity
` average_mm_activity` | average mm activity
` average_socket_power` | average socket power
` energy_accumulator` | energy accumulator value
` system_clock_counter` | system clock counter
` average_gfxclk_frequency` | average gfx clock frequency
` average_socclk_frequency` | average soc clock frequency
` average_uclk_frequency` | average uclk frequency
` average_vclk0_frequency` | average vclk0 frequency
` average_dclk0_frequency` | average dclk0 frequency
` average_vclk1_frequency` | average vclk1 frequency
` average_dclk1_frequency` | average dclk1 frequency
` current_gfxclk` | current gfx clock
` current_socclk` | current soc clock
` current_uclk` | current uclk
` current_vclk0` | current vclk0
` current_dclk0` | current dclk0
` current_vclk1` | current vclk1
` current_dclk1` | current dclk1
` throttle_status` | current throttle status
` current_fan_speed` | current fan speed
` pcie_link_width` | pcie link width
` pcie_link_speed` | pcie link speed
` padding` | padding
` gfx_activity_acc` | gfx activity acc
` mem_actvity_acc` | mem activity acc
` temperature_hbm` | hbm temperature
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_gpu_metrics_info` function:
2022-11-09 17:32:55 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_get_gpu_metrics_info(dev)
2022-11-09 17:32:55 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_od_volt_curve_regions
2022-11-09 17:32:55 +01:00
Description: This function will retrieve the current valid regions in the
frequency/voltage space
Input parameters:
* ` device_handle` handle for the given device
* ` num_regions` number of freq volt regions
Output: List containing a dictionary with fields for each freq volt region
Field | Description
---|---
` freq_range` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>` lower_bound`</td><td>lower bound freq range</td></tr><tr><td>` upper_bound`</td><td>upper bound freq range</td></tr></tbody></table>
` volt_range` | <table> <thead><tr><th> Subfield </th><th>Description</th></tr></thead><tbody><tr><td>` lower_bound`</td><td>lower bound volt range</td></tr><tr><td>` upper_bound`</td><td>upper bound volt range</td></tr></tbody></table>
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_od_volt_curve_regions` function:
2022-11-09 17:32:55 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_get_od_volt_curve_regions(device, 3)
2022-11-09 17:32:55 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_power_profile_presets
2022-11-09 17:32:55 +01:00
Description: Get the list of available preset power profiles and an indication of
which profile is currently active
Input parameters:
* ` device_handle` handle for the given device
* ` sensor_idx` number of freq volt regions
Output: Dictionary with fields
Field | Description
---|---
` available_profiles`| Which profiles are supported by this system
` current`| Which power profile is currently active
` num_profiles`| How many power profiles are available
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_power_profile_presets` function:
2022-11-09 17:32:55 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_get_power_profile_presets(device, 0)
2022-11-09 17:32:55 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-11-10 10:11:59 +01:00
## amdsmi_dev_counter_group_supported
Description: Tell if an event group is supported by a given device
Input parameters:
* ` device_handle` device which to query
* ` event_group` event group being checked for support
Output: None
Exceptions that can be thrown by ` amdsmi_dev_counter_group_supported` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
amdsmi_dev_counter_group_supported(device, AmdSmiEventGroup.XGMI)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_create_counter
2022-11-10 10:11:59 +01:00
Description: Creates a performance counter object
Input parameters:
* ` device_handle` device which to query
* ` event_type` event group being checked for support
Output: An event handle of the newly created performance counter object
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_create_counter` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
event_handle = amdsmi_dev_create_counter(device, AmdSmiEventGroup.XGMI)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_destroy_counter
2022-11-10 10:11:59 +01:00
Description: Destroys a performance counter object
Input parameters:
* ` event_handle` event handle of the performance counter object
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_destroy_counter` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
event_handle = amdsmi_dev_create_counter(device, AmdSmiEventGroup.XGMI)
amdsmi_dev_destroy_counter(event_handle)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_control_counter
2022-11-10 10:11:59 +01:00
Description: Issue performance counter control commands
Input parameters:
* ` event_handle` event handle of the performance counter object
* ` counter_command` command being passed to counter as AmdSmiCounterCommand
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_control_counter` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
event_handle = amdsmi_dev_create_counter(device, AmdSmiEventType.XGMI_1_REQUEST_TX)
amdsmi_control_counter(event_handle, AmdSmiCounterCommand.CMD_START)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_read_counter
2022-11-10 10:11:59 +01:00
Description: Read the current value of a performance counter
Input parameters:
* ` event_handle` event handle of the performance counter object
Output: Dictionary with fields
Field | Description
---|---
` value`| Counter value
` time_enabled`| Time that the counter was enabled in nanoseconds
` time_running`| Time that the counter was running in nanoseconds
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_read_counter` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
event_handle = amdsmi_dev_create_counter(device, AmdSmiEventType.XGMI_1_REQUEST_TX)
amdsmi_read_counter(event_handle)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_counter_get_available_counters
2022-11-10 10:11:59 +01:00
Description: Get the number of currently available counters
Input parameters:
* ` device_handle` handle for the given device
* ` event_group` event group being checked as AmdSmiEventGroup
Output: Number of available counters for the given device of the inputted event group
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_counter_get_available_counters` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
available_counters = amdsmi_counter_get_available_counters(device, AmdSmiEventGroup.XGMI)
2022-11-10 10:11:59 +01:00
print(available_counters)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_perf_level
2022-11-10 10:11:59 +01:00
Description: Set a desired performance level for given device
Input parameters:
* ` device_handle` handle for the given device
* ` perf_level` performance level being set as AmdSmiDevPerfLevel
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_perf_level` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_perf_level(device, AmdSmiDevPerfLevel.STABLE_PEAK)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_power_profile_presets
2022-11-10 10:11:59 +01:00
Description: Get the list of available preset power profiles and an indication of
which profile is currently active.
Input parameters:
* ` device_handle` handle for the given device
* ` sensor_idx` sensor index as integer
Output: Dictionary with fields
Field | Description
---|---
` available_profiles`| Which profiles are supported by this system
` current`| Which power profile is currently active
` num_profiles`| How many power profiles are available
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_power_profile_presets` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
status = amdsmi_dev_get_power_profile_presets(device, 0)
2022-11-10 10:11:59 +01:00
print(status)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_reset_gpu
2022-11-10 10:11:59 +01:00
Description: Reset the gpu associated with the device with provided device handle
Input parameters:
* ` device_handle` handle for the given device
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_reset_gpu` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_reset_gpu(device)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_fan_speed
2022-11-10 10:11:59 +01:00
Description: Set the fan speed for the specified device with the provided speed,
in RPMs
Input parameters:
* ` device_handle` handle for the given device
* ` sensor_idx` sensor index as integer
* ` fan_speed` the speed to which the function will attempt to set the fan
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_fan_speed` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_fan_speed(device, 0, 1333)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_reset_fan
2022-11-10 10:11:59 +01:00
Description: Reset the fan to automatic driver control
Input parameters:
* ` device_handle` handle for the given device
* ` sensor_idx` sensor index as integer
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_reset_fan` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_reset_fan(device, 0)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_clk_freq
2022-11-10 10:11:59 +01:00
Description: Control the set of allowed frequencies that can be used for the
specified clock
Input parameters:
* ` device_handle` handle for the given device
* ` clk_type` the type of clock for which the set of frequencies will be modified
2022-12-28 12:55:15 +01:00
as AmdSmiClkType
2022-11-10 10:11:59 +01:00
* ` freq_bitmask` bitmask indicating the indices of the frequencies that are to
be enabled (1) and disabled (0). Only the lowest ::amdsmi_frequencies_t.num_supported
bits of this mask are relevant.
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_clk_freq` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
freq_bitmask = 0
2022-12-28 12:55:15 +01:00
amdsmi_dev_set_clk_freq(device, AmdSmiClkType.GFX, freq_bitmask)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_overdrive_level_v1
2022-11-10 10:11:59 +01:00
Description: Set the overdrive percent associated with the device with provided
device handle with the provided value
Input parameters:
* ` device_handle` handle for the given device
* ` overdrive_value` value to which the overdrive level should be set
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_overdrive_level_v1` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_overdrive_level_v1(device, 0)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_set_overdrive_level
2022-11-10 10:11:59 +01:00
Description: **deprecated** Set the overdrive percent associated with the
device with provided device handle with the provided value
Input parameters:
* ` device_handle` handle for the given device
* ` overdrive_value` value to which the overdrive level should be set
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_set_overdrive_level` function:
2022-11-10 10:11:59 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_set_overdrive_level(device, 0)
2022-11-10 10:11:59 +01:00
except AmdSmiException as e:
print(e)
2022-11-10 10:30:10 +01:00
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_ecc_count
2022-11-10 10:30:10 +01:00
Description: Retrieve the error counts for a GPU block
Input parameters:
* ` device_handle` handle for the given device
* ` block` The block for which error counts should be retrieved
Output: Dict containing information about error counts
Field | Description
---|---
` correctable_count`| Count of correctable errors
` uncorrectable_count`| Count of uncorrectable errors
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_ecc_count` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
ecc_count = amdsmi_dev_get_ecc_count(device, AmdSmiGpuBlock.UMC)
2022-11-10 10:30:10 +01:00
print(ecc_count)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_ecc_enabled
2022-11-10 10:30:10 +01:00
Description: Retrieve the enabled ECC bit-mask
Input parameters:
* ` device_handle` handle for the given device
Output: Enabled ECC bit-mask
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_ecc_enabled` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
enabled = amdsmi_dev_get_ecc_enabled(device)
2022-11-10 10:30:10 +01:00
print(enabled)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_ecc_status
2022-11-10 10:30:10 +01:00
Description: Retrieve the ECC status for a GPU block
Input parameters:
* ` device_handle` handle for the given device
* ` block` The block for which ECC status should be retrieved
Output: ECC status for a requested GPU block
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_ecc_status` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
status = amdsmi_dev_get_ecc_status(device, AmdSmiGpuBlock.UMC)
2022-11-10 10:30:10 +01:00
print(status)
except AmdSmiException as e:
print(e)
` ``
## amdsmi_status_string
Description: Get a description of a provided AMDSMI error status
Input parameters:
* ` status` The error status for which a description is desired
Output: String description of the provided error code
Exceptions that can be thrown by ` amdsmi_status_string` function:
* ` AmdSmiParameterException`
Example:
` ``python
try:
status_str = amdsmi_status_string(ctypes.c_uint32(0))
print(status_str)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_get_compute_process_info
2022-11-10 10:30:10 +01:00
Description: Get process information about processes currently using GPU
Input parameters: None
Output: List of python dicts each containing a process information
Field | Description
---|---
` process_id` | Process ID
` pasid` | PASID
` vram_usage` | VRAM usage
` sdma_usage` | SDMA usage in microseconds
` cu_occupancy` | Compute Unit usage in percents
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_get_compute_process_info` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
Example:
` ``python
try:
2022-12-15 08:17:34 -06:00
procs = amdsmi_get_compute_process_info()
2022-11-10 10:30:10 +01:00
for proc in procs:
print(proc)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_get_compute_process_info_by_pid
2022-11-10 10:30:10 +01:00
Description: Get process information about processes currently using GPU
Input parameters:
* ` pid` The process ID for which process information is being requested
Output: Dict containing a process information
Field | Description
---|---
` process_id` | Process ID
` pasid` | PASID
` vram_usage` | VRAM usage
` sdma_usage` | SDMA usage in microseconds
` cu_occupancy` | Compute Unit usage in percents
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_get_compute_process_info_by_pid` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
pid = 0 # << valid pid here
2022-12-15 08:17:34 -06:00
proc = amdsmi_get_compute_process_info_by_pid(pid)
2022-11-10 10:30:10 +01:00
print(proc)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_get_compute_process_gpus
2022-11-10 10:30:10 +01:00
Description: Get the device indices currently being used by a process
Input parameters:
* ` pid` The process id of the process for which the number of gpus currently being used is requested
Output: List of indices of devices currently being used by the process
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_get_compute_process_gpus` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
pid = 0 # << valid pid here
2022-12-15 08:17:34 -06:00
indices = amdsmi_get_compute_process_gpus(pid)
2022-11-10 10:30:10 +01:00
print(indices)
except AmdSmiException as e:
print(e)
` ``
## amdsmi_dev_xgmi_error_status
Description: Retrieve the XGMI error status for a device
Input parameters:
* ` device_handle` handle for the given device
Output: XGMI error status for a requested device
Exceptions that can be thrown by ` amdsmi_dev_xgmi_error_status` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
status = amdsmi_dev_xgmi_error_status(device)
print(status)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_reset_xgmi_error
2022-11-10 10:30:10 +01:00
Description: Reset the XGMI error status for a device
Input parameters:
* ` device_handle` handle for the given device
Output: None
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_reset_xgmi_error` function:
2022-11-10 10:30:10 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
amdsmi_dev_reset_xgmi_error(device)
2022-11-10 10:30:10 +01:00
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_vendor_name
2022-11-10 15:29:32 +01:00
Description: Returns the device vendor name
Input parameters:
* ` device_handle` device which to query
Output: device vendor name
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_vendor_name` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
vendor_name = amdsmi_dev_get_vendor_name(device)
2022-11-10 15:29:32 +01:00
print(vendor_name)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_id
2022-11-10 15:29:32 +01:00
Description: Get the device id associated with the device with provided device handler
Input parameters:
* ` device_handle` device which to query
Output: device id
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_id` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
dev_id = amdsmi_dev_get_id(device)
2022-11-10 15:29:32 +01:00
print(dev_id)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_vram_vendor
2022-11-10 15:29:32 +01:00
Description: Get the vram vendor string of a gpu device.
Input parameters:
* ` device_handle` device which to query
Output: vram vendor
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_vram_vendor` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
vram_vendor = amdsmi_dev_get_vram_vendor(device)
2022-11-10 15:29:32 +01:00
print(vram_vendor)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_drm_render_minor
2022-11-10 15:29:32 +01:00
Description: Get the drm minor number associated with this device.
Input parameters:
* ` device_handle` device which to query
Output: drm minor number
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_drm_render_minor` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
render_minor = amdsmi_dev_get_drm_render_minor(device)
2022-11-10 15:29:32 +01:00
print(render_minor)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_subsystem_id
2022-11-10 15:29:32 +01:00
Description: Get the subsystem device id associated with the device with provided device handle.
Input parameters:
* ` device_handle` device which to query
Output: subsystem device id
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_subsystem_id` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
id = amdsmi_dev_get_subsystem_id(device)
2022-11-10 15:29:32 +01:00
print(id)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_dev_get_subsystem_name
2022-11-10 15:29:32 +01:00
Description: Get the name string for the device subsytem
Input parameters:
* ` device_handle` device which to query
Output: device subsytem
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_dev_get_subsystem_name` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
subsystem_nam = amdsmi_dev_get_subsystem_name(device)
2022-11-10 15:29:32 +01:00
print(subsystem_nam)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_get_version
2022-11-10 15:29:32 +01:00
Description: Get the build version information for the currently running build of AMDSMI.
Output: amdsmi build version
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_get_version` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
version = amdsmi_get_version()
2022-11-10 15:29:32 +01:00
print(version)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_get_version_str
2022-11-10 15:29:32 +01:00
Description: Get the driver version string for the current system.
Input parameters:
* ` sw_component` software component which to query
Output: driver version string
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_get_version_str` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
2022-12-15 08:17:34 -06:00
version = amdsmi_get_version_str(AmdSmiSwComponent.DRIVER)
2022-11-10 15:29:32 +01:00
print(version)
except AmdSmiException as e:
print(e)
` ``
## amdsmi_topo_get_numa_node_number
Description: Retrieve the NUMA CPU node number for a device
Input parameters:
* ` device_handle` device which to query
Output: node number of NUMA CPU for the device
Exceptions that can be thrown by ` amdsmi_topo_get_numa_node_number` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
node_number = amdsmi_topo_get_numa_node_number()
print(node_number)
except AmdSmiException as e:
print(e)
` ``
## amdsmi_topo_get_link_weight
Description: Retrieve the weight for a connection between 2 GPUs.
Input parameters:
* ` device_handle_src` the source device handle
* ` device_handle_dest` the destination device handle
Output: the weight for a connection between 2 GPUs
Exceptions that can be thrown by ` amdsmi_topo_get_link_weight` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
device_handle_src = devices[0]
device_handle_dest = devices[1]
weight = amdsmi_topo_get_link_weight(device_handle_src, device_handle_dest)
print(weight)
except AmdSmiException as e:
print(e)
` ``
2022-12-15 08:17:34 -06:00
## amdsmi_get_minmax_bandwidth
2022-11-10 15:29:32 +01:00
Description: Retreive minimal and maximal io link bandwidth between 2 GPUs.
Input parameters:
* ` device_handle_src` the source device handle
* ` device_handle_dest` the destination device handle
Output: Dictionary with fields:
Field | Description
---|---
` min_bandwidth` | minimal bandwidth for the connection
` max_bandwidth` | maximal bandwidth for the connection
2022-12-15 08:17:34 -06:00
Exceptions that can be thrown by ` amdsmi_get_minmax_bandwidth` function:
2022-11-10 15:29:32 +01:00
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
device_handle_src = devices[0]
device_handle_dest = devices[1]
2022-12-15 08:17:34 -06:00
bandwith = amdsmi_get_minmax_bandwidth(device_handle_src, device_handle_dest)
2022-11-10 15:29:32 +01:00
print(bandwith['min_bandwidth'])
print(bandwith['max_bandwidth'])
except AmdSmiException as e:
print(e)
` ``
## amdsmi_topo_get_link_type
Description: Retrieve the hops and the connection type between 2 GPUs
Input parameters:
* ` device_handle_src` the source device handle
* ` device_handle_dest` the destination device handle
Output: Dictionary with fields:
Field | Description
---|---
` hops` | number of hops
` type` | the connection type
Exceptions that can be thrown by ` amdsmi_topo_get_link_type` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
device_handle_src = devices[0]
device_handle_dest = devices[1]
link_type = amdsmi_topo_get_link_type(device_handle_src, device_handle_dest)
print(link_type['hops'])
print(link_type['type'])
except AmdSmiException as e:
print(e)
` ``
## amdsmi_is_P2P_accessible
Description: Return P2P availability status between 2 GPUs
Input parameters:
* ` device_handle_src` the source device handle
* ` device_handle_dest` the destination device handle
Output: P2P availability status between 2 GPUs
Exceptions that can be thrown by ` amdsmi_is_P2P_accessible` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
device_handle_src = devices[0]
device_handle_dest = devices[1]
accessible = amdsmi_is_P2P_accessible(device_handle_src, device_handle_dest)
print(accessible)
except AmdSmiException as e:
print(e)
` ``
## amdsmi_get_xgmi_info
Description: Returns XGMI information for the GPU.
Input parameters:
* ` device_handle` device handle
Output: Dictionary with fields:
Field | Description
---|---
` xgmi_lanes` | xgmi lanes
` xgmi_hive_id` | xgmi hive id
` xgmi_node_id` | xgmi node id
` index` | index
Exceptions that can be thrown by ` amdsmi_get_xgmi_info` function:
* ` AmdSmiLibraryException`
* ` AmdSmiRetryException`
* ` AmdSmiParameterException`
Example:
` ``python
try:
devices = amdsmi_get_device_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
xgmi_info = amdsmi_get_xgmi_info(device)
print(xgmi_info['xgmi_lanes'])
print(xgmi_info['xgmi_hive_id'])
print(xgmi_info['xgmi_node_id'])
print(xgmi_info['index'])
except AmdSmiException as e:
print(e)
` ``