Merge amd-dev into amd-master 20241111

Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Change-Id: Ica217a6e48f7deaf52d7021511ec8e8bf26c9a37


[ROCm/amdsmi commit: 9e221ebd93]
This commit is contained in:
Maisam Arif
2024-11-11 19:46:41 -06:00
کامیت 0fec6304c5
34فایلهای تغییر یافته به همراه3187 افزوده شده و 7608 حذف شده
+43 -60
مشاهده پرونده
@@ -6,7 +6,10 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
## amd_smi_lib for ROCm 6.3.0
### Changes
### Added
- **Added support for `amd-smi metric --ecc` & `amd-smi metric --ecc-blocks` on Guest VMs**.
Guest VMs now support getting current ECC counts and ras information from the Host cards.
- **Added support for GPU metrics 1.6 to `amdsmi_get_gpu_metrics_info()`**.
Updated `amdsmi_get_gpu_metrics_info()` and structure `amdsmi_gpu_metrics_t` to include new fields for PVIOL / TVIOL, XCP (Graphics Compute Partitions) stats, and pcie_lc_perf_other_end_recovery:
@@ -291,19 +294,6 @@ GPU: 1
...
```
- **Updated BDF commands to look use KFD SYSFS for BDF: `amdsmi_get_gpu_device_bdf()`**.
This aligns BDF output with ROCm SMI.
See below for overview as seen from `rsmi_dev_pci_id_get()` now provides partition ID. See API for better detail. Previously these bits were reserved bits (right before domain) and partition id was within function.
- bits [63:32] = domain
- bits [31:28] = partition id
- bits [27:16] = reserved
- bits [15: 0] = pci bus/device/function
- **Moved python tests directory path install location**.
- `/opt/<rocm-path>/share/amd_smi/pytest/..` to `/opt/<rocm-path>/share/amd_smi/tests/python_unittest/..`
- On amd-smi-lib-tests uninstall, the amd_smi tests folder is removed.
- Removed pytest dependency, our python testing now only depends on the unittest framework.
- **Added retrieving a set of GPUs that are nearest to a given device at a specific link type level**.
- Added `amdsmi_get_link_topology_nearest()` function to amd-smi C and Python Libraries.
@@ -505,7 +495,22 @@ GPU: 0
TARGET_GRAPHICS_VERSION: gfx942
```
- **Udpated Partition APIs and struct information and added and partition_id to `amd-smi static --partition`**.
### Changed
- **Updated BDF commands to look use KFD SYSFS for BDF: `amdsmi_get_gpu_device_bdf()`**.
This aligns BDF output with ROCm SMI.
See below for overview as seen from `rsmi_dev_pci_id_get()` now provides partition ID. See API for better detail. Previously these bits were reserved bits (right before domain) and partition id was within function.
- bits [63:32] = domain
- bits [31:28] = partition id
- bits [27:16] = reserved
- bits [15: 0] = pci bus/device/function
- **Moved python tests directory path install location**.
- `/opt/<rocm-path>/share/amd_smi/pytest/..` to `/opt/<rocm-path>/share/amd_smi/tests/python_unittest/..`
- On amd-smi-lib-tests uninstall, the amd_smi tests folder is removed
- Removed pytest dependency, our python testing now only depends on the unittest framework.
- **Updated Partition APIs and struct information and added and partition_id to `amd-smi static --partition`**.
- As part of an overhaul to partition information, some partition information will be made available in the `amdsmi_accelerator_partition_profile_t`.
- This struct will be filled out by a new API, `amdsmi_get_gpu_accelerator_partition_profile()`.
- Future data from these APIs wil will eventually get added to `amd-smi partition`.
@@ -569,7 +574,7 @@ GPU: 0
PARTITION_ID: 0
```
### Removals
### Removed
- **Removed `amd-smi reset --compute-partition` and `... --memory-partition` and associated APIs**.
- This change is part of the partition redesign. Reset functionality will be reintroduced in a later update.
@@ -578,13 +583,7 @@ GPU: 0
- **Removed usage of _validate_positive in Parser and replaced with _positive_int and _not_negative_int as appropriate**.
- This will allow 0 to be a valid input for several options in setting CPUs where appropriate (for example, as a mode or NBIOID)
- **Removed `--ras` option from `amd-smi static` command in Guest environments**.
- VMs don't have permission from Hosts to obtain RAS information, so this option was made invalid on Guest environments.
- **Removed `--ecc` option from `amd-smi monitor` command in Guest environments**.
- Guest VMs do not support getting current ECC counts from the Host cards.
### Optimizations
### Optimized
- **Adjusted ordering of gpu_metrics calls to ensure that pcie_bw values remain stable in `amd-smi metric` & `amd-smi monitor`**.
- With this change additional padding was added to PCIE_BW `amd-smi monitor --pcie`
@@ -650,10 +649,6 @@ GPU POWER GPU_TEMP MEM_TEMP VRAM_USED VRAM_TOTAL
- **`amdsmitst` TestGpuMetricsRead now prints metric in correct units**.
### Known issues
- N/A
### Upcoming changes
- **Python API for `amdsmi_get_energy_count()` will deprecate the `power` field in ROCm 6.4 and use `energy_accumulator` field instead**.
@@ -691,7 +686,7 @@ amdsmi_set_gpu_memory_partition(amdsmi_processor_handle processor_handle,
## amd_smi_lib for ROCm 6.2.1
### Additions
### Added
- **Removed `amd-smi metric --ecc` & `amd-smi metric --ecc-blocks` on Guest VMs**.
Guest VMs do not support getting current ECC counts from the Host cards.
@@ -699,11 +694,7 @@ Guest VMs do not support getting current ECC counts from the Host cards.
- **Added `amd-smi static --ras`on Guest VMs**.
Guest VMs can view enabled/disabled ras features that are on Host cards.
### Optimizations
- N/A
### Fixes
### Resolved issues
- **Fixed TypeError in `amd-smi process -G`**.
@@ -713,13 +704,9 @@ Guest VMs can view enabled/disabled ras features that are on Host cards.
- **Fixed firmware formatting where leading 0s were missing**.
### Known Issues
- N/A
## amd_smi_lib for ROCm 6.2.0
### Additions
### Added
- **`amd-smi dmon` is now available as an alias to `amd-smi monitor`**.
@@ -753,7 +740,7 @@ Added macros to reference max size limitations for certain amdsmi functions such
- **Added Ring Hang event**.
Added `AMDSMI_EVT_NOTIF_RING_HANG` to the possible events in the `amdsmi_evt_notification_type_t` enum.
### Optimizations
### Optimized
- **Updated CLI error strings to specify invalid device type queried**
@@ -856,7 +843,7 @@ GPU: 0
Updated sizes that work for retreiving relavant board information across AMD's
ASIC products. This requires users to update any ABIs using this structure.
### Fixes
### Resolved issues
- **Fixed Leftover Mutex deadlock when running multiple instances of the CLI tool**.
When running `amd-smi reset --gpureset --gpu all` and then running an instance of `amd-smi static` (or any other subcommand that access the GPUs) a mutex would lock and not return requiring either a clear of the mutex in /dev/shm or rebooting the machine.
@@ -906,13 +893,13 @@ structures data members which cannot be populated. Ensuring empty char string va
- **Fixed parsing of `pp_od_clk_voltage` within `amdsmi_get_gpu_od_volt_info`**.
The parsing of `pp_od_clk_voltage` was not dynamic enough to work with the dropping of voltage curve support on MI series cards. This propagates down to correcting the CLI's output `amd-smi metric --voltage-curve` to N/A if voltage curve is not enabled.
### Known Issues
### Known issues
- **`amdsmi_get_gpu_process_isolation` and `amdsmi_clean_gpu_local_data` commands do no currently work and will be supported in a future release**.
## amd_smi_lib for ROCm 6.1.2
### Additions
### Added
- **Added process isolation and clean shader APIs and CLI commands**.
Added APIs CLI and APIs to address LeftoverLocals security issues. Allowing clearing the sram data and setting process isolation on a per GPU basis. New APIs:
@@ -950,7 +937,7 @@ GPU: 1
SHUTDOWN_VRAM_TEMPERATURE: 105 °C
```
### Optimizations
### Optimized
- **Updated `amd-smi monitor --pcie` output**.
The source for pcie bandwidth monitor output was a legacy file we no longer support and was causing delays within the monitor command. The output is no longer using TX/RX but instantaneous bandwidth from gpu_metrics instead; updated output:
@@ -1007,7 +994,7 @@ GPU: 0
- **Removed `amdsmi_get_gpu_process_info` from Python library**.
amdsmi_get_gpu_process_info was removed from the C library in an earlier build, but the API was still in the Python interface.
### Fixes
### Resolved issues
- **Fixed `amd-smi metric --power` now provides power output for Navi2x/Navi3x/MI1x**.
These systems use an older version of gpu_metrics in amdgpu. This fix only updates what CLI outputs.
@@ -1040,13 +1027,9 @@ Updates required `amdsmi_get_power_cap_info` to return in uW as originally refle
- **Fixed Python interface call amdsmi_get_gpu_memory_reserved_pages & amdsmi_get_gpu_bad_page_info**.
Previously Python interface calls to populated bad pages resulted in a `ValueError: NULL pointer access`. This fixes the bad-pages subcommand CLI subcommand as well.
### Known Issues
- N/A
## amd_smi_lib for ROCm 6.1.1
### Changes
### Changed
- **Updated metrics --clocks**.
Output for `amd-smi metric --clock` is updated to reflect each engine and bug fixes for the clock lock status and deep sleep status.
@@ -1316,7 +1299,7 @@ $ /opt/rocm/bin/amd-smi topology -a -t --json
]
```
### Fixes
### Resolved issues
- **Fix for GPU reset error on non-amdgpu cards**.
Previously our reset could attempting to reset non-amd GPUS- resuting in "Unable to reset non-amd GPU" error. Fix
@@ -1338,7 +1321,7 @@ Fixed Attribute Error when getting process in csv format
## amd_smi_lib for ROCm 6.1.0
### Additions
### Added
- **Added Monitor Command**.
Provides users the ability to customize GPU metrics to capture, collect, and observe. Output is provided in a table view. This aligns closer to ROCm SMI `rocm-smi` (no argument), additionally allows uers to customize what data is helpful for their use-case.
@@ -1662,7 +1645,7 @@ amd-smi metric -p --json
]
```
### Changes
### Changed
- **Topology is now left-aligned with BDF of each device listed individual table's row/coloumns**.
We provided each device's BDF for every table's row/columns, then left aligned data. We want AMD SMI Tool output to be easy to understand and digest for our users. Having users scroll up to find this information made it difficult to follow, especially for devices which have many devices associated with one ASIC.
@@ -1725,7 +1708,7 @@ NUMA BW TABLE:
0000:df:00.0 50000-50000 50000-50000 50000-50000 50000-50000 50000-50000 50000-50000 50000-50000 N/A
```
### Fixes
### Resolved issues
- **Fix for Navi3X/Navi2X/MI100 `amdsmi_get_gpu_pci_bandwidth()` in frequencies_read tests**.
Devices which do not report (eg. Navi3X/Navi2X/MI100) we have added checks to confirm these devices return AMDSMI_STATUS_NOT_SUPPORTED. Otherwise, tests now display a return string.
@@ -1746,7 +1729,7 @@ AMD SMI now uses same mutex handler for devices as rocm-smi. This helps avoid cr
## amd_smi_lib for ROCm 6.0.0
### Additions
### Added
- **Integrated the E-SMI (EPYC-SMI) library**.
You can now query CPU-related information directly through AMD SMI. Metrics include power, energy, performance, and other system details.
@@ -1757,11 +1740,7 @@ You can now query MI300 device metrics to get real-time information. Metrics inc
- **Compute and memory partition support**.
Users can now view, set, and reset partitions. The topology display can provide a more in-depth look at the device's current configuration.
### Optimizations
- Updated to C++17, gtest-1.14, and cmake 3.14
### Changes
### Changed
- **GPU index sorting made consistent with other tools**.
To ensure alignment with other ROCm software tools, GPU index sorting is optimized to use Bus:Device.Function (BDF) rather than the card number.
@@ -1769,7 +1748,11 @@ To ensure alignment with other ROCm software tools, GPU index sorting is optimiz
Earlier versions of the topology output were difficult to read since each GPU was displayed linearly.
Now the information is displayed as a table by each GPU's BDF, which closer resembles rocm-smi output.
### Fixes
### Optimized
- Updated to C++17, gtest-1.14, and cmake 3.14
### Resolved issues
- **Fix for driver not initialized**.
If driver module is not loaded, user retrieve error reponse indicating amdgpu module is not loaded.
@@ -28,7 +28,7 @@ find_program(GIT NAMES git)
## Setup the package version based on git tags.
set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver")
get_package_version_number("24.7.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
get_package_version_number("24.7.1" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
message("Package version: ${PKG_VERSION_STR}")
set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}")
set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}")
+154 -293
مشاهده پرونده
@@ -1,345 +1,195 @@
# AMD System Management Interface (AMD SMI) Library
# AMD System Management Interface (AMD SMI) library
The AMD System Management Interface Library, or AMD SMI library, is a C library for Linux that provides a user space interface for applications to monitor and control AMD devices.
The AMD System Management Interface (AMD SMI) library offers a unified tool for managing and monitoring GPUs,
particularly in high-performance computing environments. It provides a user-space interface that allows applications to
control GPU operations, monitor performance, and retrieve information about the system's drivers and GPUs.
For additional information refer to [ROCm Documentation](https://rocm.docs.amd.com/projects/amdsmi/en/latest/)
For information on available features, installation steps, API reference material, and helpful tips, refer to the online
documentation at [rocm.docs.amd.com/projects/amdsmi](https://rocm.docs.amd.com/projects/amdsmi/en/latest/)
Note: This project is a successor to [rocm_smi_lib](https://github.com/RadeonOpenCompute/rocm_smi_lib)
and [esmi_ib_library](https://github.com/amd/esmi_ib_library)
>[!NOTE]
>This project is a successor to [rocm_smi_lib](https://github.com/ROCm/rocm_smi_lib)
>and [esmi_ib_library](https://github.com/amd/esmi_ib_library).
## Supported platforms
At initial release, the AMD SMI library will support Linux bare metal and Linux virtual machine guest for AMD GPUs. In the future release, the library will be extended to support AMD EPYC™ CPUs.
At initial release, the AMD SMI library will support Linux bare metal and Linux
virtual machine guest for AMD GPUs. In a future release, the library will be
extended to support AMD EPYC™ CPUs.
AMD SMI library can run on AMD ROCm supported platforms, refer to [System requirements (Linux)](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html) for more information.
AMD SMI library can run on AMD ROCm supported platforms, refer to
[System requirements (Linux)](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html)
for more information.
To run the AMD SMI library, the amdgpu driver and the hsmp driver needs to be installed. Optionally, the libdrm can be
installed to query firmware information and hardware IPs.
## Installation
## Install CLI Tool and Libraries
* [Install the AMD SMI library and CLI tool](https://rocm.docs.amd.com/projects/amdsmi/en/latest/install/install.html)
**Disclaimer: CLI Tool is provided as an example code to aid the development of telemetry tools and is not guaranteed to be backwards compatible. The Python or C++ Library is recommended as a reliable data source.**
## Requirements
The following are required to install and use the AMD SMI libraries and CLI tool.
### Requirements
* Python 3.6.8+ (64-bit)
* `amdgpu` driver must be loaded for [`amdsmi_init()`](./docs/how-to/amdsmi-cpp-lib#hello-amd-smi) to work.
* python 3.6.8+ 64-bit
- prerequisite modules:
- python3-wheel
- python3-setuptools
* amdgpu driver must be loaded for amdsmi_init() to pass
## Install amdgpu driver and AMD SMI with ROCm
### Installation
1. Get the `amdgpu-install` installer following the instructions for your Linux distribution at
[Installation via AMDGPU installer](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/amdgpu-install.html#installation).
### Install amdgpu using ROCm
* Install amdgpu driver:
See example below, your release and link may differ. The `amdgpu-install --usecase=rocm` triggers both an amdgpu driver update and AMD SMI packages to be installed on your device.
```shell
sudo apt update
wget https://repo.radeon.com/amdgpu-install/6.0.2/ubuntu/jammy/amdgpu-install_6.0.60002-1_all.deb
sudo apt install ./amdgpu-install_6.0.60002-1_all.deb
sudo amdgpu-install --usecase=rocm
```
* amd-smi --help
2. Use `amdgpu-install` to install the `amdgpu` driver and ROCm packages with
AMD SMI included.
### Install Example for Ubuntu 22.04 (without ROCm)
``` shell
sudo amdgpu-install --usecase=rocm
```
``` bash
apt install amd-smi-lib
# if installed with rocm ignore the export
export PATH="${PATH:+${PATH}:}~/opt/rocm/bin"
amd-smi --help
```
The `amdgpu-install --usecase=rocm` option triggers both an `amdgpu` driver
update and AMD SMI packages to be installed on your device.
### Optional autocompletion
3. Verify your installation.
`amd-smi` cli application supports autocompletion. The package should attempt to install it, if argcomplete is not installed you can enable it by using the following commands:
```shell
amd-smi --help
```
```bash
python3 -m pip install argcomplete
activate-global-python-argcomplete --user
# restart shell to enable
```
## Install AMD SMI without ROCm
### Manual/Multiple Rocm Instance Python Library Install
The following are example steps to install the AMD SMI libraries and CLI tool on
Ubuntu 22.04.
In the event there are multiple rocm installations and pyenv is not being used, to use the correct amdsmi version you must uninstall previous versions of amd-smi and install the version you want directly from your rocm instance.
1. Install the library.
#### Python Library Install Example for Ubuntu 22.04
```shell
sudo apt install amd-smi-lib
```
Remove previous amdsmi installation:
2. Add the installation directory to your PATH. If installed with ROCm, ignore
this step.
```bash
python3 -m pip list | grep amd
python3 -m pip uninstall amdsmi
```
```shell
export PATH="${PATH:+${PATH}:}~/opt/rocm/bin"
```
Then install Python library from your target rocm instance:
3. Verify your installation.
``` bash
apt install amd-smi-lib
cd /opt/rocm/share/amd_smi
python3 -m pip install --upgrade pip
python3 -m pip install --user .
```
```shell
amd-smi --help
```
Now you have the amdsmi python library in your python path:
## AMD SMI basic usage
``` bash
~$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import amdsmi
>>>
```
### C++ library
### Installing the Python Prerequisite Modules
For developers focused on performance monitoring, system diagnostics, or resource management, the AMD SMI C++ library
offers a powerful and versatile tool to unlock the full capabilities of AMD hardware.
Python3-setuptools and python3-wheel can both be installed through the pip installer as shown below:
Refer to the [user guide](https://rocm.docs.amd.com/projects/amdsmi/en/latest/how-to/amdsmi-cpp-lib.html) and the
detailed [C++ API reference](https://rocm.docs.amd.com/projects/amdsmi/en/latest/reference/amdsmi-cpp-api.html) in the
ROCm documentation portal.
```bash
python3 -m pip install setuptools wheel
```
### Python library
## Usage Basics for the C Library
The AMD SMI Python interface provides an easy-to-use
[API](https://rocm.docs.amd.com/projects/amdsmi/en/latest/reference/amdsmi-py-lib.html) for interacting with AMD
hardware. It simplifies tasks like monitoring and controlling GPU operations, allowing for rapid development.
### Device/Socket handles
Refer to the [user guide](https://rocm.docs.amd.com/projects/amdsmi/en/latest/how-to/amdsmi-py-lib.html) and the
detailed [Python API reference](https://rocm.docs.amd.com/projects/amdsmi/en/latest/reference/amdsmi-py-api.html) in the
ROCm documentation portal.
Many of the functions in the library take a "socket handle" or "device handle". The socket is an abstraction of hardware physical socket. This will enable amd-smi to provide a better representation of the hardware to user. Although there is always one distinct GPU for a socket, the APU may have both
GPU device and CPU device on the same socket. Moreover, for MI200, it may have multiple GCDs.
### CLI tool
To discover the sockets in the system, `amdsmi_get_socket_handles()` is called to get list of sockets
handles, which in turn can be used to query the devices in that socket using `amdsmi_get_processor_handles()`. The device handler is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different device handles after restart application, so a device handle should not be relied upon to be constant over process.
A versatile command line tool for managing and monitoring AMD hardware. You can use `amd-smi` for:
The list of socket handles discovered using `amdsmi_get_socket_handles()`,can also be used to query the cpus in that socket using `amdsmi_get_processor_handles_by_type()`, which in turn can then be used to query the cores in that cpu using `amdsmi_get_processor_handles_by_type()` again.
- Device information: Quickly retrieve detailed information about AMD GPUs
- Performance monitoring: Real-time monitoring of GPU utilization, memory, temperature, and power consumption
## Hello AMD SMI
- Process information: Identify which processes are using GPUs
The only required AMD-SMI call for any program that wants to use AMD-SMI is the `amdsmi_init()` call. This call initializes some internal data structures that will be used by subsequent AMD-SMI calls. In the call, a flag can be passed if the application is only interested in a specific device type.
- Configuration management: Adjust GPU settings like clock speeds and power limits
When AMD-SMI is no longer being used, `amdsmi_shut_down()` should be called. This provides a way to do any releasing of resources that AMD-SMI may have held.
- Error reporting: Monitor and report GPU errors for proactive maintenance
1) A simple "Hello World" type program that displays the temperature of detected devices would look like this:
```c++
#include <iostream>
#include <vector>
#include "amd_smi/amdsmi.h"
int main() {
amdsmi_status_t ret;
// Init amdsmi for sockets and devices. Here we are only interested in AMD_GPUS.
ret = amdsmi_init(AMDSMI_INIT_AMD_GPUS);
// Get all sockets
uint32_t socket_count = 0;
// Get the socket count available in the system.
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the socket handles in the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get identifier and devices
for (uint32_t i=0; i < socket_count; i++) {
// Get Socket info
char socket_info[128];
ret = amdsmi_get_socket_info(sockets[i], 128, socket_info);
std::cout << "Socket " << socket_info<< std::endl;
// Get the device count for the socket.
uint32_t device_count = 0;
ret = amdsmi_get_processor_handles(sockets[i], &device_count, nullptr);
// Allocate the memory for the device handlers on the socket
std::vector<amdsmi_processor_handle> processor_handles(device_count);
// Get all devices of the socket
ret = amdsmi_get_processor_handles(sockets[i],
&device_count, &processor_handles[0]);
// For each device of the socket, get name and temperature.
for (uint32_t j=0; j < device_count; j++) {
// Get device type. Since the amdsmi is initialized with
// AMD_SMI_INIT_AMD_GPUS, the processor_type must be AMDSMI_PROCESSOR_TYPE_AMD_GPU.
processor_type_t processor_type;
ret = amdsmi_get_processor_type(processor_handles[j], &processor_type);
if (processor_type != AMDSMI_PROCESSOR_TYPE_AMD_GPU) {
std::cout << "Expect AMDSMI_PROCESSOR_TYPE_AMD_GPU device type!\n";
return 1;
}
// Get device name
amdsmi_board_info_t board_info;
ret = amdsmi_get_gpu_board_info(processor_handles[j], &board_info);
std::cout << "\tdevice "
<< j <<"\n\t\tName:" << board_info.product_name << std::endl;
// Get temperature
int64_t val_i64 = 0;
ret = amdsmi_get_temp_metric(processor_handles[j], AMDSMI_TEMPERATURE_TYPE_EDGE,
AMDSMI_TEMP_CURRENT, &val_i64);
std::cout << "\t\tTemperature: " << val_i64 << "C" << std::endl;
}
}
// Clean up resources allocated at amdsmi_init. It will invalidate sockets
// and devices pointers
ret = amdsmi_shut_down();
return 0;
}
```
2) A sample program that displays the power of detected cpus would look like this:
```c++
#include <iostream>
#include <vector>
#include "amd_smi/amdsmi.h"
int main(int argc, char **argv) {
amdsmi_status_t ret;
uint32_t socket_count = 0;
// Initialize amdsmi for AMD CPUs
ret = amdsmi_init(AMDSMI_INIT_AMD_CPUS);
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the sockets of the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get cpus
for (uint32_t i = 0; i < socket_count; i++) {
uint32_t cpu_count = 0;
// Set processor type as AMDSMI_PROCESSOR_TYPE_AMD_CPU
processor_type_t processor_type = AMDSMI_PROCESSOR_TYPE_AMD_CPU;
ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, nullptr, &cpu_count);
// Allocate the memory for the cpus
std::vector<amdsmi_processor_handle> plist(cpu_count);
// Get the cpus for each socket
ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, &plist[0], &cpu_count);
for (uint32_t index = 0; index < plist.size(); index++) {
uint32_t socket_power;
std::cout<<"CPU "<<index<<"\t"<< std::endl;
std::cout<<"Power (Watts): ";
ret = amdsmi_get_cpu_socket_power(plist[index], &socket_power);
if(ret != AMDSMI_STATUS_SUCCESS)
std::cout<<"Failed to get cpu socket power"<<"["<<index<<"] , Err["<<ret<<"] "<< std::endl;
if (!ret) {
std::cout<<static_cast<double>(socket_power)/1000<<std::endl;
}
std::cout<<std::endl;
}
}
// Clean up resources allocated at amdsmi_init
ret = amdsmi_shut_down();
return 0;
}
```
### Documentation
The reference manual, `AMD_SMI_Manual.pdf` will be in the /opt/rocm/share/doc/amd_smi directory upon a successful build.
### Sphinx Documentation
To build the documentation locally, run the commands below:
``` bash
cd docs
python3 -m pip install -r sphinx/requirements.txt
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
```
The output will be in `docs/_build/html`.
For additional details, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html).
Check out
[Getting to Know Your GPU: A Deep Dive into AMD SMI -- ROCm Blogs](https://rocm.blogs.amd.com/software-tools-optimization/amd-smi-overview/README.html)
for a rundown.
## Building AMD SMI
### Rebuilding Python wrapper
This section describes the prerequisites and steps to build AMD SMI from source.
The python wrapper (binding) is an auto-generated file `py-interface/amdsmi_wrapper.py`
### Required software
Wrapper should be re-generated on each C++ API change, by doing:
To build the AMD SMI library, the following components are required. Note that the software versions specified were used
during development; earlier versions are not guaranteed to work.
```bash
* CMake (v3.14.0 or later) -- `python3 -m pip install cmake`
* g++ (v5.4.0 or later)
In order to build the AMD SMI Python package, the following components are required:
* Python (3.6.8 or later)
* prerequisite modules:
* python3-wheel
* python3-setuptools
* virtualenv -- `python3 -m pip install virtualenv`
### Build steps
1. Clone the AMD SMI repository to your local Linux machine.
```shell
git clone https://github.com/ROCm/amdsmi.git
```
2. The default installation location for the library and headers is `/opt/rocm`. Before installation, any old ROCm
directories should be deleted:
* `/opt/rocm`
* `/opt/rocm-<version_number>`
3. Build the library by following the typical CMake build sequence (run as root user or use `sudo` before `make install`
command); for instance:
```bash
mkdir -p build
cd build
cmake ..
make -j $(nproc)
make install
```
The built library is located in the `build/` directory. To build the `rpm` and `deb` packages use the following
command:
```bash
make package
```
### Rebuild the Python wrapper
The Python wrapper for the AMD SMI library is found in the [auto-generated file](#py_lib_fs)
`py-interface/amdsmi_wrapper.py`. It is essential to regenerate this wrapper whenever there are changes to the C++ API.
It is not regenerated automatically.
To regenerate the wrapper, use the following command.
```shell
./update_wrapper.sh
```
After this command, the file in `py-interface/amdsmi_wrapper.py` will be automatically updated on each compile.
After this command, the file in `py-interface/amdsmi_wrapper.py` will be updated
on compile.
Note: To be able to re-generate python wrapper you need **docker** installed.
>[!NOTE]
>You need Docker installed on your system to regenerate the Python wrapper.
Note: python_wrapper is NOT automatically re-generated. You must run `./update_wrapper.sh`.
### Build the tests
### Additional Required software for building
In order to build the AMD SMI library, the following components are required. Note that the software versions listed are what was used in development. Earlier versions are not guaranteed to work:
* CMake (v3.14.0) - `python3 -m pip install cmake`
* g++ (5.4.0)
In order to build the AMD SMI python package, the following components are required:
* python (3.6.8 or above)
* virtualenv - `python3 -m pip install virtualenv`
In order to build the latest documentation, the following are required:
* DOxygen (1.8.11)
* latex (pdfTeX 3.14159265-2.6-1.40.16)
The source code for AMD SMI is available on Github.
After the AMD SMI library git repository has been cloned to a local Linux machine, the Default location for the library and headers is /opt/rocm. Before installation, the old rocm directories should be deleted:
/opt/rocm
/opt/rocm-{number}
Building the library is achieved by following the typical CMake build sequence (run as root user or use 'sudo' before 'make install' command), specifically:
```bash
mkdir -p build
cd build
cmake ..
make -j $(nproc)
make install
```
The built library will appear in the `build` folder.
To build the rpm and deb packages follow the above steps with:
```bash
make package
```
### Building the Tests
In order to verify the build and capability of AMD SMI on your system and to see an example of how AMD SMI can be used, you may build and run the tests that are available in the repo. To build the tests, follow these steps:
To verify the build and capabilities of AMD SMI on your system, as well as to see practical examples of its usage, you
can build and run the available [tests in the repository](https://github.com/ROCm/amdsmi/tree/amd-staging/tests). Follow
these steps to build the tests:
```bash
mkdir -p build
@@ -348,13 +198,24 @@ cmake -DBUILD_TESTS=ON ..
make -j $(nproc)
```
### Run the Tests
#### Run the tests
To run the test, execute the program `amdsmitst` that is built from the steps above.
Path to the program `amdsmitst`: build/tests/amd_smi_test/
Once the tests are [built](#build-the-tests), you can run them by executing the `amdsmitst` program. The executable can
be found at `build/tests/amd_smi_test/`.
### Build the docs
To build the documentation, follow the instructions at
[Building documentation](https://rocm.docs.amd.com/en/latest/contribute/building.html).
## DISCLAIMER
The information contained herein is for informational purposes only, and is subject to change without notice. In addition, any stated support is planned and is also subject to change. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein.
The information contained herein is for informational purposes only, and is subject to change without notice. In
addition, any stated support is planned and is also subject to change. While every precaution has been taken in the
preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is
under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes
no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular
purposes, with respect to the operation or use of AMD hardware, software or other products described herein.
© 2023-2024 Advanced Micro Devices, Inc. All Rights Reserved.
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است Diff را بارگزاری کن
@@ -311,6 +311,8 @@ class AMDSMICommands():
args.board = board
if driver:
args.driver = driver
if ras:
args.ras = ras
if vram:
args.vram = vram
if cache:
@@ -319,14 +321,12 @@ class AMDSMICommands():
args.process_isolation = process_isolation
# Store args that are applicable to the current platform
current_platform_args = ["asic", "bus", "vbios", "driver",
current_platform_args = ["asic", "bus", "vbios", "driver", "ras",
"vram", "cache", "board", "process_isolation"]
current_platform_values = [args.asic, args.bus, args.vbios, args.driver,
current_platform_values = [args.asic, args.bus, args.vbios, args.driver, args.ras,
args.vram, args.cache, args.board, args.process_isolation]
if self.helpers.is_linux() and self.helpers.is_baremetal():
if ras:
args.ras = ras
if partition:
args.partition = partition
if limit:
@@ -336,8 +336,7 @@ class AMDSMICommands():
if xgmi_plpd:
args.xgmi_plpd = xgmi_plpd
current_platform_args += ["ras", "limit", "partition", "soc_pstate", "xgmi_plpd"]
current_platform_values += [args.ras, args.limit, args.partition,
args.soc_pstate, args.xgmi_plpd]
current_platform_values += [args.ras, args.limit, args.partition, args.soc_pstate, args.xgmi_plpd]
if self.helpers.is_linux() and not self.helpers.is_virtual_os():
if numa:
@@ -1250,17 +1249,13 @@ class AMDSMICommands():
args.temperature = temperature
if pcie:
args.pcie = pcie
current_platform_args += ["usage", "power", "clock", "temperature", "pcie"]
current_platform_values += [args.usage, args.power, args.clock,
args.temperature, args.pcie]
# Only args that are applicable to Hypervisors and BM Linux
if self.helpers.is_hypervisor() or (self.helpers.is_baremetal() and self.helpers.is_linux()):
if ecc:
args.ecc = ecc
if ecc_blocks:
args.ecc_blocks = ecc_blocks
current_platform_args += ["ecc", "ecc_blocks"]
current_platform_args += ["usage", "power", "clock", "temperature", "pcie", "ecc", "ecc_blocks"]
current_platform_values += [args.usage, args.power, args.clock,
args.temperature, args.pcie]
current_platform_values += [args.ecc, args.ecc_blocks]
if self.helpers.is_baremetal() and self.helpers.is_linux():
@@ -4035,16 +4030,47 @@ class AMDSMICommands():
raise ValueError(f"Unable to set XGMI policy to {args.xgmi_plpd} on {gpu_string}") from e
self.logger.store_output(args.gpu, 'xgmiplpd', f"Successfully set per-link power down policy to id {args.xgmi_plpd}")
if isinstance(args.clk_limit, tuple):
clk_type = args.clk_limit.clk_type
lim_type = args.clk_limit.lim_type
val = args.clk_limit.val
val_changed = True # Assume Clock limit value is changed
# Validate the value against the extremum
try:
clk_type = args.clk_limit.clk_type
lim_type = args.clk_limit.lim_type
val = args.clk_limit.val
amdsmi_interface.amdsmi_set_gpu_clk_limit(args.gpu, clk_type, lim_type, val)
# Parser only allows two options sclk or mclk
if clk_type == "sclk":
amdsmi_clk_type = amdsmi_interface.AmdSmiClkType.GFX
elif clk_type == "mclk":
amdsmi_clk_type = amdsmi_interface.AmdSmiClkType.MEM
clk_tuple = amdsmi_interface.amdsmi_get_clock_info(args.gpu, amdsmi_clk_type)
if lim_type == "min":
if val > clk_tuple['max_clk']:
raise IndexError("cannot set min value greater than max")
if val == clk_tuple['min_clk']:
val_changed = False # Clock limit value did not changed
if lim_type == "max":
if val < clk_tuple['min_clk']:
raise IndexError("cannot set max value less than min")
if val == clk_tuple['max_clk']:
val_changed = False # Clock limit value did not changed
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get clock extremum info for gpu %s | %s", gpu_id, e.get_error_info())
# Set the value
try:
if val_changed:
amdsmi_interface.amdsmi_set_gpu_clk_limit(args.gpu, clk_type, lim_type, val)
except amdsmi_exception.AmdSmiLibraryException as e:
if e.get_error_code() == amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NO_PERM:
raise PermissionError('Command requires elevation') from e
raise ValueError(f"Unable to set {args.clk_limit.lim_type} of {args.clk_limit.clk_type} to {args.clk_limit.val} on {gpu_string}") from e
self.logger.store_output(args.gpu, 'clk_limit', f"Successfully changed {args.clk_limit.lim_type} of {args.clk_limit.clk_type} to {args.clk_limit.val}")
if val_changed:
self.logger.store_output(args.gpu, 'clk_limit', f"Successfully changed {args.clk_limit.lim_type} of {args.clk_limit.clk_type} to {args.clk_limit.val}")
else:
self.logger.store_output(args.gpu, 'clk_limit', f"Clock limit is already set to {args.clk_limit.val}")
if isinstance(args.process_isolation, int):
status_string = "Enabled" if args.process_isolation else "Disabled"
@@ -4493,22 +4519,6 @@ class AMDSMICommands():
if args.gpu == None:
args.gpu = self.device_handles
# handle platform for ecc
if self.helpers.is_virtual_os():
args.ecc = False
if not any([args.power_usage, args.temperature, args.gfx, args.mem,
args.encoder, args.decoder, args.vram_usage, args.pcie, args.violation]):
args.power_usage = args.temperature = args.gfx = args.mem = \
args.encoder = args.decoder = \
args.vram_usage = args.pcie = args.violation = True
else:
if not any([args.power_usage, args.temperature, args.gfx, args.mem,
args.encoder, args.decoder, args.ecc,
args.vram_usage, args.pcie, args.violation]):
args.power_usage = args.temperature = args.gfx = args.mem = \
args.encoder = args.decoder = args.ecc = \
args.vram_usage = args.pcie = args.violation = True
# If all arguments are False, the print all values
# Don't include process in this logic as it's an optional edge case
if not any([args.power_usage, args.temperature, args.gfx, args.mem,
@@ -78,41 +78,6 @@ class AMDSMIHelpers():
self._is_passthrough = True
def os_info(self, string_format=True):
"""Return operating_system and type information ex. (Linux, Baremetal)
params:
string_format (bool) True to return in string format, False to return Tuple
returns:
str or (str, str)
"""
operating_system = ""
if self._is_linux:
operating_system = "Linux"
elif self._is_windows:
operating_system = "Windows"
else:
operating_system = "Unknown"
operating_system_type = ""
if self._is_baremetal:
operating_system_type = "Baremetal"
elif self._is_virtual_os:
operating_system_type = "Guest"
elif self._is_hypervisor:
operating_system_type = "Hypervisor"
else:
operating_system_type = "Unknown"
# Passthrough Override
if self._is_passthrough:
operating_system_type = "Guest (Passthrough)"
if string_format:
return f"{operating_system} {operating_system_type}"
return (operating_system, operating_system_type)
def is_virtual_os(self):
return self._is_virtual_os
@@ -126,6 +91,9 @@ class AMDSMIHelpers():
# Returns True if system is baremetal, if system is hypervisor this should return False
return self._is_baremetal
def is_passthrough(self):
return self._is_passthrough
def is_linux(self):
return self._is_linux
@@ -135,6 +103,41 @@ class AMDSMIHelpers():
return self._is_windows
def os_info(self, string_format=True):
"""Return operating_system and type information ex. (Linux, Baremetal)
params:
string_format (bool) True to return in string format, False to return Tuple
returns:
str or (str, str)
"""
operating_system = ""
if self.is_linux():
operating_system = "Linux"
elif self.is_windows():
operating_system = "Windows"
else:
operating_system = "Unknown"
operating_system_type = ""
if self.is_baremetal():
operating_system_type = "Baremetal"
elif self.is_virtual_os():
operating_system_type = "Guest"
elif self.is_hypervisor():
operating_system_type = "Hypervisor"
else:
operating_system_type = "Unknown"
# Passthrough Override
if self.is_passthrough():
operating_system_type = "Guest (Passthrough)"
if string_format:
return f"{operating_system} {operating_system_type}"
return (operating_system, operating_system_type)
def get_amdsmi_init_flag(self):
return AMDSMI_INIT_FLAG
@@ -187,11 +187,19 @@ class AMDSMIParser(argparse.ArgumentParser):
valid_clk_types = ('sclk', 'mclk')
valid_lim_types = ('min', 'max')
clk_type, lim_type, val = values
# Check if the sclk and mclk parameters are valid
if clk_type not in valid_clk_types:
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(clk_type, output_format)
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(clk_type, output_format)
if lim_type not in valid_lim_types:
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(lim_type, output_format)
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterException(lim_type, output_format)
# Check if the val is a valid integer value
if not val.isdigit():
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(val, output_format)
val = int(val)
if val < 0:
raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(val, output_format)
clk_limit_args = collections.namedtuple('clk_limit_args', ['clk_type', 'lim_type', 'val'])
setattr(namespace, self.dest, clk_limit_args(clk_type, lim_type, val))
return AMDSMILimitArgs
@@ -567,8 +575,8 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text
list_help = "List GPU information"
list_subcommand_help = "Lists all detected devices on the system\
\nLists the BDF, UUID, KFD_ID, and NODE_ID for each GPU and/or CPUs\
list_subcommand_help = "Lists all detected devices on the system.\
\nLists the BDF, UUID, KFD_ID, and NODE_ID for each GPU and/or CPUs.\
\nIn virtualization environments, it can also list VFs associated to each\
\nGPU with some basic information for each VF."
@@ -635,10 +643,10 @@ class AMDSMIParser(argparse.ArgumentParser):
static_parser.add_argument('-c', '--cache', action='store_true', required=False, help=cache_help)
static_parser.add_argument('-B', '--board', action='store_true', required=False, help=board_help)
static_parser.add_argument('-R', '--process-isolation', action='store_true', required=False, help=process_isolation_help)
static_parser.add_argument('-r', '--ras', action='store_true', required=False, help=ras_help)
# Options to display on Hypervisors and Baremetal
if self.helpers.is_hypervisor() or self.helpers.is_baremetal():
static_parser.add_argument('-r', '--ras', action='store_true', required=False, help=ras_help)
static_parser.add_argument('-p', '--partition', action='store_true', required=False, help=partition_help)
static_parser.add_argument('-l', '--limit', action='store_true', required=False, help=limit_help)
static_parser.add_argument('-P', '--soc-pstate', action='store_true', required=False, help=soc_pstate_help)
@@ -735,7 +743,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text
metric_help = "Gets metric/performance information about the specified GPU"
metric_subcommand_help = "If no GPU is specified, returns metric information for all GPUs on the system.\
\nIf no metric argument is provided all metric information will be displayed."
\nIf no metric argument is provided, all metric information will be displayed."
metric_optionals_title = "Metric arguments"
# Optional arguments help text
@@ -820,11 +828,12 @@ class AMDSMIParser(argparse.ArgumentParser):
metric_parser.add_argument('-c', '--clock', action='store_true', required=False, help=clock_help)
metric_parser.add_argument('-t', '--temperature', action='store_true', required=False, help=temperature_help)
metric_parser.add_argument('-P', '--pcie', action='store_true', required=False, help=pcie_help)
metric_parser.add_argument('-e', '--ecc', action='store_true', required=False, help=ecc_help)
metric_parser.add_argument('-k', '--ecc-blocks', action='store_true', required=False, help=ecc_blocks_help)
# Options that only apply to Hypervisors and Baremetal Linux
if self.helpers.is_hypervisor() or (self.helpers.is_baremetal() and self.helpers.is_linux()):
metric_parser.add_argument('-e', '--ecc', action='store_true', required=False, help=ecc_help)
metric_parser.add_argument('-k', '--ecc-blocks', action='store_true', required=False, help=ecc_blocks_help)
pass
# Optional Args for Linux Baremetal Systems
if self.helpers.is_baremetal() and self.helpers.is_linux():
@@ -895,7 +904,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text
process_help = "Lists general process information running on the specified GPU"
process_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\
\nIf no process argument is provided all process information will be displayed."
\nIf no process argument is provided, all process information will be displayed."
process_optionals_title = "Process arguments"
# Optional Arguments help text
@@ -903,7 +912,7 @@ class AMDSMIParser(argparse.ArgumentParser):
engine_help = "All engine usages"
pid_help = "Gets all process information about the specified process based on Process ID"
name_help = "Gets all process information about the specified process based on Process Name.\
\nIf multiple processes have the same name information is returned for all of them."
\nIf multiple processes have the same name, information is returned for all of them."
# Create process subparser
@@ -980,7 +989,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text
topology_help = "Displays topology information of the devices"
topology_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\
\nIf no topology argument is provided all topology information will be displayed."
\nIf no topology argument is provided, all topology information will be displayed."
topology_optionals_title = "Topology arguments"
# Help text for Arguments only on Guest and BM platforms
@@ -1031,7 +1040,7 @@ class AMDSMIParser(argparse.ArgumentParser):
set_fan_help = "Set GPU fan speed (0-255 or 0-100%%)"
set_perf_level_help = "Set performance level"
set_profile_help = "Set power profile level (#) or a quoted string of custom profile attributes"
set_perf_det_help = "Set GPU clock frequency limit and performance level to determinism to get minimal performance variation"
set_perf_det_help = "Set GPU clock frequency limit and performance level to determinism\n to get minimal performance variation"
compute_partition_choices_str = ", ".join(self.helpers.get_compute_partition_types())
memory_partition_choices_str = ", ".join(self.helpers.get_memory_partition_types())
set_compute_partition_help = f"Set one of the following the compute partition modes:\n\t{compute_partition_choices_str}"
@@ -1039,8 +1048,8 @@ class AMDSMIParser(argparse.ArgumentParser):
set_power_cap_help = "Set power capacity limit"
set_soc_pstate_help = "Set the GPU soc pstate policy using policy id\n"
set_xgmi_plpd_help = "Set the GPU XGMI per-link power down policy using policy id\n"
set_clk_limit_help = "Sets the sclk (aka gfxclk) or mclk minimum and maximum frequencies. \nOf form: amd-smi set -L (sclk | mclk) (min | max) value"
set_process_isolation_help = "Enable or disable the GPU process isolation on a per partition basis: 0 for disable and 1 for enable.\n"
set_clk_limit_help = "Sets the sclk (aka gfxclk) or mclk minimum and maximum frequencies:\n\tamd-smi set -L (sclk | mclk) (min | max) value"
set_process_isolation_help = "Enable or disable the GPU process isolation on a per partition basis:\n\t0 for disable and 1 for enable.\n"
# Help text for CPU set options
set_cpu_pwr_limit_help = "Set power limit for the given socket. Input parameter is power limit value."
@@ -1169,7 +1178,7 @@ class AMDSMIParser(argparse.ArgumentParser):
monitor_help = "Monitor metrics for target devices"
monitor_subcommand_help = "Monitor a target device for the specified arguments.\
\nIf no arguments are provided, all arguments will be enabled.\
\nUse the watch arguments to run continuously"
\nUse the watch arguments to run continuously."
monitor_optionals_title = "Monitor Arguments"
# Help text for Arguments only on Guest and BM platforms
@@ -1203,10 +1212,7 @@ class AMDSMIParser(argparse.ArgumentParser):
monitor_parser.add_argument('-m', '--mem', action='store_true', required=False, help=mem_util_help)
monitor_parser.add_argument('-n', '--encoder', action='store_true', required=False, help=encoder_util_help)
monitor_parser.add_argument('-d', '--decoder', action='store_true', required=False, help=decoder_util_help)
if not self.helpers.is_virtual_os():
monitor_parser.add_argument('-e', '--ecc', action='store_true', required=False, help=ecc_help)
monitor_parser.add_argument('-e', '--ecc', action='store_true', required=False, help=ecc_help)
monitor_parser.add_argument('-v', '--vram-usage', action='store_true', required=False, help=mem_usage_help)
monitor_parser.add_argument('-r', '--pcie', action='store_true', required=False, help=pcie_bandwidth_help)
monitor_parser.add_argument('-q', '--process', action='store_true', required=False, help=process_help)
@@ -1266,7 +1272,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text
xgmi_help = "Displays xgmi information of the devices"
xgmi_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\
\nIf no xgmi argument is provided all xgmi information will be displayed."
\nIf no xgmi argument is provided, all xgmi information will be displayed."
xgmi_optionals_title = "XGMI arguments"
# Help text for Arguments only on Guest and BM platforms
@@ -1294,7 +1300,7 @@ class AMDSMIParser(argparse.ArgumentParser):
# Subparser help text
partition_help = "Displays partition information of the devices"
partition_subcommand_help = "If no GPU is specified, returns information for all GPUs on the system.\
\nIf no partition argument is provided all partition information will be displayed."
\nIf no partition argument is provided, all partition information will be displayed."
partition_optionals_title = "partition arguments"
# Options help text
@@ -1,2 +0,0 @@
```{include} ../CHANGELOG.md
```
@@ -1,2 +0,0 @@
```{include} ../amdsmi_cli/README.md
```
@@ -1,2 +0,0 @@
```{include} ../amdsmi_cli/Release_Notes.md
```
@@ -1 +0,0 @@
test
+48 -20
مشاهده پرونده
@@ -4,29 +4,57 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import subprocess
import re
import shutil
from rocm_docs import ROCmDocs
# get version number to print in docs
def get_version_info(filepath):
with open(filepath, 'r') as f:
content = f.read()
get_version_year = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_YEAR\ //p" ../include/amd_smi/amdsmi.h'
get_version_major = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_MAJOR\ //p" ../include/amd_smi/amdsmi.h'
get_version_minor = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_MINOR\ //p" ../include/amd_smi/amdsmi.h'
get_version_release = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_RELEASE\ //p" ../include/amd_smi/amdsmi.h'
version_year = subprocess.getoutput(get_version_year)
version_major = subprocess.getoutput(get_version_major)
version_minor = subprocess.getoutput(get_version_minor)
version_release = subprocess.getoutput(get_version_release)
name = f"AMD SMI {version_year}.{version_major}.{version_minor}.{version_release}"
version_pattern = (
r'^#define\s+AMDSMI_LIB_VERSION_YEAR\s+(\d+)\s*$|'
r'^#define\s+AMDSMI_LIB_VERSION_MAJOR\s+(\d+)\s*$|'
r'^#define\s+AMDSMI_LIB_VERSION_MINOR\s+(\d+)\s*$|'
r'^#define\s+AMDSMI_LIB_VERSION_RELEASE\s+(\d+)\s*$'
)
matches = re.findall(version_pattern, content, re.MULTILINE)
if len(matches) == 4:
version_year, version_major, version_minor, version_release = [
match for match in matches if any(match)
]
return version_year[0], version_major[1], version_minor[2], version_release[3]
else:
raise ValueError("Couldn't find all VERSION numbers.")
# copy changelog to docs/
shutil.copy2("../CHANGELOG.md", "./reference/changelog.md")
version_year, version_major, version_minor, version_release = get_version_info('../include/amd_smi/amdsmi.h')
version_number = f"{version_year}.{version_major}.{version_minor}.{version_release}"
# project info
project = "AMD SMI"
author = "Advanced Micro Devices, Inc."
copyright = "Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved."
version = version_number
release = version_number
html_theme = "rocm_docs_theme"
html_theme_options = {"flavor": "rocm"}
html_title = f"AMD SMI {version_number} documentation"
exclude_patterns = ["rocm-smi-lib"]
suppress_warnings = ["etoc.toctree"]
external_toc_path = "./sphinx/_toc.yml"
docs_core = ROCmDocs(f"{name} Documentation")
docs_core.run_doxygen(doxygen_root="doxygen", doxygen_path="doxygen/docBin/xml")
docs_core.enable_api_reference()
docs_core.setup()
docs_core.html_theme_options = {
"repository_url": "https://github.com/RadeonOpenCompute/amdsmi"
}
external_projects_current_project = "amdsmi"
extensions = ["rocm_docs", "rocm_docs.doxygen"]
for sphinx_var in ROCmDocs.SPHINX_VARS:
globals()[sphinx_var] = getattr(docs_core, sphinx_var)
doxygen_root = "doxygen"
doxysphinx_enabled = True
doxygen_project = {
"name": "AMD SMI C++ API reference",
"path": "doxygen/docBin/xml",
}
@@ -48,7 +48,7 @@ PROJECT_NAME = AMD SMI
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "24.7.0.0"
PROJECT_NUMBER = "24.7.1.0"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -1,14 +1,41 @@
# Using AMD SMI Command Line Interface tool
---
myst:
html_meta:
"description lang=en": "Learn how to use the AMD SMI command line tool."
"keywords": "api, smi, lib, system, management, interface, example"
---
**Disclaimer: CLI Tool is provided as an example code to aid the development of telemetry tools. Python or C++ Library is recommended as a reliable data source.**
# AMD SMI CLI tool usage
AMD-SMI reports the version and current platform detected when running the command line interface (CLI) without arguments:
This tool is a command line interface (CLI) for manipulating and monitoring the
`amdgpu` kernel; it is intended to replace and deprecate the existing `rocm_smi`
CLI tool and `gpuv-smi` tool. The AMD SMI CLI tool uses Ctypes to call the
`amd_smi_lib` API.
``` bash
When using the CLI tool, you should have at least one AMD GPU and the driver
installed.
```{admonition} Disclaimer
The AMD SMI CLI tool is provided as an example code to aid the development of
telemetry tools. The [Python](./amdsmi-py-lib) or [C++
library](./amdsmi-cpp-lib) is recommended as a robust data source.
```
## Install the CLI Tool and Python library
Refer to the [installation instructions](../install/install.md).
## Get started
The amd-smi command provides system management and monitoring capabilities for
AMD hardware. When run without arguments, it reports the version and platform
detected:
```shell-session
~$ amd-smi
usage: amd-smi [-h] ...
AMD System Management Interface | Version: 24.7.0.0 | ROCm version: 6.2.2 | Platform: Linux Baremetal
AMD System Management Interface | Version: 24.7.1.0 | ROCm version: 6.3.0 | Platform: Linux Baremetal
options:
-h, --help show this help message and exit
@@ -26,35 +53,44 @@ AMD-SMI Commands:
topology Displays topology information of the devices
set Set options for devices
reset Reset options for devices
monitor Monitor metrics for target devices
monitor (dmon) Monitor metrics for target devices
xgmi Displays xgmi information of the devices
```
Example commands:
``` bash
```shell-session
amd-smi static --gpu 0
amd-smi metric
amd-smi process --gpu 0 1
amd-smi reset --gpureset --gpu all
```
More detailed verison information is available from `amd-smi version`
```{note}
For command-specific help, use `amd-smi [command] --help` for see more detailed
usage information. See [Commands](#cmds).
Each command will have detailed information via `amd-smi [command] --help`
For more detailed version information, use `amd-smi version`.
```
(cmds)=
## Commands
For convenience, here is the help output for each command
The following are the help output for each command, providing quick reference
details for usage.
```bash
(cmd-list)=
### amd-smi list
Lists GPU information.
```shell-session
~$ amd-smi list --help
usage: amd-smi list [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]]
Lists all the devices on the system and the links between devices.
Lists all the sockets and for each socket, GPUs and/or CPUs associated to
that socket alongside some basic information for each device.
Lists the BDF, UUID, KFD_ID, and NODE_ID for each GPU and/or CPUs.
In virtualization environments, it can also list VFs associated to each
GPU with some basic information for each VF.
@@ -84,7 +120,13 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-static)=
### amd-smi static
Gets static information about the specified GPU. See the [sample
output](#cli-ex-static) for `amd-smi static`.
```shell-session
~$ amd-smi static --help
usage: amd-smi static [-h] [-g GPU [GPU ...] | -U CPU [CPU ...]] [-a] [-b] [-V] [-d] [-v]
[-c] [-B] [-R] [-r] [-p] [-l] [-P] [-x] [-u] [-s] [-i]
@@ -134,7 +176,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-firmware)=
### amd-smi firmware
Gets firmware information about the specified GPU.
```shell-session
~$ amd-smi firmware --help
usage: amd-smi firmware [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-f]
@@ -168,7 +215,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-bad-pages)=
### amd-smi bad-pages
Gets bad page information about the specified GPU.
```shell-session
~$ amd-smi bad-pages --help
usage: amd-smi bad-pages [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-p]
@@ -205,7 +257,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-metric)=
### amd-smi metric
Gets metrics and performance information about the specified GPU.
```shell-session
~$ amd-smi metric --help
usage: amd-smi metric [-h] [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]]
[-w INTERVAL] [-W TIME] [-i ITERATIONS] [-m] [-u] [-p] [-c] [-t]
@@ -222,7 +279,7 @@ usage: amd-smi metric [-h] [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE
[--json | --csv] [--file FILE] [--loglevel LEVEL]
If no GPU is specified, returns metric information for all GPUs on the system.
If no metric argument is provided all metric information will be displayed.
If no metric argument is provided, all metric information will be displayed.
Metric arguments:
-h, --help show this help message and exit
@@ -258,6 +315,7 @@ Metric arguments:
-l, --perf-level Current DPM performance level
-x, --xgmi-err XGMI error information since last read
-E, --energy Amount of energy consumed
-T, --throttle Displays throttle accumulators; Only available for MI300 or newer ASICs
CPU Arguments:
--cpu-power-metrics CPU power metrics
@@ -295,7 +353,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-process)=
### amd-smi process
Lists general process information running on the specified GPU.
```shell-session
~$ amd-smi process --help
usage: amd-smi process [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]]
@@ -303,7 +366,7 @@ usage: amd-smi process [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-n NAME]
If no GPU is specified, returns information for all GPUs on the system.
If no process argument is provided all process information will be displayed.
If no process argument is provided, all process information will be displayed.
Process arguments:
-h, --help show this help message and exit
@@ -329,7 +392,7 @@ Process arguments:
-e, --engine All engine usages
-p, --pid PID Gets all process information about the specified process based on Process ID
-n, --name NAME Gets all process information about the specified process based on Process Name.
If multiple processes have the same name information is returned for all of them.
If multiple processes have the same name, information is returned for all of them.
Command Modifiers:
--json Displays output in JSON format (human readable by default).
@@ -339,7 +402,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-event)=
### amd-smi event
Displays event information for the given GPU.
```shell-session
~$ amd-smi event --help
usage: amd-smi event [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]]
@@ -372,14 +440,19 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-topology)=
### amd-smi topology
Displays topology information of the specified devices.
```shell-session
~$ amd-smi topology --help
usage: amd-smi topology [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-a]
[-w] [-o] [-t] [-b]
If no GPU is specified, returns information for all GPUs on the system.
If no topology argument is provided all topology information will be displayed.
If no topology argument is provided, all topology information will be displayed.
Topology arguments:
-h, --help show this help message and exit
@@ -403,6 +476,10 @@ Topology arguments:
-o, --hops Displays the number of hops between GPUs
-t, --link-type Displays the link type between GPUs
-b, --numa-bw Display max and min bandwidth between nodes
-c, --coherent Display cache coherant (or non-coherant) link capability between nodes
-n, --atomics Display 32 and 64-bit atomic io link capability between nodes
-d, --dma Display P2P direct memory access (DMA) link capability between nodes
-z, --bi-dir Display P2P bi-directional link capability between nodes
Command Modifiers:
--json Displays output in JSON format (human readable by default).
@@ -412,7 +489,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-set)=
### amd-smi set
Set options for specified devices.
```shell-session
~$ amd-smi set --help
usage: amd-smi set [-h] (-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]) [-f %]
[-l LEVEL] [-P SETPROFILE] [-d SCLKMAX] [-C PARTITION] [-M PARTITION]
@@ -426,7 +508,7 @@ usage: amd-smi set [-h] (-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...
[--loglevel LEVEL]
A GPU must be specified to set a configuration.
A set argument must be provided; Multiple set arguments are accepted
A set argument must be provided; Multiple set arguments are accepted.
Set Arguments:
-h, --help show this help message and exit
@@ -454,9 +536,12 @@ Set Arguments:
-M, --memory-partition PARTITION Set one of the following the memory partition modes:
NPS1, NPS2, NPS4, NPS8
-o, --power-cap WATTS Set power capacity limit
-p, --dpm-policy POLICY_ID Set the GPU DPM policy using policy id
-p, --soc-pstate POLICY_ID Set the GPU soc pstate policy using policy id
-x, --xgmi-plpd POLICY_ID Set the GPU XGMI per-link power down policy using policy id
-R, --process-isolation STATUS Enable or disable the GPU process isolation: 0 for disable and 1 for enable.
-L, --clk-limit CLK_TYPE LIM_TYPE VALUE Sets the sclk (aka gfxclk) or mclk minimum and maximum frequencies
amd-smi set -L (sclk | mclk) (min | max) value
-R, --process-isolation STATUS Enable or disable the GPU process isolation:
0 for disable and 1 for enable.
CPU Arguments:
--cpu-pwr-limit PWR_LIMIT Set power limit for the given socket. Input parameter is power limit value.
@@ -482,7 +567,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-reset)=
### amd-smi reset
Reset options for specified devices.
```shell-session
~$ amd-smi reset --help
usage: amd-smi reset [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
(-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]) [-G] [-c]
@@ -514,10 +604,8 @@ Reset Arguments:
-p, --profile Reset power profile back to default
-x, --xgmierr Reset XGMI error counts
-d, --perf-determinism Disable performance determinism
-C, --compute-partition Reset compute partitions on the specified GPU
-M, --memory-partition Reset memory partitions on the specified GPU
-o, --power-cap Reset power capacity limit to max capable
-l, --run-shader SHADER_NAME Run the shader on processor. Only CLEANER shader can be used to clean up data in LDS/GPRs
-l, --clean-local-data Clean up the local data in the LDS/GPRs on a per partition basis
Command Modifiers:
--json Displays output in JSON format (human readable by default).
@@ -527,7 +615,12 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-monitor)=
### amd-smi monitor
Monitor metrics for target devices.
```shell-session
~$ amd-smi monitor --help
usage: amd-smi monitor [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]]
@@ -536,7 +629,7 @@ usage: amd-smi monitor [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
Monitor a target device for the specified arguments.
If no arguments are provided, all arguments will be enabled.
Use the watch arguments to run continuously
Use the watch arguments to run continuously.
Monitor Arguments:
-h, --help show this help message and exit
@@ -568,6 +661,7 @@ Monitor Arguments:
-v, --vram-usage Monitor memory usage in MB
-r, --pcie Monitor PCIe bandwidth in Mb/s
-q, --process Enable Process information table below monitor output
-V, --violation Monitor power and thermal violation status (%); Only available for MI300 or newer ASICs
Command Modifiers:
--json Displays output in JSON format (human readable by default).
@@ -577,13 +671,18 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```bash
(cmd-xgmi)=
### amd-smi xgmi
Displays XGMI information of specified devices.
```shell-session
~$ amd-smi xgmi --help
usage: amd-smi xgmi [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
[-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-m]
If no GPU is specified, returns information for all GPUs on the system.
If no xgmi argument is provided all xgmi information will be displayed.
If no xgmi argument is provided, all xgmi information will be displayed.
XGMI arguments:
-h, --help show this help message and exit
@@ -612,9 +711,11 @@ Command Modifiers:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
(cli-ex-static)=
### Example output from amd-smi static
Here is some example output from the tool:
To gain a sense of the AMD SMI CLI's output, the following block is sample
output from the CLI tool:
```bash
~$ amd-smi static
@@ -623,25 +724,7 @@ CPU: 0
FW_VERSION: 85.90.0
INTERFACE_VERSION:
PROTO VERSION: 6
CPU: 1
SMU:
FW_VERSION: 85.90.0
INTERFACE_VERSION:
PROTO VERSION: 6
CPU: 2
SMU:
FW_VERSION: 85.90.0
INTERFACE_VERSION:
PROTO VERSION: 6
CPU: 3
SMU:
FW_VERSION: 85.90.0
INTERFACE_VERSION:
PROTO VERSION: 6
...
GPU: 0
ASIC:
@@ -650,9 +733,12 @@ GPU: 0
VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI]
SUBVENDOR_ID: 0x1002
DEVICE_ID: 0x74a0
SUBSYSTEM_ID: 0x74a0
REV_ID: 0x00
ASIC_SERIAL: 0x7E8F7E20764E2714
OAM_ID: 0
NUM_COMPUTE_UNITS: 228
TARGET_GRAPHICS_VERSION: gfx942
BUS:
BDF: 0000:01:00.0
MAX_PCIE_WIDTH: 16
@@ -712,6 +798,7 @@ GPU: 0
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
PARTITION_ID: 0
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
@@ -742,6 +829,7 @@ GPU: 0
TYPE: HBM
VENDOR: N/A
SIZE: 64289 MB
BIT_WIDTH: 8192
CACHE_INFO:
CACHE_0:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
@@ -767,380 +855,5 @@ GPU: 0
CACHE_LEVEL: 3
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
GPU: 1
ASIC:
MARKET_NAME: MI300A
VENDOR_ID: 0x1002
VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI]
SUBVENDOR_ID: 0x1002
DEVICE_ID: 0x74a0
REV_ID: 0x00
ASIC_SERIAL: 0xB6AE7C8CEFE1F084
OAM_ID: 1
BUS:
BDF: 0001:01:00.0
MAX_PCIE_WIDTH: 16
MAX_PCIE_SPEED: 32 GT/s
PCIE_INTERFACE_VERSION: Gen 5
SLOT_TYPE: PCIE
VBIOS:
NAME: N/A
BUILD_DATE: N/A
PART_NUMBER: N/A
VERSION: N/A
LIMIT:
MAX_POWER: 550 W
MIN_POWER: 0 W
SOCKET_POWER: 550 W
SLOWDOWN_EDGE_TEMPERATURE: N/A
SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C
SLOWDOWN_VRAM_TEMPERATURE: 105 °C
SHUTDOWN_EDGE_TEMPERATURE: N/A
SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C
SHUTDOWN_VRAM_TEMPERATURE: 115 °C
DRIVER:
NAME: amdgpu
VERSION: 6.9.0-rc5+
BOARD:
MODEL_NUMBER: N/A
PRODUCT_SERIAL: N/A
FRU_ID: N/A
PRODUCT_NAME: Aqua Vanjaram [Instinct MI300A]
MANUFACTURER_NAME: Advanced Micro Devices, Inc. [AMD/ATI]
RAS:
EEPROM_VERSION: 0x0
PARITY_SCHEMA: DISABLED
SINGLE_BIT_SCHEMA: DISABLED
DOUBLE_BIT_SCHEMA: DISABLED
POISON_SCHEMA: ENABLED
ECC_BLOCK_STATE:
UMC: DISABLED
SDMA: ENABLED
GFX: ENABLED
MMHUB: ENABLED
ATHUB: DISABLED
PCIE_BIF: DISABLED
HDP: DISABLED
XGMI_WAFL: DISABLED
DF: DISABLED
SMN: DISABLED
SEM: DISABLED
MP0: DISABLED
MP1: DISABLED
FUSE: DISABLED
MCA: DISABLED
VCN: DISABLED
JPEG: DISABLED
IH: DISABLED
MPIO: DISABLED
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 2
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
PROCESS_ISOLATION: N/A
NUMA:
NODE: 1
AFFINITY: 1
VRAM:
TYPE: HBM
VENDOR: N/A
SIZE: 64289 MB
CACHE_INFO:
CACHE_0:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 32 KB
CACHE_LEVEL: 1
MAX_NUM_CU_SHARED: 2
NUM_CACHE_INSTANCE: 348
CACHE_1:
CACHE_PROPERTIES: INST_CACHE, SIMD_CACHE
CACHE_SIZE: 64 KB
CACHE_LEVEL: 1
MAX_NUM_CU_SHARED: 2
NUM_CACHE_INSTANCE: 120
CACHE_2:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 4096 KB
CACHE_LEVEL: 2
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
CACHE_3:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 262144 KB
CACHE_LEVEL: 3
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
GPU: 2
ASIC:
MARKET_NAME: MI300A
VENDOR_ID: 0x1002
VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI]
SUBVENDOR_ID: 0x1002
DEVICE_ID: 0x74a0
REV_ID: 0x00
ASIC_SERIAL: 0x367125D815189854
OAM_ID: 2
BUS:
BDF: 0002:01:00.0
MAX_PCIE_WIDTH: 16
MAX_PCIE_SPEED: 32 GT/s
PCIE_INTERFACE_VERSION: Gen 5
SLOT_TYPE: PCIE
VBIOS:
NAME: N/A
BUILD_DATE: N/A
PART_NUMBER: N/A
VERSION: N/A
LIMIT:
MAX_POWER: 550 W
MIN_POWER: 0 W
SOCKET_POWER: 550 W
SLOWDOWN_EDGE_TEMPERATURE: N/A
SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C
SLOWDOWN_VRAM_TEMPERATURE: 105 °C
SHUTDOWN_EDGE_TEMPERATURE: N/A
SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C
SHUTDOWN_VRAM_TEMPERATURE: 115 °C
DRIVER:
NAME: amdgpu
VERSION: 6.9.0-rc5+
BOARD:
MODEL_NUMBER: N/A
PRODUCT_SERIAL: N/A
FRU_ID: N/A
PRODUCT_NAME: Aqua Vanjaram [Instinct MI300A]
MANUFACTURER_NAME: Advanced Micro Devices, Inc. [AMD/ATI]
RAS:
EEPROM_VERSION: 0x0
PARITY_SCHEMA: DISABLED
SINGLE_BIT_SCHEMA: DISABLED
DOUBLE_BIT_SCHEMA: DISABLED
POISON_SCHEMA: ENABLED
ECC_BLOCK_STATE:
UMC: DISABLED
SDMA: ENABLED
GFX: ENABLED
MMHUB: ENABLED
ATHUB: DISABLED
PCIE_BIF: DISABLED
HDP: DISABLED
XGMI_WAFL: DISABLED
DF: DISABLED
SMN: DISABLED
SEM: DISABLED
MP0: DISABLED
MP1: DISABLED
FUSE: DISABLED
MCA: DISABLED
VCN: DISABLED
JPEG: DISABLED
IH: DISABLED
MPIO: DISABLED
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 2
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
PROCESS_ISOLATION: N/A
NUMA:
NODE: 2
AFFINITY: 2
VRAM:
TYPE: HBM
VENDOR: N/A
SIZE: 64289 MB
CACHE_INFO:
CACHE_0:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 32 KB
CACHE_LEVEL: 1
MAX_NUM_CU_SHARED: 2
NUM_CACHE_INSTANCE: 348
CACHE_1:
CACHE_PROPERTIES: INST_CACHE, SIMD_CACHE
CACHE_SIZE: 64 KB
CACHE_LEVEL: 1
MAX_NUM_CU_SHARED: 2
NUM_CACHE_INSTANCE: 120
CACHE_2:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 4096 KB
CACHE_LEVEL: 2
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
CACHE_3:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 262144 KB
CACHE_LEVEL: 3
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
GPU: 3
ASIC:
MARKET_NAME: MI300A
VENDOR_ID: 0x1002
VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI]
SUBVENDOR_ID: 0x1002
DEVICE_ID: 0x74a0
REV_ID: 0x00
ASIC_SERIAL: 0xF4C44C2BE5E66537
OAM_ID: 3
BUS:
BDF: 0003:01:00.0
MAX_PCIE_WIDTH: 16
MAX_PCIE_SPEED: 32 GT/s
PCIE_INTERFACE_VERSION: Gen 5
SLOT_TYPE: PCIE
VBIOS:
NAME: N/A
BUILD_DATE: N/A
PART_NUMBER: N/A
VERSION: N/A
LIMIT:
MAX_POWER: 550 W
MIN_POWER: 0 W
SOCKET_POWER: 550 W
SLOWDOWN_EDGE_TEMPERATURE: N/A
SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C
SLOWDOWN_VRAM_TEMPERATURE: 105 °C
SHUTDOWN_EDGE_TEMPERATURE: N/A
SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C
SHUTDOWN_VRAM_TEMPERATURE: 115 °C
DRIVER:
NAME: amdgpu
VERSION: 6.9.0-rc5+
BOARD:
MODEL_NUMBER: N/A
PRODUCT_SERIAL: N/A
FRU_ID: N/A
PRODUCT_NAME: Aqua Vanjaram [Instinct MI300A]
MANUFACTURER_NAME: Advanced Micro Devices, Inc. [AMD/ATI]
RAS:
EEPROM_VERSION: 0x0
PARITY_SCHEMA: DISABLED
SINGLE_BIT_SCHEMA: DISABLED
DOUBLE_BIT_SCHEMA: DISABLED
POISON_SCHEMA: ENABLED
ECC_BLOCK_STATE:
UMC: DISABLED
SDMA: ENABLED
GFX: ENABLED
MMHUB: ENABLED
ATHUB: DISABLED
PCIE_BIF: DISABLED
HDP: DISABLED
XGMI_WAFL: DISABLED
DF: DISABLED
SMN: DISABLED
SEM: DISABLED
MP0: DISABLED
MP1: DISABLED
FUSE: DISABLED
MCA: DISABLED
VCN: DISABLED
JPEG: DISABLED
IH: DISABLED
MPIO: DISABLED
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 2
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
PROCESS_ISOLATION: N/A
NUMA:
NODE: 3
AFFINITY: 3
VRAM:
TYPE: HBM
VENDOR: N/A
SIZE: 64289 MB
CACHE_INFO:
CACHE_0:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 32 KB
CACHE_LEVEL: 1
MAX_NUM_CU_SHARED: 2
NUM_CACHE_INSTANCE: 348
CACHE_1:
CACHE_PROPERTIES: INST_CACHE, SIMD_CACHE
CACHE_SIZE: 64 KB
CACHE_LEVEL: 1
MAX_NUM_CU_SHARED: 2
NUM_CACHE_INSTANCE: 120
CACHE_2:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 4096 KB
CACHE_LEVEL: 2
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
CACHE_3:
CACHE_PROPERTIES: DATA_CACHE, SIMD_CACHE
CACHE_SIZE: 262144 KB
CACHE_LEVEL: 3
MAX_NUM_CU_SHARED: 228
NUM_CACHE_INSTANCE: 1
...
```
@@ -0,0 +1,198 @@
---
myst:
html_meta:
"description lang=en": "Get started with the AMD SMI C++ library. Basic usage and examples."
"keywords": "api, smi, lib, c++, system, management, interface, ROCm"
---
# AMD SMI C++ library usage and examples
This section presents a brief overview and some basic examples on the AMD SMI
library's usage. Whether you are developing applications for performance
monitoring, system diagnostics, or resource allocation, the AMD SMI C++ library
serves as a valuable tool for leveraging the full potential of AMD hardware in
your projects.
```{note}
``hipcc`` and other compilers will not automatically link in the ``libamd_smi``
dynamic library. To compile code that uses the AMD SMI library API, ensure the
``libamd_smi.so`` can be located by setting the ``LD_LIBRARY_PATH`` environment
variable to the directory containing ``librocm_smi64.so`` (usually
``/opt/rocm/lib``) or by passing the ``-lamd_smi`` flag to the compiler.
```
```{seealso}
Refer to the [C++ library API reference](../reference/amdsmi-cpp-api.md).
```
(device_socket_handle)=
## Device and socket handles
Many functions in the library take a _socket handle_ or _device handle_. A
_socket_ refers to a physical hardware socket, abstracted by the library to
represent the hardware more effectively to the user. While there is always one
unique GPU per socket, an APU may house both a GPU and CPU on the same socket.
For MI200 GPUs, multiple GCDs may reside within a single socket
To identify the sockets in a system, use the `amdsmi_get_socket_handles()`
function, which returns a list of socket handles. These handles can then be used
with `amdsmi_get_processor_handles()` to query devices within each socket. The
device handle is used to differentiate between detected devices; however, it's
important to note that a device handle may change after restarting the
application, so it should not be considered a persistent identifier across
processes.
The list of socket handles obtained from `amdsmi_get_socket_handles()` can
also be used to query the CPUs in each socket by calling
`amdsmi_get_processor_handles_by_type()`. This function can then be called again
to query the cores within each CPU.
(cpp_hello_amdsmi)=
## Hello AMD SMI
An application using AMD SMI must call `amdsmi_init()` to initialize the AMI SMI
library before all other calls. This call initializes the internal data
structures required for subsequent AMD SMI operations. In the call, a flag can
be passed to indicate if the application is interested in a specific device
type.
`amdsmi_shut_down()` must be the last call to properly close connection to
driver and make sure that any resources held by AMD SMI are released.
1. A simple "Hello World" type program that displays the temperature of detected
devices looks like this:
```cpp
#include <iostream>
#include <vector>
#include "amd_smi/amdsmi.h"
int main() {
amdsmi_status_t ret;
// Init amdsmi for sockets and devices. Here we are only interested in AMD_GPUS.
ret = amdsmi_init(AMDSMI_INIT_AMD_GPUS);
// Get all sockets
uint32_t socket_count = 0;
// Get the socket count available in the system.
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the socket handles in the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get identifier and devices
for (uint32_t i=0; i < socket_count; i++) {
// Get Socket info
char socket_info[128];
ret = amdsmi_get_socket_info(sockets[i], 128, socket_info);
std::cout << "Socket " << socket_info<< std::endl;
// Get the device count for the socket.
uint32_t device_count = 0;
ret = amdsmi_get_processor_handles(sockets[i], &device_count, nullptr);
// Allocate the memory for the device handlers on the socket
std::vector<amdsmi_processor_handle> processor_handles(device_count);
// Get all devices of the socket
ret = amdsmi_get_processor_handles(sockets[i],
&device_count, &processor_handles[0]);
// For each device of the socket, get name and temperature.
for (uint32_t j=0; j < device_count; j++) {
// Get device type. Since the amdsmi is initialized with
// AMD_SMI_INIT_AMD_GPUS, the processor_type must be AMDSMI_PROCESSOR_TYPE_AMD_GPU.
processor_type_t processor_type;
ret = amdsmi_get_processor_type(processor_handles[j], &processor_type);
if (processor_type != AMDSMI_PROCESSOR_TYPE_AMD_GPU) {
std::cout << "Expect AMDSMI_PROCESSOR_TYPE_AMD_GPU device type!\n";
return 1;
}
// Get device name
amdsmi_board_info_t board_info;
ret = amdsmi_get_gpu_board_info(processor_handles[j], &board_info);
std::cout << "\tdevice "
<< j <<"\n\t\tName:" << board_info.product_name << std::endl;
// Get temperature
int64_t val_i64 = 0;
ret = amdsmi_get_temp_metric(processor_handles[j], AMDSMI_TEMPERATURE_TYPE_EDGE,
AMDSMI_TEMP_CURRENT, &val_i64);
std::cout << "\t\tTemperature: " << val_i64 << "C" << std::endl;
}
}
// Clean up resources allocated at amdsmi_init. It will invalidate sockets
// and devices pointers
ret = amdsmi_shut_down();
return 0;
}
```
2. A sample program that displays the power of detected CPUs looks like this:
```cpp
#include <iostream>
#include <vector>
#include "amd_smi/amdsmi.h"
int main(int argc, char **argv) {
amdsmi_status_t ret;
uint32_t socket_count = 0;
// Initialize amdsmi for AMD CPUs
ret = amdsmi_init(AMDSMI_INIT_AMD_CPUS);
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the sockets of the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get cpus
for (uint32_t i = 0; i < socket_count; i++) {
uint32_t cpu_count = 0;
// Set processor type as AMDSMI_PROCESSOR_TYPE_AMD_CPU
processor_type_t processor_type = AMDSMI_PROCESSOR_TYPE_AMD_CPU;
ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, nullptr, &cpu_count);
// Allocate the memory for the cpus
std::vector<amdsmi_processor_handle> plist(cpu_count);
// Get the cpus for each socket
ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, &plist[0], &cpu_count);
for (uint32_t index = 0; index < plist.size(); index++) {
uint32_t socket_power;
std::cout<<"CPU "<<index<<"\t"<< std::endl;
std::cout<<"Power (Watts): ";
ret = amdsmi_get_cpu_socket_power(plist[index], &socket_power);
if(ret != AMDSMI_STATUS_SUCCESS)
std::cout<<"Failed to get cpu socket power"<<"["<<index<<"] , Err["<<ret<<"] "<< std::endl;
if (!ret) {
std::cout<<static_cast<double>(socket_power)/1000<<std::endl;
}
std::cout<<std::endl;
}
}
// Clean up resources allocated at amdsmi_init
ret = amdsmi_shut_down();
return 0;
}
```
@@ -0,0 +1,105 @@
---
myst:
html_meta:
"description lang=en": "Get started with the AMD SMI Python interface."
"keywords": "api, smi, lib, py, system, management, interface, ROCm"
---
# AMD SMI Python interface overview
The AMD SMI Python interface provides a convenient way to interact with AMD
hardware through a simple and accessible [API](../reference/amdsmi-py-api.md).
Compatible with Python 3.6 and higher, this library requires the AMD driver to
be loaded for initialization -- review the [prerequisites](#install_reqs).
## Get started
To get started, the `amdsmi` folder should be copied and placed next to
the importing script. Import it as follows:
```python
from amdsmi import *
try:
amdsmi_init()
# amdsmi calls ...
except AmdSmiException as e:
print(e)
finally:
try:
amdsmi_shut_down()
except AmdSmiException as e:
print(e)
```
(py_lib_fs)=
### Folder structure
File name | Description
----------------------|-------------------------------------------------
`__init__.py` | Python package initialization file
`amdsmi_interface.py` | Amdsmi library Python interface
`amdsmi_wrapper.py` | Python wrapper around amdsmi binary
`amdsmi_exception.py` | Amdsmi [exceptions](#py_exceptions) Python file
(py_usage)=
## Usage
```{note}
``hipcc`` and other compilers will not automatically link in the ``libamd_smi``
dynamic library. To compile code that uses the AMD SMI library API, ensure the
``libamd_smi.so`` can be located by setting the ``LD_LIBRARY_PATH`` environment
variable to the directory containing ``librocm_smi64.so`` (usually
``/opt/rocm/lib``) or by passing the ``-lamd_smi`` flag to the compiler.
```
```{seealso}
Refer to the [Python library API reference](../reference/amdsmi-py-api.md).
```
An application using AMD SMI must call `amdsmi_init()` to initialize the AMI SMI
library before all other calls. This call initializes the internal data
structures required for subsequent AMD SMI operations. In the call, a flag can
be passed to indicate if the application is interested in a specific device
type.
`amdsmi_shut_down()` must be the last call to properly close connection to
driver and make sure that any resources held by AMD SMI are released.
(py_exceptions)=
## Exceptions
All exceptions are in `amdsmi_exception.py` file.
Exceptions that can be thrown by AMD SMI are:
* `AmdSmiException`: base amdsmi exception class
* `AmdSmiLibraryException`: derives base `AmdSmiException` class and represents errors that can occur in amdsmi-lib.
When this exception is thrown, `err_code` and `err_info` are set. `err_code` is an integer that corresponds to errors that can occur
in amdsmi-lib and `err_info` is a string that explains the error that occurred.
For example:
```python
try:
num_of_GPUs = len(amdsmi_get_processor_handles())
if num_of_GPUs == 0:
print("No GPUs on machine")
except AmdSmiException as e:
print("Error code: {}".format(e.err_code))
if e.err_code == amdsmi_wrapper.AMDSMI_STATUS_RETRY:
print("Error info: {}".format(e.err_info))
```
* `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.
@@ -1,254 +0,0 @@
.. meta::
:description: Using AMD SMI
:keywords: AMD, SMI, system, management, interface, ROCm
********************************
Usage Basics for the C Library
********************************
Device/Socket handles
----------------------
Many of the AMD SMI library's functions take a "socket handle" or "device handle." The socket is an abstraction of the hardware's physical socket. This will enable AMD SMI to provide a better representation of the hardware to the user. Although there is always one distinct GPU for a socket, the APU may have both GPU and CPU devices on the same socket. Moreover, for the MI200 series, it may have multiple GCDs.
To discover the sockets in the system, `amdsmi_get_socket_handles()` is called to get a list of socket handles, which, in turn, can be used to query the devices in that socket using `amdsmi_get_processor_handles().` The device handler is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different device handle after restarting the application, so a device handle should not be relied upon to be constant over the process.
The list of socket handles discovered using `amdsmi_get_socket_handles()`, can also be used to query the CPUs in that socket using amdsmi_get_processor_handles_by_type(), which in turn can then be used to query the cores in that CPU using amdsmi_get_processor_handles_by_type() again.
Hello AMD SMI
--------------
The only required AMD SMI call for any program that wants to use AMD SMI is the `amdsmi_init()` call. This call initializes some internal data structures that subsequent AMD-SMI calls will use. A flag can be passed in the call if the application is only interested in a specific device type.
When AMD SMI is no longer used, `amdsmi_shut_down()` should be called. This provides a way to release resources that AMD-SMI may have held.
1) A simple "Hello World" type program that displays the temperature of detected devices would look like this:
.. code-block::
#include <iostream>
#include <vector>
#include "amd_smi/amdsmi.h"
int main() {
amdsmi_status_t ret;
// Init amdsmi for sockets and devices. Here we are only interested in AMD_GPUS.
ret = amdsmi_init(AMDSMI_INIT_AMD_GPUS);
// Get all sockets
uint32_t socket_count = 0;
// Get the socket count available in the system.
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the socket handles in the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get identifier and devices
for (uint32_t i=0; i < socket_count; i++) {
// Get Socket info
char socket_info[128];
ret = amdsmi_get_socket_info(sockets[i], 128, socket_info);
std::cout << "Socket " << socket_info<< std::endl;
// Get the device count for the socket.
uint32_t device_count = 0;
ret = amdsmi_get_processor_handles(sockets[i], &device_count, nullptr);
// Allocate the memory for the device handlers on the socket
std::vector<amdsmi_processor_handle> processor_handles(device_count);
// Get all devices of the socket
ret = amdsmi_get_processor_handles(sockets[i],
&device_count, &processor_handles[0]);
// For each device of the socket, get name and temperature.
for (uint32_t j=0; j < device_count; j++) {
// Get device type. Since the amdsmi is initialized with
// AMD_SMI_INIT_AMD_GPUS, the processor_type must be AMD_GPU.
processor_type_t processor_type;
ret = amdsmi_get_processor_type(processor_handles[j], &processor_type);
if (processor_type != AMD_GPU) {
std::cout << "Expect AMD_GPU device type!\n";
return 1;
}
// Get device name
amdsmi_board_info_t board_info;
ret = amdsmi_get_gpu_board_info(processor_handles[j], &board_info);
std::cout << "\tdevice "
<< j <<"\n\t\tName:" << board_info.product_name << std::endl;
// Get temperature
int64_t val_i64 = 0;
ret = amdsmi_get_temp_metric(processor_handles[j], AMDSMI_TEMPERATURE_TYPE_EDGE,
AMDSMI_TEMP_CURRENT, &val_i64);
std::cout << "\t\tTemperature: " << val_i64 << "C" << std::endl;
}
}
// Clean up resources allocated at amdsmi_init. It will invalidate sockets
// and devices pointers
ret = amdsmi_shut_down();
return 0;
}
2) A sample program that displays the power of detected cpus would look like this:
.. code-block::
#include <iostream>
#include <vector>
#include "amd_smi/amdsmi.h"
int main(int argc, char **argv) {
amdsmi_status_t ret;
uint32_t socket_count = 0;
// Initialize amdsmi for AMD CPUs
ret = amdsmi_init(AMDSMI_INIT_AMD_CPUS);
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the sockets of the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get cpus
for (uint32_t i = 0; i < socket_count; i++) {
uint32_t cpu_count = 0;
// Set processor type as AMD_CPU
processor_type_t processor_type = AMD_CPU;
ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, nullptr, &cpu_count);
// Allocate the memory for the cpus
std::vector<amdsmi_processor_handle> plist(cpu_count);
// Get the cpus for each socket
ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, &plist[0], &cpu_count);
for (uint32_t index = 0; index < plist.size(); index++) {
uint32_t socket_power;
std::cout<<"CPU "<<index<<"\t"<< std::endl;
std::cout<<"Power (Watts): ";
ret = amdsmi_get_cpu_socket_power(plist[index], &socket_power);
if(ret != AMDSMI_STATUS_SUCCESS)
std::cout<<"Failed to get cpu socket power"<<"["<<index<<"] , Err["<<ret<<"] "<< std::endl;
if (!ret) {
std::cout<<static_cast<double>(socket_power)/1000<<std::endl;
}
std::cout<<std::endl;
}
}
// Clean up resources allocated at amdsmi_init
ret = amdsmi_shut_down();
return 0;
}
Building AMD SMI
-----------------
Rebuilding Python wrapper
==========================
Python wrapper (binding) is an auto-generated file `py-interface/amdsmi_wrapper.py`
The wrapper should be re-generated on each C++ API change by doing the following:
.. code-block:: bash
./update_wrapper.sh
After this command, the file in `py-interface/amdsmi_wrapper.py` will be automatically updated on each compile.
Note: To re-generate the Python wrapper, you must have **Docker** installed.
Note: Python_wrapper is NOT automatically re-generated. You must run `./update_wrapper.sh`.
Additional software required for building AMD SMI
--------------------------------------------------
The following components are required to build the library.
.. Note:: The software versions listed are what was used in development. Earlier versions are not guaranteed to work.
* CMake (v3.14.0) - `python3 -m pip install cmake`
* g++ (5.4.0)
The following components are required to build the AMD SMI Python package:
* Python (3.6.8 or above)
* virtualenv - `python3 -m pip install virtualenv`
The following tools are required to build the latest documentation:
* Doxygen (1.8.11)
* Latex (pdfTeX 3.14159265-2.6-1.40.16)
The source code for AMD SMI is available on Github.
After the AMD SMI library git repository is cloned to a local Linux machine, the default location for the library and headers is /opt/rocm.
.. Note:: Before installation, the old ROCm directories must be deleted:
* /opt/rocm
* /opt/rocm-{number}
Building the library is achieved by following the typical CMake build sequence (run as root user or use 'sudo' before the 'make install' command), specifically:
.. code-block:: bash
mkdir -p build
cd build
cmake ..
make -j $(nproc)
make install
The built library will appear in the `build` folder.
In addition to the preceding steps, use the following instructions to build the rpm and deb packages:
.. code-block:: bash
make package
Building tests
-------------------
To verify the build and capability of AMD SMI on your system and see an example of how AMD SMI can be used, you may build and run the tests available in the repo. To build the tests, follow these steps:
.. code-block:: bash
mkdir -p build
cd build
cmake -DBUILD_TESTS=ON ..
make -j $(nproc)
Running tests
--------------
Execute the program `amdsmitst` that is built from the steps above to run the test.
Path to the program `amdsmitst`: `build/tests/amd_smi_test/`
@@ -0,0 +1,82 @@
---
myst:
html_meta:
"description lang=en": "AMD SMI documentation and API reference."
"keywords": "amdsmi, lib, cli, system, management, interface, amdgpu, admin, sys"
---
# AMD SMI documentation
The AMD System Management Interface (AMD SMI) library offers a unified tool for
managing and monitoring GPUs, particularly in high-performance computing
environments. It provides a user-space interface that allows applications to
control GPU operations, monitor performance, and retrieve information about the
system's drivers and GPUs.
Find the source code at <https://github.com/ROCm/amdsmi>.
```{note}
AMD SMI is the successor to <https://github.com/ROCm/rocm_smi_lib>.
```
::::{grid} 2
:gutter: 3
:::{grid-item-card} Install
* [Library and CLI tool installation](./install/install.md)
* [Build from source](./install/build.md)
:::
:::{grid-item-card} How to
* [C++ library usage](./how-to/amdsmi-cpp-lib.md)
* [Python library usage](./how-to/amdsmi-py-lib.md)
* [CLI tool usage](./how-to/amdsmi-cli-tool.md)
:::
:::{grid-item-card} Reference
* [C++ API](./reference/amdsmi-cpp-api.md)
* [Modules](../doxygen/docBin/html/modules)
* [Files](../doxygen/docBin/html/files)
* [Globals](../doxygen/docBin/html/globals)
* [Data structures](../doxygen/docBin/html/annotated)
* [Data fields](../doxygen/docBin/html/functions_data_fields)
* [Python API](./reference/amdsmi-py-api.md)
:::
:::{grid-item-card} Tutorials
* [AMD SMI examples (GitHub)](https://github.com/ROCm/amdsmi/tree/amd-staging/example)
* [ROCm SMI examples (GitHub)](https://github.com/ROCm/rocm_smi_lib/tree/amd-staging/example)
:::
::::
To contribute to the documentation, refer to
{doc}`Contributing to ROCm <rocm:contribute/contributing>`.
Find ROCm licensing information on the
{doc}`Licensing <rocm:about/license>` page.
<style>
#disclaimer {
font-size: 0.8rem;
}
</style>
<div id="disclaimer">
The information contained herein is for informational purposes only, and is
subject to change without notice. While every precaution has been taken in the
preparation of this document, it may contain technical inaccuracies, omissions
and typographical errors, and AMD is under no obligation to update or otherwise
correct this information. Advanced Micro Devices, Inc. makes no representations
or warranties with respect to the accuracy or completeness of the contents of
this document, and assumes no liability of any kind, including the implied
warranties of noninfringement, merchantability or fitness for particular
purposes, with respect to the operation or use of AMD hardware, software or
other products described herein.
AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced
Micro Devices, Inc. Other product names used in this publication are for
identification purposes only and may be trademarks of their respective
companies.
Copyright (c) 2014-2024 Advanced Micro Devices, Inc. All rights reserved.
</div>
@@ -1,50 +0,0 @@
.. meta::
:description: AMDSMI documentation and API reference library
:keywords: amdsmi, ROCm, API, documentation
********************************************************************
AMD SMI documentation
********************************************************************
The AMD System Management Interface (SMI) Library, or AMD SMI library, is a C library for Linux that provides a user space interface for applications to monitor and control AMD devices.
You can access the AMD SMI code on the `GitHub repository <https://github.com/ROCm/amdsmi>`_.
.. Note::
This project is a successor to `rocm_smi_lib. <https://github.com/RadeonOpenCompute/rocm_smi_lib>`_
.. grid:: 2
:gutter: 3
.. grid-item-card:: Install
* :doc:`AMD SMI installation <./install/install>`
.. grid-item-card:: API reference
* :doc:`Files <../doxygen/docBin/html/files>`
* :doc:`Globals <../doxygen/docBin/html/globals>`
* :doc:`Data structures <../doxygen/docBin/html/annotated>`
* :doc:`Modules <../doxygen/docBin/html/modules>`
* :doc:`Data fields <../doxygen/docBin/html/functions_data_fields>`
.. grid-item-card:: How to
* :doc:`Use AMD SMI for C++ library <how-to/using-amdsmi-for-C++>`
* :doc:`Use AMD SMI for Python library <how-to/using-amdsmi-for-python>`
* :doc:`Use AMD SMI CLI tool <how-to/using-AMD-SMI-CLI-tool>`
.. grid-item-card:: Tutorials
* `AMD SMI GitHub samples <https://github.com/ROCm/amdsmi/tree/develop/example>`_
* `ROCm SMI Github samples <https://github.com/ROCm/rocm_smi_lib/tree/develop/docs>`_
To contribute to the documentation, refer to
`Contributing to ROCm <https://rocm.docs.amd.com/en/latest/contribute/contributing.html>`_.
You can find licensing information on the
`Licensing <https://rocm.docs.amd.com/en/latest/about/license.html>`_ page.
@@ -0,0 +1,110 @@
---
myst:
html_meta:
"description lang=en": "How to build AMD SMI from source."
"keywords": "system, management, interface, contribute, contributing, ROCm, develop, testing"
---
# Building AMD SMI
This section describes the prerequisites and steps to build AMD SMI from source.
(build_reqs)=
## Required software
To build the AMD SMI library, the following components are required. Note that
the software versions specified were used during development; earlier
versions are not guaranteed to work.
* CMake (v3.14.0 or later) -- `python3 -m pip install cmake`
* g++ (v5.4.0 or later)
In order to build the AMD SMI Python package, the following components are
required:
* Python (3.6.8 or later)
* prerequisite modules:
* python3-wheel
* python3-setuptools
* virtualenv -- `python3 -m pip install virtualenv`
## Build steps
1. Clone the AMD SMI repository to your local Linux machine.
```shell
git clone https://github.com/ROCm/amdsmi.git
```
2. The default installation location for the library and headers is `/opt/rocm`.
Before installation, any old ROCm directories should be deleted:
* `/opt/rocm`
* `/opt/rocm-<version_number>`
3. Build the library by following the typical CMake build sequence (run as root
user or use `sudo` before `make install` command); for instance:
```bash
mkdir -p build
cd build
cmake ..
make -j $(nproc)
make install
```
The built library is located in the `build/` directory. To build the `rpm`
and `deb` packages use the following command:
```bash
make package
```
(rebuild_py_wrapper)=
## Rebuild the Python wrapper
The Python wrapper for the AMD SMI library is found in the [auto-generated
file](#py_lib_fs) `py-interface/amdsmi_wrapper.py`. It is essential to
regenerate this wrapper whenever there are changes to the C++ API. It is not
regenerated automatically.
To regenerate the wrapper, use the following command.
```shell
./update_wrapper.sh
```
After this command, the file in `py-interface/amdsmi_wrapper.py` will be updated
on compile.
```{note}
You need Docker installed on your system to regenerate the Python wrapper.
```
(build_tests)=
## Build the tests
To verify the build and capabilities of AMD SMI on your system, as well as to
see practical examples of its usage, you can build and run the available [tests
in the repository](https://github.com/ROCm/amdsmi/tree/amd-staging/tests).
Follow these steps to build the tests:
```bash
mkdir -p build
cd build
cmake -DBUILD_TESTS=ON ..
make -j $(nproc)
```
(run_tests)=
### Run the tests
Once the tests are [built](#build_tests), you can run them by executing the
`amdsmitst` program. The executable can be found at `build/tests/amd_smi_test/`.
(build_docs)=
## Build the docs
To build the documentation, follow the instructions at [Building
documentation](https://rocm.docs.amd.com/en/latest/contribute/building.html).
@@ -0,0 +1,144 @@
---
myst:
html_meta:
"description lang=en": "How to install AMD SMI libraries and CLI tool."
"keywords": "system, management, interface, cpu, gpu, hsmp, versions"
---
# AMD SMI library and CLI tool
This section describes how to install the AMD SMI library, Python interface,
and command line tool either as part of the
{doc}`ROCm software stack <rocm:what-is-rocm>` -- or manually.
(install_reqs)=
## Requirements
The following are required to install and use the AMD SMI libraries and CLI
tool.
* Python 3.6.8+ (64-bit)
* `amdgpu` driver must be loaded for [`amdsmi_init()`](#cpp_hello_amdsmi) to
work.
### Supported platforms
At initial release, the AMD SMI library will support Linux bare metal and Linux
virtual machine guest for AMD GPUs. In a future release, the library will be
extended to support AMD EPYC™ CPUs.
AMD SMI library can run on AMD ROCm supported platforms, refer to
{doc}`System requirements (Linux) <rocm-install-on-linux:reference/system-requirements>`
for more information.
<!--https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html-->
To run the AMD SMI library, the `amdgpu` driver and the `amd_hsmp` driver need
to be installed. Optionally, `libdrm` can be installed to query firmware
information and hardware IPs.
(install_amdgpu_rocm)=
## Install amdgpu driver and AMD SMI with ROCm
<!--https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/amdgpu-install.html-->
1. Get the `amdgpu-install` installer following the instructions for your
Linux distribution at {doc}`rocm-install-on-linux:install/amdgpu-install`.
See the following example; your desired ROCm release and install URL may be
different.
```shell
sudo apt update
wget https://repo.radeon.com/amdgpu-install/6.2.2/ubuntu/noble/amdgpu-install_6.2.60202-1_all.deb
sudo apt install ./amdgpu-install_6.2.60202-1_all.deb
```
2. Use `amdgpu-install` to install the `amdgpu` driver and ROCm packages with
AMD SMI included.
``` shell
sudo amdgpu-install --usecase=rocm
```
The `amdgpu-install --usecase=rocm` option triggers both an `amdgpu` driver
update and AMD SMI packages to be installed on your device.
3. Verify your installation.
```shell
amd-smi --help
```
(install_without_rocm)=
## Install AMD SMI without ROCm
The following are example steps to install the AMD SMI libraries and CLI tool on
Ubuntu 22.04.
1. Install the library.
```shell
sudo apt install amd-smi-lib
```
2. Add the installation directory to your PATH. If installed with ROCm, ignore
this step.
```shell
export PATH="${PATH:+${PATH}:}~/opt/rocm/bin"
```
3. Verify your installation.
```shell
amd-smi --help
```
## Optionally enable CLI autocompletion
The `amd-smi` CLI application supports autocompletion. If `argcomplete` is not
installed and enabled already, do so using the following commands.
```shell
python3 -m pip install argcomplete
activate-global-python-argcomplete --user
# restart shell to enable
```
(install-manual-py-lib)=
## Install the Python library for multiple ROCm instances
If {doc}`multiple ROCm versions are installed
<rocm-install-on-linux:install/native-install/multi-version-install>` and you
are not using `pyenv`, uninstall previous versions of AMD SMI before installing
the desired version from your ROCm instance.
### Manually install the Python library
The following are example AMD SMI installation steps on Ubuntu 22.04 without
ROCm.
1. Remove previous AMD SMI installation.
```shell
python3 -m pip list | grep amd
python3 -m pip uninstall amdsmi
```
2. Install the AMD SMI Python library from your target ROCm instance.
```shell
apt install amd-smi-lib
cd /opt/rocm/share/amd_smi
python3 -m pip install --upgrade pip
python3 -m pip install --user .
```
3. You should now have the AMD SMI Python library in your Python path:
```shell-session
~$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import amdsmi
>>>
```
@@ -1,147 +0,0 @@
.. meta::
:description: Install AMD SMI
:keywords: install, SMI, AMD, ROCm
********************************************************************
Installation
********************************************************************
AMD System Management Interface (AMD SMI) library
-------------------------------------------------
The AMD System Management Interface Library (AMD SMI library) is a C library for Linux that provides a user space interface for applications to monitor and control AMD devices.
.. Note::
This project is a successor to `rocm_smi_lib. <https://github.com/RadeonOpenCompute/rocm_smi_lib>`_
Supported platforms
=====================
In its initial release, the AMD SMI library supports Linux bare metal and Linux virtual machine guest for AMD GPUs. In a future release, the library will extend to support AMD EPYC™ CPUs.
The AMD SMI library can run on AMD ROCm-supported platforms. Refer to `System requirements - Linux <https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html>`_ for more information.
To run the AMD SMI library, the `amdgpu` driver and the `hsmp` driver must be installed. Optionally, `libdrm` can be installed to query firmware information and hardware IPs.
CLI tool and libraries installation
------------------------------------
Requirements
=============
* Python 3.6.8+ 64-bit
* amdgpu driver must be loaded for `amdsmi_init()` to pass
Installation steps
-------------------
1. Install amdgpu using ROCm.
2. Install amdgpu driver. See the following example. Note that your release and link may differ. The `amdgpu-install --usecase=rocm` triggers both the amdgpu driver update and AMD SMI packages to be installed on your device.
.. code-block:: shell
sudo apt update
wget https://repo.radeon.com/amdgpu-install/6.0.2/ubuntu/jammy/amdgpu-install_6.0.60002-1_all.deb
sudo apt install ./amdgpu-install_6.0.60002-1_all.deb
sudo amdgpu-install --usecase=rocm
amd-smi --help
3. Install an example for Ubuntu 22.04 (without ROCm).
.. code-block:: bash
apt install amd-smi-lib
# if installed with rocm ignore the export
export PATH="${PATH:+${PATH}:}~/opt/rocm/bin"
amd-smi --help
Optional autocompletion
------------------------
The `amd-smi` cli application supports autocompletion. The package should attempt to install it, if argcomplete is not installed, you can enable it by using the following commands:
.. code:: bash
python3 -m pip install argcomplete
activate-global-python-argcomplete --user
# restart shell to enable
Manual/Multiple ROCm instance Python library install
------------------------------------------------------
In the event there are multiple ROCm installations and `pyenv` is not being used to use the correct amdsmi version, you must uninstall previous versions of AMD SMI and install the latest version you want directly from your ROCm instance.
Python library install example for Ubuntu 22.04
=================================================
1. Remove any existing AMD SMI installation:
.. code-block:: bash
python3 -m pip list | grep amd
python3 -m pip uninstall amdsmi
2. Install Python library from your target ROCm instance:
.. code:: bash
apt install amd-smi-lib
cd /opt/rocm/share/amd_smi
python3 -m pip install --upgrade pip
python3 -m pip install --user
Now you have the AMD SMI Python library in your Python path:
.. code:: bash
~$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08)
[GCC 9.4.0] on linux
3. Type "help", "copyright", "credits" or "license" for more information
.. code:: bash
import amdsmi
Sphinx documentation
=====================
Run the following commands to build the documentation locally:
.. code-block:: bash
cd docs
python3 -m pip install -r sphinx/requirements.txt
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
The output is available in `docs/_build/html`.
For additional details, see `Contribute to ROCm documentation <https://rocm.docs.amd.com/en/latest/contribute/contributing.html>`_.
@@ -1,6 +1,9 @@
=======
.. meta::
:description: Review the AMD SMI license agreement.
:keywords: amdsmi
*******
License
=======
*******
.. include:: ../LICENSE
:literal:
@@ -1,2 +0,0 @@
```{include} ../py-interface/README.md
```
@@ -0,0 +1,21 @@
---
myst:
html_meta:
"description lang=en": "Explore the AMD SMI C++ API."
"keywords": "api, smi, lib, cpp, header, system, management, interface, ROCm"
---
# AMD SMI C++ API reference
This section provides comprehensive documentation for the AMD SMI C++ API.
Explore these sections to understand the full scope of available
functionalities and how to implement them in your applications.
- {doc}`Modules <../doxygen/docBin/html/modules>`
- {doc}`Files <../doxygen/docBin/html/files>`
- {doc}`Globals <../doxygen/docBin/html/globals>`
- {doc}`Data structures <../doxygen/docBin/html/annotated>`
@@ -1,73 +1,20 @@
# AMD SMI Python Library
---
myst:
html_meta:
"description lang=en": "Explore the AMD SMI Python API."
"keywords": "api, smi, lib, py, system, management, interface, ROCm"
---
## Requirements
# AMD SMI Python API reference
* Python 3.6+ 64-bit
* Driver must be loaded for amdsmi_init() to pass
The AMD SMI Python interface provides a convenient way to interact with AMD
hardware through a simple and accessible API. Compatible with Python 3.6 and
higher, this library requires the AMD driver to be loaded for initialization --
review the [prerequisites](#install_reqs).
## Overview
### Folder structure
File Name | Note
---|---
`__init__.py` | Python package initialization file
`amdsmi_interface.py` | Amdsmi library python interface
`amdsmi_wrapper.py` | Python wrapper around amdsmi binary
`amdsmi_exception.py` | Amdsmi exceptions python file
`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:
amdsmi_init()
# amdsmi calls ...
except AmdSmiException as e:
print(e)
finally:
try:
amdsmi_shut_down()
except AmdSmiException as e:
print(e)
```
To initialize amdsmi lib, amdsmi_init() must be called before all other calls to amdsmi lib.
To close connection to driver, amdsmi_shut_down() must be the last call.
### Exceptions
All exceptions are in `amdsmi_exception.py` file.
Exceptions that can be thrown are:
* `AmdSmiException`: base amdsmi exception class
* `AmdSmiLibraryException`: derives base `AmdSmiException` class and represents errors that can occur in amdsmi-lib.
When this exception is thrown, `err_code` and `err_info` are set. `err_code` is an integer that corresponds to errors that can occur
in amdsmi-lib and `err_info` is a string that explains the error that occurred.
Example:
```python
try:
num_of_GPUs = len(amdsmi_get_processor_handles())
if num_of_GPUs == 0:
print("No GPUs on machine")
except AmdSmiException as e:
print("Error code: {}".format(e.err_code))
if e.err_code == amdsmi_wrapper.AMDSMI_STATUS_RETRY:
print("Error info: {}".format(e.err_info))
```
* `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.
This section provides comprehensive documentation for the AMD SMI Python API.
Explore these sections to understand the full scope of available functionalities
and how to implement them in your applications.
## API
@@ -497,6 +444,7 @@ Field | Description
`vram_type` | vram type
`vram_vendor` | vram vendor
`vram_size` | vram size in mb
`vram_bit_width` | vram bit width
Exceptions that can be thrown by `amdsmi_get_gpu_vram_info` function:
@@ -517,6 +465,7 @@ try:
print(vram_info['vram_type'])
print(vram_info['vram_vendor'])
print(vram_info['vram_size'])
print(vram_info['vram_bit_width'])
except AmdSmiException as e:
print(e)
```
@@ -532,17 +481,17 @@ Input parameters:
Output: List of Dictionaries containing cache information following the schema below:
Schema:
```JSON
```json
{
cache_properties:
"cache_properties":
{
"type" : "array",
"items" : {"type" : "string"}
},
cache_size: {"type" : "number"},
cache_level: {"type" : "number"},
max_num_cu_shared: {"type" : "number"},
num_cache_instance: {"type" : "number"}
"cache_size": {"type" : "number"},
"cache_level": {"type" : "number"},
"max_num_cu_shared": {"type" : "number"},
"num_cache_instance": {"type" : "number"}
}
```
@@ -2102,6 +2051,7 @@ except AmdSmiException as e:
```
### amdsmi_set_gpu_process_isolation
Description: Enable/disable the system Process Isolation for the given device handle.
Input parameters:
@@ -2132,6 +2082,7 @@ except AmdSmiException as e:
```
### amdsmi_clean_gpu_local_data
Description: Clear the SRAM data of the given device. This can be called between user logins to prevent information leak.
Input parameters:
@@ -2160,7 +2111,6 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_overdrive_level
Description: Get the overdrive percent associated with the device with provided
@@ -2396,6 +2346,78 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_pm_metrics_info
Description: This function will retreive the name and value for each
item in the pm metrics table with the given processor handle.
Input parameters:
* `processor_handle` handle for the given device
Output: List containing dictionaries of pm metrics and their values
Field | Description
---|---
`name` | name of PM metric
`value` | value of pm metric
Exceptions that can be thrown by `amdsmi_get_gpu_pm_metrics_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
print(amdsmi_get_gpu_pm_metrics_info(device))
except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_reg_table_info
Description: This function will retrieve register metrics table with provided device index and register type.
Input parameters:
* `processor_handle` handle for the given device
* `reg_type` register type
Output: List containing dictionaries of register metrics and their values
Field | Description
---|---
`name` | name of register metric
`value` | value of register metric
Exceptions that can be thrown by `amdsmi_get_gpu_reg_table_info` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
print(amdsmi_get_gpu_reg_table_info(device, AmdSmiRegType.PCIE))
except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_od_volt_curve_regions
Description: This function will retrieve the current valid regions in the
@@ -3607,6 +3629,45 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_P2P_status
Description: Retrieve the connection type and P2P capabilities between 2 GPUs
Input parameters:
* `processor_handle_src` the source device handle
* `processor_handle_dest` the destination device handle
Output: Dictionary with fields:
Fields | Description
---|---
`type` | AmdSmiIoLinkType
`cap` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`is_iolink_coherent`</td><td>1 == True; 0 == False; Uint_max = Undefined</td></tr><tr><td>`is_iolink_atomics_32bit`</td><td>Supports 32bit atomics</td></tr><tr><td>`is_iolink_atomics_64bit`</td><td>Supports 64bit atomics</td></tr><tr><td>`is_iolink_dma`</td><td>Supports DMA</td></tr><tr><td>`is_iolink_bi_directional`</td><td>Is the IOLink Bidirectional</td></tr></tbody></table>
Exceptions that can be thrown by `amdsmi_get_P2P_status` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
processor_handle_src = devices[0]
processor_handle_dest = devices[1]
link_type = amdsmi_get_P2P_status(processor_handle_src, processor_handle_dest)
print(link_type['type'])
print(link_type['caps'])
except AmdSmiException as e:
print(e)
```
### amdsmi_is_P2P_accessible
Description: Return P2P availability status between 2 GPUs
@@ -3767,6 +3828,44 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_accelerator_partition_profile
**Note: CURRENTLY HARDCODED TO RETURN EMPTY VALUES**
Description: Get partition information for target device
Input parameters:
* `processor_handle` the device handle
Output: Dictionary with fields:
Field | Description
---|---
`partition_id` | ID of the partition on the GPU provided
`partition_profile` | Dict containing partition data (TBD)
Exceptions that can be thrown by `amdsmi_get_gpu_accelerator_partition_profile` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
partition_id = amdsmi_get_gpu_accelerator_partition_profile(device)["partition_id"]
print(partition_id)
except AmdSmiException as e:
print(e)
```
### amdsmi_get_xgmi_info
Description: Returns XGMI information for the GPU.
@@ -3839,8 +3938,7 @@ try:
else:
print(amdsmi_get_gpu_device_uuid(devices[0]))
nearest_gpus = amdsmi_topology_nearest_t()
nearest_gpus = amdsmi_get_link_topology_nearest(devices[0], AmdSmiLinkType(2))
nearest_gpus = amdsmi_get_link_topology_nearest(devices[0], AmdSmiLinkType.AMDSMI_LINK_TYPE_PCIE)
if (nearest_gpus['count']) == 0:
print("No nearest GPUs found on machine")
else:
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است Diff را بارگزاری کن
@@ -1,14 +0,0 @@
.. meta::
:description: Install AMD SMI
:keywords: install, SMI, AMD, ROCm
******************
API reference
******************
This section provides technical descriptions and important information about the different AMD SMI and library components.
* {doc}`Library <../doxygen/docBin/html/files>`
* {doc}`Functions <../doxygen/docBin/html/globals>`
* {doc}`Data structures <../doxygen/docBin/html/annotated>`
@@ -1,49 +1,51 @@
defaults:
numbered: false
root: index
subtrees:
- entries:
- file: what-is-AMDSMI.rst
title: What is AMD SMI?
subtrees:
- caption: Install
entries:
- file: install/install.rst
title: AMD SMI installation
- file: install/install.md
title: Library and CLI tool installation
- file: install/build.md
title: Build from source
- caption: How to
entries:
- file: how-to/using-amdsmi-for-C++.rst
title: Use AMD SMI for C++ library
- file: how-to/using-amdsmi-for-python.md
title: Use AMD SMI for Python library
- file: how-to/using-AMD-SMI-CLI-tool.md
title: Use AMD SMI CLI tool
- caption: API reference
- file: how-to/amdsmi-cpp-lib.md
title: C++ library usage
- file: how-to/amdsmi-py-lib.md
title: Python library usage
- file: how-to/amdsmi-cli-tool.md
title: CLI tool usage
- caption: Reference
entries:
- file: reference/amdsmi-cpp-api.md
title: C++ API
entries:
- file: doxygen/docBin/html/modules
title: Modules
- file: doxygen/docBin/html/files
title: Files
- file: doxygen/docBin/html/globals
title: Globals
- file: doxygen/docBin/html/annotated
title: Data structures
- file: doxygen/docBin/html/modules
title: Modules
- file: doxygen/docBin/html/functions_data_fields
title: Data fields
- file: reference/amdsmi-py-api.md
title: Python API
- file: reference/changelog.md
title: Changelog
- caption: Tutorials
entries:
- url: https://github.com/ROCm/amdsmi/tree/amd-staging/example
title: AMD SMI GitHub samples
- url: https://github.com/ROCm/rocm_smi_lib/tree/amd-staging/docs
title: ROCm SMI lib GitHub samples
- url: https://github.com/ROCm/amdsmi/tree/amd-staging/example
title: AMD SMI examples (GitHub)
- url: https://github.com/ROCm/rocm_smi_lib/tree/amd-staging/example
title: ROCm SMI lib examples (GitHub)
- caption: About
entries:
- file: license.md
- file: license.md
@@ -1 +1 @@
rocm-docs-core[api_reference]==1.4.0
rocm-docs-core[api_reference]==1.8.2
@@ -6,9 +6,9 @@
#
accessible-pygments==0.0.5
# via pydata-sphinx-theme
alabaster==0.7.16
alabaster==1.0.0
# via sphinx
babel==2.15.0
babel==2.16.0
# via
# pydata-sphinx-theme
# sphinx
@@ -16,9 +16,9 @@ beautifulsoup4==4.12.3
# via pydata-sphinx-theme
breathe==4.35.0
# via rocm-docs-core
certifi==2024.6.2
certifi==2024.8.30
# via requests
cffi==1.16.0
cffi==1.17.1
# via
# cryptography
# pynacl
@@ -31,7 +31,7 @@ click==8.1.7
# sphinx-external-toc
click-log==0.4.0
# via doxysphinx
cryptography==42.0.8
cryptography==43.0.1
# via pyjwt
deprecated==1.2.14
# via pygithub
@@ -41,15 +41,15 @@ docutils==0.21.2
# myst-parser
# pydata-sphinx-theme
# sphinx
doxysphinx==3.3.8
doxysphinx==3.3.10
# via rocm-docs-core
fastjsonschema==2.19.1
fastjsonschema==2.20.0
# via rocm-docs-core
gitdb==4.0.11
# via gitpython
gitpython==3.1.43
# via rocm-docs-core
idna==3.7
idna==3.10
# via requests
imagesize==1.4.1
# via sphinx
@@ -67,13 +67,13 @@ markdown-it-py==3.0.0
# myst-parser
markupsafe==2.1.5
# via jinja2
mdit-py-plugins==0.4.1
mdit-py-plugins==0.4.2
# via myst-parser
mdurl==0.1.2
# via markdown-it-py
mpire==2.10.2
# via doxysphinx
myst-parser==3.0.1
myst-parser==4.0.0
# via rocm-docs-core
numpy==1.26.4
# via doxysphinx
@@ -83,11 +83,11 @@ packaging==24.1
# sphinx
pycparser==2.22
# via cffi
pydata-sphinx-theme==0.15.3
pydata-sphinx-theme==0.15.4
# via
# rocm-docs-core
# sphinx-book-theme
pygithub==2.3.0
pygithub==2.4.0
# via rocm-docs-core
pygments==2.18.0
# via
@@ -97,13 +97,13 @@ pygments==2.18.0
# sphinx
pyjson5==1.6.6
# via doxysphinx
pyjwt[crypto]==2.8.0
pyjwt[crypto]==2.9.0
# via pygithub
pynacl==1.5.0
# via pygithub
pyparsing==3.1.2
pyparsing==3.1.4
# via doxysphinx
pyyaml==6.0.1
pyyaml==6.0.2
# via
# myst-parser
# rocm-docs-core
@@ -112,15 +112,15 @@ requests==2.32.3
# via
# pygithub
# sphinx
rocm-docs-core[api-reference]==1.4.0
rocm-docs-core[api-reference]==1.8.2
# via -r requirements.in
smmap==5.0.1
# via gitdb
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.5
soupsieve==2.6
# via beautifulsoup4
sphinx==7.3.7
sphinx==8.0.2
# via
# breathe
# myst-parser
@@ -135,33 +135,33 @@ sphinx-book-theme==1.1.3
# via rocm-docs-core
sphinx-copybutton==0.5.2
# via rocm-docs-core
sphinx-design==0.6.0
sphinx-design==0.6.1
# via rocm-docs-core
sphinx-external-toc==1.0.1
# via rocm-docs-core
sphinx-notfound-page==1.0.2
sphinx-notfound-page==1.0.4
# via rocm-docs-core
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-applehelp==2.0.0
# via sphinx
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-devhelp==2.0.0
# via sphinx
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-htmlhelp==2.1.0
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-qthelp==2.0.0
# via sphinx
sphinxcontrib-serializinghtml==1.1.10
sphinxcontrib-serializinghtml==2.0.0
# via sphinx
tomli==2.0.1
tomli==2.0.2
# via sphinx
tqdm==4.66.4
tqdm==4.66.5
# via mpire
typing-extensions==4.12.2
# via
# pydata-sphinx-theme
# pygithub
urllib3==2.2.1
urllib3==2.2.3
# via
# pygithub
# requests
@@ -180,7 +180,7 @@ typedef enum {
#define AMDSMI_LIB_VERSION_MAJOR 7
//! Minor version should be updated for each API change, but without changing headers
#define AMDSMI_LIB_VERSION_MINOR 0
#define AMDSMI_LIB_VERSION_MINOR 1
//! Release version should be set to 0 as default and can be updated by the PMs for each CSP point release
#define AMDSMI_LIB_VERSION_RELEASE 0
@@ -2573,14 +2573,12 @@ amdsmi_status_t amdsmi_set_gpu_pci_bandwidth(amdsmi_processor_handle processor_h
* @platform{gpu_bm_linux}
*
* @details Given a processor handle @p processor_handle, a pointer to a uint64_t
* @p power, and a pointer to a uint64_t @p timestamp, this function will write
* amount of energy consumed to the uint64_t pointed to by @p power,
* and the timestamp to the uint64_t pointed to by @p timestamp.
* @p energy_accumulator, and a pointer to a uint64_t @p timestamp, this function
* will write amount of energy consumed to the uint64_t pointed to by
* @p energy_accumulator, and the timestamp to the uint64_t pointed to by @p timestamp.
* This function accumulates all energy consumed.
*
* @param[in] processor_handle a processor handle
* @param[in,out] counter_resolution resolution of the counter @p power in
* micro Joules
*
* @param[in,out] energy_accumulator a pointer to uint64_t to which the energy
* counter will be written
@@ -2589,6 +2587,9 @@ amdsmi_status_t amdsmi_set_gpu_pci_bandwidth(amdsmi_processor_handle processor_h
* and ::AMDSMI_STATUS_NOT_SUPPORTED if it is not supported with the
* provided arguments.
*
* @param[in,out] counter_resolution resolution of the counter @p energy_accumulator in
* micro Joules
*
* @param[in,out] timestamp a pointer to uint64_t to which the timestamp
* will be written. Resolution: 1 ns.
*
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است Diff را بارگزاری کن
@@ -412,6 +412,14 @@ class AmdSmiProcessorType(IntEnum):
AMDSMI_PROCESSOR_TYPE_NON_AMD_CPU = amdsmi_wrapper.AMDSMI_PROCESSOR_TYPE_NON_AMD_CPU
class AmdSmiRegType(IntEnum):
XGMI = amdsmi_wrapper.AMDSMI_REG_XGMI
WAFL = amdsmi_wrapper.AMDSMI_REG_WAFL
PCIE = amdsmi_wrapper.AMDSMI_REG_PCIE
USR = amdsmi_wrapper.AMDSMI_REG_USR
USR1 = amdsmi_wrapper.AMDSMI_REG_USR1
class AmdSmiEventReader:
def __init__(
self, processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
@@ -1745,8 +1753,8 @@ def amdsmi_get_gpu_pm_metrics_info(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
pm_metrics = ctypes.POINTER(struct_amdsmi_name_value_t);
num_mets = ctypes.c_uint32;
pm_metrics = ctypes.POINTER(amdsmi_wrapper.amdsmi_name_value_t)
num_mets = ctypes.c_uint32
_check_res(
amdsmi_wrapper.amdsmi_get_gpu_pm_metrics_info(
@@ -1767,15 +1775,15 @@ def amdsmi_get_gpu_pm_metrics_info(
def amdsmi_get_gpu_reg_table_info(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
reg_type: amdsmi_wrapper.amdsmi_reg_type_t,
reg_type: AmdSmiRegType,
) -> Dict[str, Any]:
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
reg_metrics = ctypes.POINTER(struct_amdsmi_name_value_t);
num_regs = ctypes.c_uint32;
reg_metrics = ctypes.POINTER(amdsmi_wrapper.amdsmi_name_value_t)
num_regs = ctypes.c_uint32
_check_res(
amdsmi_wrapper.amdsmi_get_gpu_reg_table_info(
@@ -1790,7 +1798,7 @@ def amdsmi_get_gpu_reg_table_info(
'value': reg_metrics[i].value
}
results.append(item)
amdsmi_wrapper.amdsmi_free_name_value_pairs(pm_metrics)
amdsmi_wrapper.amdsmi_free_name_value_pairs(reg_metrics)
return results