AMDSMI CLI Initial Packaging
- Added CMake packaging to the amdsmi_cli folder - Updated Headings in the README.md to follow markdown standard - Updated Compatibility to be based on the built package name in bin - Added misc error handling and import corrections - Updated py-interface amdsmi_exception imports to work by relative path - Cleaned up py-interface cmake & generator code for finding libamd_smi.so - Changed line endings in tools/generator.py file to unix Change-Id: I91858ff3dd0cb57ed9b8cd61a0ada27b6af9c51c Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Cette révision appartient à :
1 Parent
aa70b77ec5
révision
235c8db949
13 fichiers modifiés
+300
-182
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,89 @@
|
||||
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
message(" CMake AMDSMI CLI Install ")
|
||||
message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
|
||||
|
||||
|
||||
# Set CLI Build Directory
|
||||
set(CLI_BUILD_DIR "amdsmi_cli" CACHE STRING "")
|
||||
set(SHARE_WHL_LOCATION "${SHARE_INSTALL_PREFIX}/${AMD_SMI}/amdsmi-0.1-py3-none-any.whl")
|
||||
|
||||
# The CLI requires the python amdsmi wrapper whl file to exist
|
||||
add_custom_target(
|
||||
amdsmi_cli
|
||||
DEPENDS SHARE_WHL_LOCATION)
|
||||
|
||||
# if Python3 is found but the version is below 3.7 - Python3_FOUND is set to FALSE
|
||||
find_package(Python3 3.7 COMPONENTS Interpreter)
|
||||
|
||||
# WARN: This is a HACK to pass compile on AMD rhel8 CI systems!
|
||||
# Those still use python3.6 which is too old for this project!
|
||||
if(NOT Python3_FOUND)
|
||||
message(AUTHOR_WARNING "Python3 DOESN'T EXIST OR VERSION IS TOO OLD!: ${Python3_VERSION}")
|
||||
# WARN: EXIT CURRENT CMAKE FILE
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_custom_target(
|
||||
amdsmi_whl_install
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade --force-reinstall SHARE_WHL_LOCATION)
|
||||
|
||||
# symlinking instead of copying avoids unnecessarry regeneration of packaged files
|
||||
add_custom_command(
|
||||
OUTPUT ${CLI_BUILD_DIR}/pyproject.toml
|
||||
${CLI_BUILD_DIR}/__init__.py
|
||||
${CLI_BUILD_DIR}/_version.py
|
||||
${CLI_BUILD_DIR}/amdsmi_cli.py
|
||||
${CLI_BUILD_DIR}/amdsmi_commands.py
|
||||
${CLI_BUILD_DIR}/amdsmi_helpers.py
|
||||
${CLI_BUILD_DIR}/amdsmi_logger.py
|
||||
${CLI_BUILD_DIR}/amdsmi_parser.py
|
||||
${CLI_BUILD_DIR}/BDF.py
|
||||
DEPENDS amdsmi_cli
|
||||
amdsmi_whl_install
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/_version.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_commands.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_helpers.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_logger.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_parser.py ${CLI_BUILD_DIR}/
|
||||
COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/BDF.py ${CLI_BUILD_DIR}/)
|
||||
|
||||
install(
|
||||
FILES _version.py
|
||||
amdsmi_commands.py
|
||||
amdsmi_helpers.py
|
||||
amdsmi_init.py
|
||||
amdsmi_logger.py
|
||||
amdsmi_parser.py
|
||||
BDF.py
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli)
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli.py
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
||||
GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/amd-smi
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/gpuv-smi
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# symlink amdsmi_cli.py to amd-smi
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
add_custom_target(
|
||||
link_amdsmi_cli ALL
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
../${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli/amdsmi_cli.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bin/amd-smi)
|
||||
|
||||
add_custom_target(
|
||||
link_gpuvsmi_cli ALL
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
../${CMAKE_INSTALL_LIBEXECDIR}/${AMD_SMI}/amdsmi_cli/amdsmi_cli.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bin/gpuv-smi)
|
||||
Seulement les espaces.
@@ -25,10 +25,18 @@ import sys
|
||||
|
||||
from amdsmi_commands import AMDSMICommands
|
||||
from amdsmi_parser import AMDSMIParser
|
||||
|
||||
from amdsmi_logger import AMDSMILogger
|
||||
|
||||
if __name__ == "__main__":
|
||||
amd_smi_commands = AMDSMICommands()
|
||||
# Set compatability mode based on which cli mapping user selects
|
||||
if 'gpuv-smi' in sys.argv[0]:
|
||||
compatibility = AMDSMILogger.LoggerCompatibility.gpuvsmi.value
|
||||
elif 'rocm-smi' in sys.argv[0]:
|
||||
compatibility = AMDSMILogger.LoggerCompatibility.rocmsmi.value
|
||||
else:
|
||||
compatibility = AMDSMILogger.LoggerCompatibility.amdsmi.value
|
||||
|
||||
amd_smi_commands = AMDSMICommands(compatibility=compatibility)
|
||||
amd_smi_parser = AMDSMIParser(amd_smi_commands.version,
|
||||
amd_smi_commands.discovery,
|
||||
amd_smi_commands.static,
|
||||
@@ -59,8 +67,6 @@ if __name__ == "__main__":
|
||||
'ERROR': logging.ERROR,
|
||||
'CRITICAL': logging.CRITICAL}
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging_dict[args.loglevel])
|
||||
if args.compatibility:
|
||||
amd_smi_commands.logger.compatibility = args.compatibility
|
||||
|
||||
# Execute subcommands
|
||||
args.func(args)
|
||||
@@ -31,8 +31,9 @@ destination.
|
||||
|
||||
from _version import __version__
|
||||
|
||||
from amdsmi_helpers import *
|
||||
from amdsmi_helpers import AMDSMIHelpers
|
||||
from amdsmi_logger import AMDSMILogger
|
||||
from amdsmi import amdsmi_interface
|
||||
|
||||
|
||||
class AMDSMICommands():
|
||||
@@ -744,9 +745,14 @@ class AMDSMICommands():
|
||||
'rpm' : fan_rpm,
|
||||
'usage' : fan_percent}
|
||||
if args.pcie_usage:
|
||||
pcie_link_status = amdsmi_interface.amdsmi_get_pcie_link_status(args.gpu)
|
||||
try:
|
||||
pcie_link_status = amdsmi_interface.amdsmi_get_pcie_link_status(args.gpu)
|
||||
pcie_link_status_call = True
|
||||
except amdsmi_interface.AmdSmiLibraryException as err:
|
||||
pcie_link_status = err.get_error_info()
|
||||
pcie_link_status_call = False
|
||||
|
||||
if self.logger.is_human_readable_format():
|
||||
if self.logger.is_human_readable_format() and pcie_link_status_call:
|
||||
unit ='MT/s'
|
||||
pcie_link_status['pcie_speed'] = f"{pcie_link_status['pcie_speed']} {unit}"
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ import sys
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert( 0, "../build/python_package/amdsmi")
|
||||
import amdsmi_interface
|
||||
import amdsmi as amdsmi_interface
|
||||
|
||||
# Using basic python logging for user errors and development
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) # User level logging
|
||||
|
||||
@@ -34,7 +34,7 @@ class AMDSMILogger():
|
||||
self.output = {}
|
||||
self.multiple_device_output = []
|
||||
self.watch_output = []
|
||||
self.compatibility = compatibility # amdsmi, gpuvsmi, or rocmsmi
|
||||
self.compatibility = compatibility # amd-smi, gpuv-smi, or rocm-smi
|
||||
self.format = format # csv, json, or human_readable
|
||||
self.destination = destination # stdout, path to a file (append)
|
||||
self.amd_smi_helpers = AMDSMIHelpers()
|
||||
@@ -46,7 +46,7 @@ class AMDSMILogger():
|
||||
csv = 'csv'
|
||||
human_readable = 'human_readable'
|
||||
|
||||
class Loggercompatibility(Enum):
|
||||
class LoggerCompatibility(Enum):
|
||||
"""Enum for logger compatibility"""
|
||||
amdsmi = 'amdsmi'
|
||||
rocmsmi = 'rocmsmi'
|
||||
@@ -66,15 +66,15 @@ class AMDSMILogger():
|
||||
|
||||
|
||||
def is_amdsmi_compatibility(self):
|
||||
return self.compatibility == self.Loggercompatibility.amdsmi.value
|
||||
return self.compatibility == self.LoggerCompatibility.amdsmi.value
|
||||
|
||||
|
||||
def is_rocmsmi_compatibility(self):
|
||||
return self.compatibility == self.Loggercompatibility.rocmsmi.value
|
||||
return self.compatibility == self.LoggerCompatibility.rocmsmi.value
|
||||
|
||||
|
||||
def is_gpuvsmi_compatibility(self):
|
||||
return self.compatibility == self.Loggercompatibility.gpuvsmi.value
|
||||
return self.compatibility == self.LoggerCompatibility.gpuvsmi.value
|
||||
|
||||
|
||||
def store_output(self, device_handle, argument, data):
|
||||
|
||||
@@ -183,7 +183,6 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
csv_help = "Displays output in CSV format (human readable by default)."
|
||||
file_help = "Saves output into a file on the provided path (stdout by default)."
|
||||
loglevel_help = "Set the logging level for the parser commands"
|
||||
compatibility_help = "Display output in gpuvsmi or rocmsmi legacy format if possible"
|
||||
|
||||
command_modifier_group = subcommand_parser.add_argument_group('Command Modifiers')
|
||||
|
||||
@@ -197,10 +196,6 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
command_modifier_group.add_argument('--loglevel', action='store', required=False, help=loglevel_help, default='ERROR',
|
||||
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"])
|
||||
|
||||
# Output Compatibility options
|
||||
command_modifier_group.add_argument('--compatibility', action='store', required=False, help=compatibility_help,
|
||||
choices=["amdsmi", "gpuvsmi", "rocmsmi"], default='amdsmi')
|
||||
|
||||
|
||||
def _add_device_arguments(self, subcommand_parser, required=False):
|
||||
# Device arguments help text
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur