Skip to content

Commit

Permalink
Merge amd-master into rocm-rel-6.0 20231122
Browse files Browse the repository at this point in the history
Signed-off-by: Maisam Arif <[email protected]>
Change-Id: I1f63bc7780765fc2d6f0526c0b1bb1a2d4393189
  • Loading branch information
marifamd committed Nov 22, 2023
2 parents 4ce7d69 + f319f73 commit 3f96bd1
Show file tree
Hide file tree
Showing 27 changed files with 11,009 additions and 1,333 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ set(CMN_SRC_LIST
"${ROCM_SRC_DIR}/rocm_smi_counters.cc"
"${ROCM_SRC_DIR}/rocm_smi_device.cc"
"${ROCM_SRC_DIR}/rocm_smi_gpu_metrics.cc"
"${ROCM_SRC_DIR}/rocm_smi_binary_parser.cc"
"${ROCM_SRC_DIR}/rocm_smi_io_link.cc"
"${ROCM_SRC_DIR}/rocm_smi_kfd.cc"
"${ROCM_SRC_DIR}/rocm_smi_main.cc"
Expand All @@ -163,6 +164,7 @@ set(CMN_INC_LIST
"${ROCM_INC_DIR}/rocm_smi_counters.h"
"${ROCM_INC_DIR}/rocm_smi_device.h"
"${ROCM_INC_DIR}/rocm_smi_gpu_metrics.h"
"${ROCM_INC_DIR}/rocm_smi_binary_parser.h"
"${ROCM_INC_DIR}/rocm_smi_exception.h"
"${ROCM_INC_DIR}/rocm_smi_io_link.h"
"${ROCM_INC_DIR}/rocm_smi_kfd.h"
Expand Down Expand Up @@ -245,12 +247,12 @@ install(

#Debian package specific variables
set(CPACK_DEBIAN_PACKAGE_PROVIDES "amd-smi")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "sudo, python3-argcomplete, libdrm-dev, python3-yaml")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python3-argcomplete, libdrm-dev, python3-yaml")
set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
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 (>= 3.6.8), python3-pip")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "sudo, python3 (>= 3.6.8), python3-pip")
set(CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS})
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS})

Expand All @@ -269,11 +271,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")
# NOTE: RPM SUGGESTS DO NOT WORK! https://bugzilla.redhat.com/show_bug.cgi?id=1811358
set(CPACK_RPM_PACKAGE_SUGGESTS "python3-argcomplete")
set(CPACK_RPM_DEV_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS})
set(CPACK_RPM_ASAN_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS})
# python version gated by rhel8 :(
set(CPACK_RPM_PACKAGE_REQUIRES "python3 >= 3.6.8, python3-pip, python3-PyYAML")
set(CPACK_RPM_PACKAGE_REQUIRES "sudo, python3 >= 3.6.8, python3-pip, python3-PyYAML")
set(CPACK_RPM_DEV_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})
set(CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES})

Expand Down
30 changes: 16 additions & 14 deletions DEBIAN/postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ do_ldconfig() {
}

do_install_amdsmi_python_lib() {
echo "Installing AMD-SMI python library (amdsmi)..."
# get python version
local python3_minor_version
python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)')
Expand All @@ -123,8 +122,11 @@ do_install_amdsmi_python_lib() {
return
fi

local PREVIOUS_PIP_ROOT_ACTION="$PIP_ROOT_USER_ACTION"
local PREVIOUS_PIP_ROOT_USER_ACTION="$PIP_ROOT_USER_ACTION"
export PIP_ROOT_USER_ACTION=ignore
# python3.11 requires --break-system-packages
local PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES="$PIP_BREAK_SYSTEM_PACKAGES"
export PIP_BREAK_SYSTEM_PACKAGES=1

# Remove old python library
local pip_list_output
Expand All @@ -140,21 +142,21 @@ do_install_amdsmi_python_lib() {
local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@
python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check

unset PIP_ROOT_USER_ACTION
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_ACTION"
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_USER_ACTION"
export PIP_BREAK_SYSTEM_PACKAGES="$PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES"

pip_list_output=$(python3 -m pip list --disable-pip-version-check)
# check pip list output for argcomplete
if [[ $pip_list_output == *"argcomplete"* ]]; then
activate-global-python-argcomplete3
# Newer versions of argcomplete do not have the 3 at the end
if [ $? -ne 0 ]; then
echo "[WARNING] Could not find activate-global-python-argcomplete3. "\
"Trying newer activate-global-python-argcomplete..."
activate-global-python-argcomplete
# only try to activate argcomplete if such command exists
if command -v activate-global-python-argcomplete &>/dev/null; then
activate-global-python-argcomplete
else
# try older argcomplete3 version
if command -v activate-global-python-argcomplete3 &>/dev/null; then
activate-global-python-argcomplete3
else
echo "[WARNING] Could not find argcomplete or argcomplete3. "\
"Argument completion will not work..."
fi
fi
echo "Installed AMD-SMI python library (amdsmi)..."
}

case "$1" in
Expand Down
32 changes: 12 additions & 20 deletions DEBIAN/prerm.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ rm_ldconfig() {

rm_leftovers() {
# remove pyc files generated by python
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__"
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__"

# remove leftover doc files
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/
# remove build and egg files
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi.egg-info"
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/build"

# remove leftover libs
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so*
# remove leftover doc files
if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*"; then
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*"
fi
}

rm_logFolder() {
Expand All @@ -41,7 +43,6 @@ return_logrotateToOrigConfig() {
}

rm_python_lib() {
echo "Removing AMD-SMI python library (amdsmi)..."
# get python version
local python3_minor_version
python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)')
Expand All @@ -63,26 +64,17 @@ rm_python_lib() {
pip_list_output=$(python3 -m pip list --disable-pip-version-check)
# check pip list output for amdsmi
if [[ $pip_list_output == *"amdsmi"* ]]; then
local PREVIOUS_PIP_ROOT_ACTION="$PIP_ROOT_USER_ACTION"
export PIP_ROOT_USER_ACTION=ignore

echo "Detected AMD-SMI python library (amdsmi)..."
python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
echo "Removed AMD-SMI python library (amdsmi)..."

unset PIP_ROOT_USER_ACTION
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_ACTION"
PIP_ROOT_USER_ACTION=ignore PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
fi

local pip_list_output
pip_list_output=$(python3 -m pip list --disable-pip-version-check)
# check pip list output for amdsmi
if [[ $pip_list_output == *"amdsmi"* ]]; then
echo "[WARNING] AMD-SMI python library (amdsmi) is still installed in pip. "\
"Check post install to ensure version is correct"
return
else
echo "Removed AMD-SMI python library (amdsmi)..."
fi
echo "Removed AMD-SMI python library (amdsmi)..."
}


Expand Down
33 changes: 17 additions & 16 deletions RPM/post.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ do_configureLogrotate() {
chmod -R a+rw "${logPath}"
chmod a+rw "${logFile}"

command -v logrotate &>/dev/null
if [ $? -ne 0 ]; then
if ! command -v logrotate &>/dev/null; then
echo "[WARNING] Detected logrotate is not installed."\
"$packageName logs (when turned on) will not rotate properly."
return
Expand Down Expand Up @@ -105,7 +104,6 @@ do_ldconfig() {
}

do_install_amdsmi_python_lib() {
echo "Installing AMD-SMI python library (amdsmi)..."
# get python version
local python3_minor_version
python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)')
Expand All @@ -123,8 +121,11 @@ do_install_amdsmi_python_lib() {
return
fi

local PREVIOUS_PIP_ROOT_ACTION="$PIP_ROOT_USER_ACTION"
local PREVIOUS_PIP_ROOT_USER_ACTION="$PIP_ROOT_USER_ACTION"
export PIP_ROOT_USER_ACTION=ignore
# python3.11 requires --break-system-packages
local PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES="$PIP_BREAK_SYSTEM_PACKAGES"
export PIP_BREAK_SYSTEM_PACKAGES=1

# Remove old python library
local pip_list_output
Expand All @@ -140,21 +141,21 @@ do_install_amdsmi_python_lib() {
local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@
python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check

unset PIP_ROOT_USER_ACTION
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_ACTION"
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_USER_ACTION"
export PIP_BREAK_SYSTEM_PACKAGES="$PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES"

pip_list_output=$(python3 -m pip list --disable-pip-version-check)
# check pip list output for argcomplete
if [[ $pip_list_output == *"argcomplete"* ]]; then
activate-global-python-argcomplete3
# Newer versions of argcomplete do not have the 3 at the end
if [ $? -ne 0 ]; then
echo "[WARNING] Could not find activate-global-python-argcomplete3. "\
"Trying newer activate-global-python-argcomplete..."
activate-global-python-argcomplete
# only try to activate argcomplete if such command exists
if command -v activate-global-python-argcomplete &>/dev/null; then
activate-global-python-argcomplete
else
# try older argcomplete3 version
if command -v activate-global-python-argcomplete3 &>/dev/null; then
activate-global-python-argcomplete3
else
echo "[WARNING] Could not find argcomplete or argcomplete3. "\
"Argument completion will not work..."
fi
fi
echo "Installed AMD-SMI python library (amdsmi)..."
}

# post install or upgrade, $i is 1 or 2 -> do these actions
Expand Down
32 changes: 12 additions & 20 deletions RPM/preun.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

rm_leftovers() {
# remove pyc files generated by python
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__"
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__"

# remove leftover doc files
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/
# remove build and egg files
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi.egg-info"
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/build"

# remove leftover libs
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so*
# remove leftover doc files
if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*"; then
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*"
fi
}

rm_logFolder() {
Expand All @@ -33,7 +35,6 @@ return_logrotateToOrigConfig() {
}

rm_python_lib() {
echo "Removing AMD-SMI python library (amdsmi)..."
# get python version
local python3_minor_version
python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)')
Expand All @@ -55,26 +56,17 @@ rm_python_lib() {
pip_list_output=$(python3 -m pip list --disable-pip-version-check)
# check pip list output for amdsmi
if [[ $pip_list_output == *"amdsmi"* ]]; then
local PREVIOUS_PIP_ROOT_ACTION="$PIP_ROOT_USER_ACTION"
export PIP_ROOT_USER_ACTION=ignore

echo "Detected AMD-SMI python library (amdsmi)..."
python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
echo "Removed AMD-SMI python library (amdsmi)..."

unset PIP_ROOT_USER_ACTION
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_ACTION"
PIP_ROOT_USER_ACTION=ignore PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
fi

local pip_list_output
pip_list_output=$(python3 -m pip list --disable-pip-version-check)
# check pip list output for amdsmi
if [[ $pip_list_output == *"amdsmi"* ]]; then
echo "[WARNING] AMD-SMI python library (amdsmi) is still installed in pip. "\
"Check post install to ensure version is correct"
return
else
echo "Removed AMD-SMI python library (amdsmi)..."
fi
echo "Removed AMD-SMI python library (amdsmi)..."
}


Expand Down
Loading

0 comments on commit 3f96bd1

Please sign in to comment.