ROCm SMI Documentation Reorg
Change-Id: I3e4db2c50a43a51eeea4d3e06ba4811ad1859368 Signed-off-by: Charis Poag <Charis.Poag@amd.com>
This commit is contained in:
committato da
Charis Poag
parent
10f3c2325c
commit
2fd36e33ad
@@ -0,0 +1,35 @@
|
||||
.. meta::
|
||||
:description: ROCm SMI tutorial
|
||||
:keywords: install, SMI, library, api, AMD, ROCm
|
||||
|
||||
ROCm SMI C++ API tutorial
|
||||
----------------------------
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
int main() {
|
||||
|
||||
rsmi_status_t ret;
|
||||
uint32_t num_devices;
|
||||
uint16_t dev_id;
|
||||
|
||||
// We will skip return code checks for this example, but it
|
||||
// is recommended to always check this as some calls may not
|
||||
// apply for some devices or ROCm releases
|
||||
|
||||
ret = rsmi_init(0);
|
||||
ret = rsmi_num_monitor_devices(&num_devices);
|
||||
|
||||
for (int i=0; i < num_devices; ++i) {
|
||||
ret = rsmi_dev_id_get(i, &dev_id);
|
||||
// dev_id holds the device ID of device i, upon a
|
||||
// successful call
|
||||
}
|
||||
ret = rsmi_shut_down();
|
||||
return 0;
|
||||
}
|
||||
|
||||
For more examples please check the `C++ example <https://github.com/ROCm/rocm_smi_lib/blob/develop/rocm_smi/example/rocm_smi_example.cc>`_
|
||||
or `tests. <https://github.com/ROCm/rocm_smi_lib/tree/develop/tests/rocm_smi_test/functional>`_
|
||||
@@ -0,0 +1,31 @@
|
||||
.. meta::
|
||||
:description: ROCm SMI Python tutorial
|
||||
:keywords: install, SMI, library, api, AMD, ROCm
|
||||
|
||||
|
||||
ROCm SMI Python API tutorial
|
||||
-----------------------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import sys
|
||||
sys.path.append("/opt/rocm/libexec/rocm_smi/")
|
||||
try:
|
||||
import rocm_smi
|
||||
except ImportError:
|
||||
raise ImportError("Could not import /opt/rocm/libexec/rocm_smi/rocm_smi.py")
|
||||
|
||||
class prof_utils:
|
||||
def __init__(self, mode) -> None:
|
||||
rocm_smi.initializeRsmi()
|
||||
|
||||
def getPower(self, device):
|
||||
return rocm_smi.getPower(device)
|
||||
|
||||
def listDevices(self):
|
||||
return rocm_smi.listDevices()
|
||||
|
||||
def getMemInfo(self, device):
|
||||
(memUsed, memTotal) = rocm_smi.getMemInfo(device, "vram")
|
||||
return round(float(memUsed)/float(memTotal) * 100, 2)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user