[SWDEV-482058] Updated Packaging for offline installs

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


[ROCm/amdsmi commit: 2cfae06560]
This commit is contained in:
Maisam Arif
2024-09-19 23:55:12 -05:00
rodzic 90c854ad72
commit f1eae9f051
8 zmienionych plików z 57 dodań i 62 usunięć
+2
Wyświetl plik
@@ -289,6 +289,8 @@ With this change additional padding was added to PCIE_BW `amd-smi monitor --pcie
### Resolved issues
- **Improved Offline install process & lowered dependency for PyYAML**.
- **Fixed CPX not showing total number of logical GPUs**.
Updates were made to `amdsmi_init()` and `amdsmi_get_gpu_bdf_id(..)`. In order to display all logical devices, we needed a way to provide order to GPU's enumerated. This was done
by adding a partition_id within the BDF optional pci_id bits.
+18 -27
Wyświetl plik
@@ -159,6 +159,24 @@ do_install_amdsmi_python_lib() {
fi
unset pip_version
# Install setuptools wheel (offline install)
echo "Checking for amdsmi_offline.tar.gz..."
offline_packages_tar_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/amdsmi_offline.tar.gz
if [ -z "$offline_packages_tar_path" ]; then
echo "Error: amdsmi_offline.tar.gz not found. Not installing amdsmi offline packages..."
else
echo "Extracting amdsmi_offline.tar.gz..."
offline_packages_target_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/
tar -xzvf $offline_packages_tar_path -C $offline_packages_target_path
offline_packages_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/offline_packages
echo "Installing/Upgrading amdsmi offline packages..."
python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links="$offline_packages_path" setuptools
unset offline_packages_path
unset offline_packages_target_path
fi
unset offline_packages_tar_path
# Check PyYAML dependency, typically should not execute
pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]')
if [[ "$pyyaml_version" -lt 3 ]]; then
@@ -167,33 +185,6 @@ do_install_amdsmi_python_lib() {
fi
unset pyyaml_version
# Install setuptools wheel (offline install)
# Function to find the tarball
find_tarball() {
find / -name "amdsmi_offline.tar.gz" 2>/dev/null | head -n 1
}
# Locate the tarball
tarball_path=$(find_tarball)
if [ -z "$tarball_path" ]; then
echo "Error: amdsmi_offline.tar.gz not found."
exit 1
fi
# Extract directory from tarball path
base_dir=$(dirname "$tarball_path")
# Navigate to the directory containing the tarball
cd "$base_dir" || exit
# Unpack the tarball
tar -xzvf amdsmi_offline.tar.gz
# Install setuptools offline (if needed)
cd offline_packages || exit
python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links=. setuptools
# install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi
local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@
python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check --no-build-isolation
+5 -1
Wyświetl plik
@@ -13,9 +13,13 @@ 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__"
# remove CLI folder packages folder
if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*"; then
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*"
fi
# 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"
+19 -28
Wyświetl plik
@@ -158,7 +158,25 @@ do_install_amdsmi_python_lib() {
fi
unset pip_version
# Check PyYAML dependency
# Install setuptools wheel (offline install)
echo "Checking for amdsmi_offline.tar.gz..."
offline_packages_tar_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/amdsmi_offline.tar.gz
if [ -z "$offline_packages_tar_path" ]; then
echo "Error: amdsmi_offline.tar.gz not found. Not installing amdsmi offline packages..."
else
echo "Extracting amdsmi_offline.tar.gz..."
offline_packages_target_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/
tar -xzvf $offline_packages_tar_path -C $offline_packages_target_path
offline_packages_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/offline_packages
echo "Installing/Upgrading amdsmi offline packages..."
python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links="$offline_packages_path" setuptools
unset offline_packages_path
unset offline_packages_target_path
fi
unset offline_packages_tar_path
# Check PyYAML dependency, typically should not execute
local pyyaml_version
pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]')
if [[ "$pyyaml_version" -lt 3 ]]; then
@@ -167,33 +185,6 @@ do_install_amdsmi_python_lib() {
fi
unset pyyaml_version
# Install setuptools wheel (offline install)
# Function to find the tarball
find_tarball() {
find / -name "amdsmi_offline.tar.gz" 2>/dev/null | head -n 1
}
# Locate the tarball
tarball_path=$(find_tarball)
if [ -z "$tarball_path" ]; then
echo "Error: amdsmi_offline.tar.gz not found."
exit 1
fi
# Extract directory from tarball path
base_dir=$(dirname "$tarball_path")
# Navigate to the directory containing the tarball
cd "$base_dir" || exit
# Unpack the tarball
tar -xzvf amdsmi_offline.tar.gz
# Install setuptools offline (if needed)
cd offline_packages || exit
python3 -m pip install --upgrade --upgrade-strategy only-if-needed --no-index --find-links=. setuptools
# install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi
local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@
python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check --no-build-isolation
+5 -1
Wyświetl plik
@@ -2,9 +2,13 @@
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__"
# remove CLI folder packages folder
if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*"; then
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli*"
fi
# 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"
@@ -24,6 +24,7 @@ add_custom_command(
${PY_PACKAGE_DIR}/amdsmi_cli_exceptions.py
${PY_PACKAGE_DIR}/rocm_version.py
${PY_PACKAGE_DIR}/BDF.py
${PY_PACKAGE_DIR}/amdsmi_offline.tar.gz
${PY_PACKAGE_DIR}/README.md
${PY_PACKAGE_DIR}/Release_Notes.md
DEPENDS amdsmi_cli
@@ -38,6 +39,7 @@ add_custom_command(
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli_exceptions.py ${PY_PACKAGE_DIR}/
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.py ${PY_PACKAGE_DIR}/
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/BDF.py ${PY_PACKAGE_DIR}/
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_offline.tar.gz ${PY_PACKAGE_DIR}/
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${PY_PACKAGE_DIR}/
COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/Release_Notes.md ${PY_PACKAGE_DIR}/)
@@ -56,6 +58,7 @@ add_custom_target(
${PY_PACKAGE_DIR}/amdsmi_cli_exceptions.py
${PY_PACKAGE_DIR}/rocm_version.py
${PY_PACKAGE_DIR}/BDF.py
${PY_PACKAGE_DIR}/amdsmi_offline.tar.gz
${PY_PACKAGE_DIR}/README.md
${PY_PACKAGE_DIR}/Release_Notes.md)
@@ -37,7 +37,7 @@ import amdsmi_cli_exceptions
class CustomDumper(yaml.Dumper):
def represent_dict_preserve_order(self, data):
return self.represent_dict(data.items())
def has_sort_keys_option(): # to check if sort_keys is available
def has_sort_keys_option(): # to check if sort_keys is available
return 'sort_keys' in inspect.signature(yaml.dump).parameters
class AMDSMILogger():
@@ -212,14 +212,14 @@ class AMDSMILogger():
json_string = json.dumps(capitalized_json, indent=4)
if has_sort_keys_option():
if has_sort_keys_option():
yaml_data = yaml.safe_load(json_string)
yaml_output = yaml.dump(yaml_data, sort_keys=False, allow_unicode=True)
else:
yaml_output = yaml.dump(yaml_data, sort_keys=False, allow_unicode=True)
else:
CustomDumper.add_representer(dict, CustomDumper.represent_dict_preserve_order)
yaml_data = yaml.safe_load(json_string)
yaml_output = yaml.dump(yaml_data, Dumper=CustomDumper, allow_unicode=True, default_flow_style=False)
# Remove a key line if it is a spacer
yaml_output = yaml_output.replace("AMDSMI_SPACING_REMOVAL:\n", "")
yaml_output = yaml_output.replace("'", "") # Remove ''
Plik binarny nie jest wyświetlany.