AMD-SMI-CLI - Packaging updates

Added fallback in amdsmi_init.py to access /opt/rocm/share/amd_smi
        if python package is not installed
    Made libamd_smi.so detection more reliable
    Added PyYaml dependency to pyproject.toml
    Added python3-clang dependency in CMakeLists
    Updated python3 version dependency in CMakeLists
    Update Readme
    Added Release Notes

Change-Id: Ie3b85fde7563dd84dce499f229aac1f94bcc2989
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Этот коммит содержится в:
Maisam Arif
2023-05-18 16:00:45 -05:00
родитель 2f18ec7539
Коммит da50f4f078
7 изменённых файлов: 89 добавлений и 26 удалений
+8 -7
Просмотреть файл
@@ -208,9 +208,10 @@ set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS "sudo, libdrm-dev")
set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS "sudo, libdrm-dev")
set(CPACK_DEBIAN_ASAN_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}-asan")
set(CPACK_DEBIAN_DEV_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3")
set(CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS "python3")
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "python3")
#Python 3.7.9 is the first stable build post the python bugfix window
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3 (>= 3.7.9), python3-clang, python3-yaml")
set(CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS "python3 (>= 3.7.9), python3-clang, python3-yaml")
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "python3 (>= 3.7.9), python3-clang, python3-yaml")
## Process the Debian install/remove scripts to update the CPACK variables
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst.in DEBIAN/postinst @ONLY)
@@ -227,11 +228,12 @@ endif()
set(CPACK_RPM_PACKAGE_PROVIDES "amd-smi")
set(CPACK_RPM_DEV_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}")
set(CPACK_RPM_ASAN_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}-asan")
set(CPACK_RPM_PACKAGE_REQUIRES "python3")
#Python 3.7.9 is the first stable build post the python bugfix window
set(CPACK_RPM_PACKAGE_REQUIRES "python38, python3-clang, python3-pyyaml")
# don't terminate if bytecompile of python files fails
set(CPACK_RPM_SPEC_MORE_DEFINE "%define _python_bytecompile_errors_terminate_build 0")
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "python3")
set(CPACK_RPM_ASAN_PACKAGE_REQUIRES "python3")
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "python38, python3-clang, python3-pyyaml")
set(CPACK_RPM_ASAN_PACKAGE_REQUIRES "python38, python3-clang, python3-pyyaml")
# Add rocm-core dependency if -DROCM_DEP_ROCMCORE=ON is passed
if(ROCM_DEP_ROCMCORE)
@@ -243,7 +245,6 @@ if(ROCM_DEP_ROCMCORE)
string(APPEND CPACK_RPM_PACKAGE_REQUIRES ", rocm-core")
endif()
## Enable Component Mode and set component specific flags
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "${AMD_SMI_PACKAGE}")
+29 -6
Просмотреть файл
@@ -1,4 +1,5 @@
# AMD System Management Interface
This tool acts as a command line interface for manipulating
and monitoring the amdgpu kernel, and is intended to replace
and deprecate the existing rocm_smi CLI tool & gpuv-smi tool.
@@ -6,27 +7,47 @@ It uses Ctypes to call the amd_smi_lib API.
Recommended: At least one AMD GPU with AMD driver installed
## Requirements
* python 3.7+ 64-bit
* driver must be loaded for amdsmi_init() to pass
- python 3.7+ 64-bit
- driver must be loaded for amdsmi_init() to pass
## Installation
- Install amdgpu driver
- Through package manager install amd-smi-lib
- Install amd-smi-lib package through package manager
- cd /opt/<rocm_instance>/share/amd_smi
- pip install .
- /opt/<rocm_instance>/bin/amd-smi
or
- pip3 install .
- /opt/<rocm_instance>/bin/amd-smi --help
### RHEL 8
The default python version in RHEL 8 is python 3.6.8
To install the python library you need to upgrade to python 3.7+
The package's dependency manager will attempt to install python 3.8+
Verify that your pip version is 3.7+ and if not you can use pip3.8 instead
### Example of Ubuntu 22.04 post amdgpu driver install
``` shell
apt install amd-smi-lib
cd /opt/rocm/share/amd_smi
pip install .
/opt/rocm/bin/amd-smi
```
Add /opt/rocm/bin to your local path to access amd-smi via the cmdline
Add /opt/rocm/bin to your shell's path to access amd-smi via the cmdline
## Usage
amd-smi will report the version and current platform detected when running the command without arguments:
``` bash
amd-smi
usage: amd-smi [-h] ...
@@ -51,12 +72,15 @@ AMD-SMI Commands:
set Set options for devices.
reset Reset options for devices.
```
More detailed verison information can be give when running `amd-smi version`
Each command will have detailed information via `amd-smi [command] --help`
## Commands
For convenience, here is the help output for each command
``` bash
amd-smi discovery --help
usage: amd-smi discovery [-h] [--json | --csv] [--file FILE]
@@ -330,4 +354,3 @@ The information contained herein is for informational purposes only, and is subj
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-2023 Advanced Micro Devices, Inc. All rights reserved.
+33
Просмотреть файл
@@ -0,0 +1,33 @@
# Release Notes
## Documentation
Documentation for AMDSMI-CLI is available post install in /opt/<rocm_instance>/libexec/amdsmi_cli/README.md
## AMDSMI-CLI 0.0.4
### Added
- AMDSMI-CLI tool enabled for Linux Baremetal & Guest
- Added CSV & Watch modifier
- Added topology subcommand
### Known Issues
- not all ecc fields are currently supported
- RHEL 8 has extra install steps
## AMDSMI-CLI 0.0.2
### Added
- AMDSMI-CLI tool enabled for Linux Baremetal & Guest
### Known Issues
- ecc & ras subcommands will report N/A even if RAS is enabled
- process vram_mem's unit is listed as percentage vs bytes
- csv modifier does not work
- topology information is not yet enabled
- watch modifier not fully enabled
- limited guest support
+2 -1
Просмотреть файл
@@ -29,7 +29,8 @@ import sys
from pathlib import Path
sys.path.append(f'{Path(__file__).resolve().parent}/../../share/amd_smi')
sys.path.append(f"{Path(__file__).resolve().parent}/../../share/amd_smi")
sys.path.append("/opt/rocm/share/amd_smi")
from amdsmi import amdsmi_interface
from amdsmi import amdsmi_exception
+8 -6
Просмотреть файл
@@ -165,26 +165,28 @@ def char_pointer_cast(string, encoding='utf-8'):
return ctypes.cast(string, ctypes.POINTER(ctypes.c_char))
### Match edits in generator.py from start to end
### Start match
_libraries = {}
from pathlib import Path
libamd_smi_optrocm = Path(__file__).parents[3] / "/lib/libamd_smi.so"
libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so")
libamd_smi_optrocm = Path("/opt/rocm/lib/libamd_smi.so")
libamd_smi_parent_dir = Path(__file__).resolve().parent / "libamd_smi.so"
libamd_smi_cwd = Path.cwd() / "libamd_smi.so"
if libamd_smi_optrocm.is_file():
# try /opt/rocm/lib as a fallback
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_optrocm)
elif libamd_smi_cpack.is_file():
if libamd_smi_cpack.is_file():
# try to find library in install directory provided by CMake
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_cpack)
elif libamd_smi_optrocm.is_file():
# try /opt/rocm/lib as a fallback
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_optrocm)
elif libamd_smi_parent_dir.is_file():
# try to fall back to parent directory
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_parent_dir)
else:
# lastly - search in current working directory
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_cwd)
### End match
+4 -1
Просмотреть файл
@@ -10,11 +10,14 @@ name = "amdsmi"
authors = [
{name = "AMD", email = "amd-smi.support@amd.com"},
]
version = '0.3'
version = '0.4'
license = {file = "amdsmi/LICENSE"}
readme = {file = "amdsmi/README.md", content-type = "text/markdown"}
description = "SMI LIB - AMD GPU Monitoring Library"
requires-python = ">=3.7"
dependencies = [
'PyYAML >= 5.0',
]
[project.urls]
"Homepage" = "https://github.com/RadeonOpenCompute/amdsmi"
+5 -5
Просмотреть файл
@@ -106,17 +106,17 @@ def main():
library_path = os.path.join(os.path.dirname(__file__), library)
line_to_replace = "_libraries['{}'] = ctypes.CDLL('{}')".format(library_name, library_path)
new_line = f"""from pathlib import Path
libamd_smi_optrocm = Path(__file__).parents[3] / "/lib/{library_name}"
libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/{library_name}")
libamd_smi_optrocm = Path("/opt/rocm/lib/{library_name}")
libamd_smi_parent_dir = Path(__file__).resolve().parent / "{library_name}"
libamd_smi_cwd = Path.cwd() / "{library_name}"
if libamd_smi_optrocm.is_file():
# try /opt/rocm/lib as a fallback
_libraries['{library_name}'] = ctypes.CDLL(libamd_smi_optrocm)
elif libamd_smi_cpack.is_file():
if libamd_smi_cpack.is_file():
# try to find library in install directory provided by CMake
_libraries['{library_name}'] = ctypes.CDLL(libamd_smi_cpack)
elif libamd_smi_optrocm.is_file():
# try /opt/rocm/lib as a fallback
_libraries['{library_name}'] = ctypes.CDLL(libamd_smi_optrocm)
elif libamd_smi_parent_dir.is_file():
# try to fall back to parent directory
_libraries['{library_name}'] = ctypes.CDLL(libamd_smi_parent_dir)