From cb0912cde66a4eaea1b86734a2f443ff8e36e3de Mon Sep 17 00:00:00 2001 From: Jeff Daily Date: Tue, 31 Jan 2023 13:47:21 -0800 Subject: [PATCH] [ROCm] reduce disk space used in image (#1288) Fixes https://github.com/pytorch/builder/issues/1286 --- common/install_miopen.sh | 32 +++++++++++++++++++++++--------- common/install_rocm_magma.sh | 5 ++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/common/install_miopen.sh b/common/install_miopen.sh index 92ffb35dc..b526cbe20 100644 --- a/common/install_miopen.sh +++ b/common/install_miopen.sh @@ -33,8 +33,9 @@ if [[ $ROCM_INT -lt 40001 ]]; then exit 0 fi +# CHANGED: Do not uninstall. To avoid out of disk space issues, we will copy lib over existing. # Uninstall existing package, to avoid errors during later yum install indicating packages did not change. -yum remove -y miopen-hip +#yum remove -y miopen-hip # Function to retry functions that sometimes timeout or have flaky failures retry () { @@ -88,7 +89,9 @@ fi git clone https://github.com/ROCmSoftwarePlatform/MIOpen -b ${MIOPEN_BRANCH} pushd MIOpen -# Don't build MLIR to save docker build time +# remove .git to save disk space ince CI runner was running out +rm -rf .git +# Don't build MLIR to save docker build time # since we are disabling MLIR backend for MIOpen anyway if [[ $ROCM_INT -ge 50400 ]] && [[ $ROCM_INT -lt 50500 ]]; then sed -i '/rocMLIR/d' requirements.txt @@ -97,6 +100,14 @@ elif [[ $ROCM_INT -ge 50200 ]] && [[ $ROCM_INT -lt 50400 ]]; then fi ## MIOpen minimum requirements cmake -P install_deps.cmake --minimum + +# clean up since CI runner was running out of disk space +rm -rf /tmp/* +yum clean all +rm -rf /var/cache/yum +rm -rf /var/lib/yum/yumdb +rm -rf /var/lib/yum/history + ## Build MIOpen mkdir -p build cd build @@ -105,16 +116,19 @@ PKG_CONFIG_PATH=/usr/local/lib/pkgconfig CXX=${ROCM_INSTALL_PATH}/llvm/bin/clang ${MIOPEN_CMAKE_DB_FLAGS} \ -DCMAKE_PREFIX_PATH="${ROCM_INSTALL_PATH}/hip;${ROCM_INSTALL_PATH}" make MIOpen -j $(nproc) -make -j $(nproc) package + +# CHANGED: Do not build package. +# Build MIOpen package +#make -j $(nproc) package # clean up since CI runner was running out of disk space rm -rf /usr/local/cget -rm -rf /tmp/* -yum clean all -rm -rf /var/cache/yum -rm -rf /var/lib/yum/yumdb -rm -rf /var/lib/yum/history -yum install -y miopen-*.rpm +# CHANGED: Do not install package, just copy lib over existing. +#yum install -y miopen-*.rpm +dest=$(ls ${ROCM_INSTALL_PATH}/lib/libMIOpen.so.1.0.*) +rm -f ${dest} +cp lib/libMIOpen.so.1.0 ${dest} + popd rm -rf MIOpen diff --git a/common/install_rocm_magma.sh b/common/install_rocm_magma.sh index c651a6e4e..00540fbec 100644 --- a/common/install_rocm_magma.sh +++ b/common/install_rocm_magma.sh @@ -37,5 +37,8 @@ make -f make.gen.hipMAGMA -j $(nproc) LANG=C.UTF-8 make lib/libmagma.so -j $(nproc) MKLROOT="${MKLROOT}" make testing/testing_dgemm -j $(nproc) MKLROOT="${MKLROOT}" popd -mv magma /opt/rocm +mkdir -p /opt/rocm/magma +mv magma/include /opt/rocm/magma +mv magma/lib /opt/rocm/magma +rm -rf magma