From edf579d9920cc84785e62a32f5f460c96abdc62c Mon Sep 17 00:00:00 2001 From: Cole Ramos Date: Fri, 3 May 2024 15:01:10 -0500 Subject: [PATCH] Optimizing Dockerfiles and buildscripts (#359) * Optimizing Dockerfiles and buildscripts Signed-off-by: coleramos425 * Give docker scripts exe permission Signed-off-by: coleramos425 --------- Signed-off-by: coleramos425 [ROCm/rocprofiler-compute commit: bf9176c1aec81e75530556387dad0b942325855a] --- .../docker/Dockerfile.opensuse | 54 ++++ .../docker/Dockerfile.opensuse.ci | 48 ++++ .../docker/Dockerfile.rhel | 52 ++++ .../docker/Dockerfile.rhel.ci | 42 +++ .../docker/Dockerfile.ubuntu | 57 ++++ .../docker/Dockerfile.ubuntu.ci | 48 ++++ .../docker/build-docker-ci.sh | 154 ++++++++++ .../docker/build-docker.sh | 272 ++++++++++++++++++ .../docker/rhel8/Dockerfile | 14 - .../docker/rhel8/rocm.repo | 13 - .../docker/sle15sp3/Dockerfile | 12 - .../docker/sle15sp3/amdgpu.repo | 13 - .../docker/ubuntu20.04/Dockerfile | 15 - 13 files changed, 727 insertions(+), 67 deletions(-) create mode 100644 projects/rocprofiler-compute/docker/Dockerfile.opensuse create mode 100644 projects/rocprofiler-compute/docker/Dockerfile.opensuse.ci create mode 100644 projects/rocprofiler-compute/docker/Dockerfile.rhel create mode 100644 projects/rocprofiler-compute/docker/Dockerfile.rhel.ci create mode 100644 projects/rocprofiler-compute/docker/Dockerfile.ubuntu create mode 100644 projects/rocprofiler-compute/docker/Dockerfile.ubuntu.ci create mode 100755 projects/rocprofiler-compute/docker/build-docker-ci.sh create mode 100755 projects/rocprofiler-compute/docker/build-docker.sh delete mode 100644 projects/rocprofiler-compute/docker/rhel8/Dockerfile delete mode 100644 projects/rocprofiler-compute/docker/rhel8/rocm.repo delete mode 100644 projects/rocprofiler-compute/docker/sle15sp3/Dockerfile delete mode 100644 projects/rocprofiler-compute/docker/sle15sp3/amdgpu.repo delete mode 100644 projects/rocprofiler-compute/docker/ubuntu20.04/Dockerfile diff --git a/projects/rocprofiler-compute/docker/Dockerfile.opensuse b/projects/rocprofiler-compute/docker/Dockerfile.opensuse new file mode 100644 index 0000000000..77dbe6196b --- /dev/null +++ b/projects/rocprofiler-compute/docker/Dockerfile.opensuse @@ -0,0 +1,54 @@ +ARG DISTRO=opensuse/leap +ARG VERSION=15.3 +FROM ${DISTRO}:${VERSION} + +ENV HOME /root +ENV SHELL /bin/bash +ENV BASH_ENV /etc/bash.bashrc +ENV DEBIAN_FRONTEND noninteractive + +WORKDIR /tmp +SHELL [ "/bin/bash", "-c" ] + +ENV PATH /usr/local/bin:${PATH} +ENV LIBRARY_PATH ${LIBRARY_PATH}:/opt/amdgpu/lib64 + +RUN set +e; \ + zypper --non-interactive -i --gpg-auto-import-keys refresh; \ + zypper --non-interactive -i patch; \ + zypper --non-interactive -i patch; \ + zypper --non-interactive -i --gpg-auto-import-keys refresh; \ + exit 0 + +RUN zypper --non-interactive update -y && \ + zypper --non-interactive dist-upgrade -y && \ + zypper --non-interactive install -y -t pattern devel_basis && \ + zypper --non-interactive install -y python3-pip gcc-c++ git dpkg-devel rpm-build wget curl binutils-gold && \ + python3 -m pip install 'cmake==3.28.4' + +ARG ROCM_VERSION=0.0 +ARG AMDGPU_RPM=latest/sle/15/amdgpu-install-21.50.50000-1.noarch.rpm +ARG PERL_REPO=SLE_15 + +RUN if [ "${ROCM_VERSION}" != "0.0" ]; then \ + zypper --non-interactive addrepo https://mirrorcache-us.opensuse.org/repositories/devel:/languages:/perl/${PERL_REPO}/devel:languages:perl.repo && \ + zypper --non-interactive --no-gpg-checks install -y https://repo.radeon.com/amdgpu-install/${AMDGPU_RPM} && \ + zypper --non-interactive --gpg-auto-import-keys refresh && \ + zypper --non-interactive install -y rocm-dev rocm-smi-lib roctracer-dev rocprofiler-dev rccl-devel libpciaccess0 && \ + zypper --non-interactive clean --all; \ + fi + +ARG PYTHON_VERSIONS="6 7 8 9 10 11 12" + +RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + export PATH="/opt/conda/bin:${PATH}" && \ + conda config --set always_yes yes --set changeps1 no && \ + conda update -c defaults -n base conda && \ + for i in ${PYTHON_VERSIONS}; do conda create -n py3.${i} -c defaults -c conda-forge python=3.${i} pip; done && \ + for i in ${PYTHON_VERSIONS}; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done && \ + conda clean -a -y && \ + conda init + +WORKDIR /home +SHELL [ "/bin/bash", "--login", "-c" ] \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/Dockerfile.opensuse.ci b/projects/rocprofiler-compute/docker/Dockerfile.opensuse.ci new file mode 100644 index 0000000000..5dc94ef055 --- /dev/null +++ b/projects/rocprofiler-compute/docker/Dockerfile.opensuse.ci @@ -0,0 +1,48 @@ +ARG DISTRO=opensuse/leap +ARG VERSION=15.3 +FROM ${DISTRO}:${VERSION} + +ENV HOME /root +ENV SHELL /bin/bash +ENV BASH_ENV /etc/bash.bashrc +ENV DEBIAN_FRONTEND noninteractive + +WORKDIR /tmp +SHELL [ "/bin/bash", "-c" ] + +ENV PATH /usr/local/bin:${PATH} + +ARG EXTRA_PACKAGES="" +# ARG ELFUTILS_DOWNLOAD_VERSION="0.186" +# ARG NJOBS="12" + +RUN set +e; \ + zypper --non-interactive -i --gpg-auto-import-keys refresh; \ + zypper --non-interactive -i patch; \ + zypper --non-interactive -i patch; \ + zypper --non-interactive -i --gpg-auto-import-keys refresh; \ + exit 0 + +RUN zypper --non-interactive update -y && \ + zypper --non-interactive dist-upgrade -y && \ + zypper --non-interactive install -y -t pattern devel_basis && \ + zypper --non-interactive install -y python3-pip gcc-c++ git dpkg-devel rpm-build curl wget binutils-gold && \ + python3 -m pip install 'cmake==3.28.4' && \ + zypper --non-interactive clean --all + +ARG PYTHON_VERSIONS="6 7 8 9 10 11 12" + +RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + export PATH="/opt/conda/bin:${PATH}" && \ + conda config --set always_yes yes --set changeps1 no && \ + conda update -c defaults -n base conda && \ + for i in ${PYTHON_VERSIONS}; do conda create -n py3.${i} -c defaults -c conda-forge python=3.${i} pip numpy; done && \ + for i in ${PYTHON_VERSIONS}; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy pandas dataclasses; done && \ + conda clean -a -y && \ + cd /tmp && \ + shopt -s dotglob extglob && \ + rm -rf * + +WORKDIR /home +SHELL [ "/bin/bash", "--login", "-c" ] diff --git a/projects/rocprofiler-compute/docker/Dockerfile.rhel b/projects/rocprofiler-compute/docker/Dockerfile.rhel new file mode 100644 index 0000000000..e614dc0681 --- /dev/null +++ b/projects/rocprofiler-compute/docker/Dockerfile.rhel @@ -0,0 +1,52 @@ +ARG DISTRO=rockylinux +ARG VERSION=8 +FROM ${DISTRO}:${VERSION} + +ENV HOME /root +ENV SHELL /bin/bash +ENV BASH_ENV /etc/bash.bashrc +ENV DEBIAN_FRONTEND noninteractive + +WORKDIR /tmp +SHELL [ "/bin/bash", "-c" ] + +ENV PATH /usr/local/bin:${PATH} +ENV LIBRARY_PATH ${LIBRARY_PATH}:/opt/amdgpu/lib64 + +RUN yum groupinstall -y "Development Tools" && \ + yum install -y epel-release && \ + yum install -y --allowerasing curl dpkg-devel python3-pip wget zlib-devel which && \ + yum clean all && \ + python3 -m pip install 'cmake==3.28.4' + +ARG ROCM_VERSION=0.0 +ARG AMDGPU_RPM=5.4/rhel/8.7/amdgpu-install-5.4.50400-1.el8.noarch.rpm + +RUN if [ "${ROCM_VERSION}" != "0.0" ]; then \ + OS_VERSION_MAJOR=$(cat /etc/os-release | grep 'VERSION_ID' | sed 's/=/ /1' | awk '{print $NF}' | sed 's/"//g' | sed 's/\./ /g' | awk '{print $1}') && \ + if [ "${OS_VERSION_MAJOR}" -eq 8 ]; then PERL_REPO=powertools; else PERL_REPO=crb; fi && \ + dnf -y --enablerepo=${PERL_REPO} install perl-File-BaseDir && \ + yum install -y https://repo.radeon.com/amdgpu-install/${AMDGPU_RPM} && \ + yum install -y rocm-dev rocm-smi-lib roctracer-dev rocprofiler-dev libpciaccess && \ + yum clean all; \ + fi + +ARG PYTHON_VERSIONS="6 7 8 9 10 11 12" + +RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + export PATH="/opt/conda/bin:${PATH}" && \ + conda config --set always_yes yes --set changeps1 no && \ + conda update -c defaults -n base conda && \ + for i in ${PYTHON_VERSIONS}; do conda create -n py3.${i} -c defaults -c conda-forge python=3.${i} pip; done && \ + for i in ${PYTHON_VERSIONS}; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done && \ + conda clean -a -y && \ + conda init + +RUN if [ "${ROCM_VERSION}" != "0.0" ]; then ln -sf /opt/rocm-${ROCM_VERSION}* /opt/rocm; fi + +WORKDIR /home +ENV LC_ALL C.UTF-8 +SHELL [ "/bin/bash", "--login", "-c" ] +COPY ./entrypoint-rhel.sh /docker-entrypoint.sh +ENTRYPOINT [ "/docker-entrypoint.sh" ] \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/Dockerfile.rhel.ci b/projects/rocprofiler-compute/docker/Dockerfile.rhel.ci new file mode 100644 index 0000000000..c07738fe92 --- /dev/null +++ b/projects/rocprofiler-compute/docker/Dockerfile.rhel.ci @@ -0,0 +1,42 @@ + +ARG DISTRO=rockylinux +ARG VERSION=8 +FROM ${DISTRO}:${VERSION} + +ENV HOME /root +ENV SHELL /bin/bash +ENV BASH_ENV /etc/bash.bashrc +ENV DEBIAN_FRONTEND noninteractive + +WORKDIR /tmp +SHELL [ "/bin/bash", "-c" ] + +ENV PATH /usr/local/bin:${PATH} + +ARG EXTRA_PACKAGES="" +# ARG ELFUTILS_DOWNLOAD_VERSION="0.186" +# ARG NJOBS="12" + +RUN yum groupinstall -y "Development Tools" && \ + yum install -y epel-release && \ + yum install -y --allowerasing curl dpkg-devel python3-pip wget zlib-devel which git && \ + yum clean all && \ + python3 -m pip install --upgrade pip && \ + python3 -m pip install 'cmake==3.28.4' + +ARG PYTHON_VERSIONS="6 7 8 9 10 11 12" + +RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + export PATH="/opt/conda/bin:${PATH}" && \ + conda config --set always_yes yes --set changeps1 no && \ + conda update -c defaults -n base conda && \ + for i in ${PYTHON_VERSIONS}; do conda create -n py3.${i} -c defaults -c conda-forge python=3.${i} pip numpy; done && \ + for i in ${PYTHON_VERSIONS}; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy pandas dataclasses; done && \ + conda clean -a -y && \ + cd /tmp && \ + shopt -s dotglob extglob && \ + rm -rf * + +WORKDIR /home +SHELL [ "/bin/bash", "--login", "-c" ] diff --git a/projects/rocprofiler-compute/docker/Dockerfile.ubuntu b/projects/rocprofiler-compute/docker/Dockerfile.ubuntu new file mode 100644 index 0000000000..d1fcc8ebab --- /dev/null +++ b/projects/rocprofiler-compute/docker/Dockerfile.ubuntu @@ -0,0 +1,57 @@ +ARG DISTRO +ARG VERSION +FROM ${DISTRO}:${VERSION} + +ENV HOME /root +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US +ENV LC_ALL C +ENV SHELL /bin/bash +ENV BASH_ENV /etc/bash.bashrc +ENV DEBIAN_FRONTEND noninteractive + +WORKDIR /tmp +SHELL [ "/bin/bash", "-c" ] + +ARG EXTRA_PACKAGES="" +ARG ROCM_REPO_VERSION="debian" +ARG ROCM_VERSION="0.0" +ARG ROCM_REPO_DIST="ubuntu" +ARG PYTHON_VERSIONS="6 7 8 9 10 11 12" +ENV PATH ${HOME}/.local/bin:${PATH} + +RUN apt-get update && \ + apt-get dist-upgrade -y && \ + apt-get install -y build-essential cmake libnuma1 wget gnupg2 m4 bash-completion git-core autoconf libtool autotools-dev python3-pip lsb-release libpapi-dev libpfm4-dev libudev1 libopenmpi-dev rpm librpm-dev curl apt-utils && \ + python3 -m pip install 'cmake==3.28.4' + +RUN if [ "${ROCM_VERSION}" != "0.0" ]; then \ + if [ -d /etc/apt/trusted.gpg.d ]; then \ + wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor > /etc/apt/trusted.gpg.d/rocm.gpg; \ + else \ + wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add -; \ + fi && \ + echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${ROCM_REPO_VERSION}/ ${ROCM_REPO_DIST} main" | tee /etc/apt/sources.list.d/rocm.list && \ + apt-get update && \ + apt-get dist-upgrade -y && \ + apt-get install -y hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev && \ + apt-get install -y hip-base hip-runtime-amd hip-dev && \ + apt-get install -y rocm-llvm rocm-core rocm-smi-lib rocm-device-libs && \ + apt-get install -y roctracer-dev rocprofiler-dev rccl-dev ${EXTRA_PACKAGES} && \ + if [ "$(echo ${ROCM_VERSION} | awk -F '.' '{print $1}')" -lt "5" ]; then apt-get install -y rocm-dev; fi && \ + apt-get autoclean; \ + fi + +RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + export PATH="/opt/conda/bin:${PATH}" && \ + conda config --set always_yes yes --set changeps1 no && \ + conda update -c defaults -n base conda && \ + for i in ${PYTHON_VERSIONS}; do conda create -n py3.${i} -c defaults -c conda-forge python=3.${i} pip; done && \ + for i in ${PYTHON_VERSIONS}; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done && \ + conda clean -a -y && \ + conda init + +ENV LC_ALL C.UTF-8 +WORKDIR /home +SHELL [ "/bin/bash", "--login", "-c" ] \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/Dockerfile.ubuntu.ci b/projects/rocprofiler-compute/docker/Dockerfile.ubuntu.ci new file mode 100644 index 0000000000..ce2e343984 --- /dev/null +++ b/projects/rocprofiler-compute/docker/Dockerfile.ubuntu.ci @@ -0,0 +1,48 @@ + +ARG DISTRO +ARG VERSION +FROM ${DISTRO}:${VERSION} + +ENV HOME /root +ENV LANG C.UTF-8 +ENV SHELL /bin/bash +ENV BASH_ENV /etc/bash.bashrc +ENV DEBIAN_FRONTEND noninteractive + +WORKDIR /tmp +SHELL [ "/bin/bash", "-c" ] + +ARG EXTRA_PACKAGES="" +# ARG ELFUTILS_DOWNLOAD_VERSION="0.186" +# ARG BOOST_DOWNLOAD_VERSION="1.79.0" +# ARG NJOBS="12" +ARG PYTHON_VERSIONS="6 7 8 9 10 11 12" + +ENV PATH /usr/local/bin:${PATH} +ENV LIBRARY_PATH /usr/local/lib:/usr/local/lib64:${LIBRARY_PATH} +ENV LD_LIBRARY_PATH /usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH} +ENV CMAKE_PREFIX_PATH /usr/local:${CMAKE_PREFIX_PATH} + + +RUN apt-get update && \ + apt-get dist-upgrade -y && \ + apt-get install -y autoconf autotools-dev bash-completion build-essential bzip2 cmake curl environment-modules git-core gnupg2 gzip libtool locales lsb-release m4 python3-pip unzip wget zip zlib1g-dev && \ + python3 -m pip install 'cmake==3.28.4' && \ + apt-get autoclean && \ + locale -a && \ + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p /opt/conda && \ + export PATH="/opt/conda/bin:${PATH}" && \ + conda config --set always_yes yes --set changeps1 no && \ + conda update -c defaults -n base conda && \ + for i in ${PYTHON_VERSIONS}; do conda create -n py3.${i} -c defaults -c conda-forge python=3.${i} pip numpy; done && \ + for i in ${PYTHON_VERSIONS}; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy pandas dataclasses; done && \ + conda clean -a -y && \ + cd /tmp && \ + shopt -s dotglob extglob && \ + rm -rf * + + +ENV LC_ALL C.UTF-8 +WORKDIR /home +SHELL [ "/bin/bash", "--login", "-c" ] \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/build-docker-ci.sh b/projects/rocprofiler-compute/docker/build-docker-ci.sh new file mode 100755 index 0000000000..8c7029e890 --- /dev/null +++ b/projects/rocprofiler-compute/docker/build-docker-ci.sh @@ -0,0 +1,154 @@ +#!/usr/bin/env bash + +set -e + +: ${USER:=$(whoami)} +: ${DISTRO:=ubuntu} +: ${VERSIONS:=20.04} +# : ${NJOBS=$(nproc)} +# : ${ELFUTILS_VERSION:=0.186} +# : ${BOOST_VERSION:=1.79.0} +: ${PYTHON_VERSIONS:="6 7 8 9 10 11 12"} +: ${PUSH:=0} +: ${PULL:=--pull} + +verbose-run() +{ + echo -e "\n### Executing \"${@}\"... ###\n" + eval $@ +} + +tolower() +{ + echo "$@" | awk -F '\\|~\\|' '{print tolower($1)}'; +} + +toupper() +{ + echo "$@" | awk -F '\\|~\\|' '{print toupper($1)}'; +} + +usage() +{ + print_option() { printf " --%-20s %-24s %s\n" "${1}" "${2}" "${3}"; } + echo "Options:" + print_option "help -h" "" "This message" + print_option "push" "" "Push the container to DockerHub when completed" + print_option "no-pull" "" "Do not pull down most recent base container" + + echo "" + print_default_option() { printf " --%-20s %-24s %s (default: %s)\n" "${1}" "${2}" "${3}" "$(tolower ${4})"; } + print_default_option distro "[ubuntu|opensuse|rhel]" "OS distribution" "${DISTRO}" + print_default_option versions "[VERSION] [VERSION...]" "Ubuntu, OpenSUSE, or RHEL release" "${VERSIONS}" + print_default_option python-versions "[VERSION] [VERSION...]" "Python 3 minor releases" "${PYTHON_VERSIONS}" + # print_default_option "jobs -j" "[N]" "parallel build jobs" "${NJOBS}" + # print_default_option elfutils-version "[0.183..0.186]" "ElfUtils version" "${ELFUTILS_VERSION}" + # print_default_option boost-version "[1.67.0..1.79.0]" "Boost version" "${BOOST_VERSION}" + print_default_option user "[USERNAME]" "DockerHub username" "${USER}" +} + +send-error() +{ + usage + echo -e "\nError: ${@}" + exit 1 +} + +reset-last() +{ + last() { send-error "Unsupported argument :: ${1}"; } +} + +reset-last + +n=0 +while [[ $# -gt 0 ]] +do + case "${1}" in + -h|--help) + usage + exit 0 + ;; + "--distro") + shift + DISTRO=${1} + last() { DISTRO="${DISTRO} ${1}"; } + ;; + "--versions") + shift + VERSIONS=${1} + last() { VERSIONS="${VERSIONS} ${1}"; } + ;; + "--python-versions") + shift + PYTHON_VERSIONS=${1} + last() { PYTHON_VERSIONS="${PYTHON_VERSIONS} ${1}"; } + ;; + --user|-u) + shift + USER=${1} + reset-last + ;; + "--push") + PUSH=1 + reset-last + ;; + "--no-pull") + PULL="" + reset-last + ;; + --*) + reset-last + last ${1} + ;; + *) + last ${1} + ;; + esac + n=$((${n} + 1)) + shift +done + +DOCKER_FILE=Dockerfile.${DISTRO}.ci + +if [ ! -f ${DOCKER_FILE} ]; then cd docker; fi + +if [ ! -f ${DOCKER_FILE} ]; then + echo "Error! Execute script from source directory" + exit 1 +fi + +# verbose-run rm -rf ./dyninst-source +# verbose-run cp -r ../external/dyninst ./dyninst-source +# verbose-run rm -rf ./dyninst-source/{build,install}* + +set -e + +if [ "${DISTRO}" = "opensuse" ]; then + DISTRO_IMAGE="opensuse/leap" +elif [ "${DISTRO}" = "rhel" ]; then + DISTRO_IMAGE="rockylinux" +else + DISTRO_IMAGE=${DISTRO} +fi + +for VERSION in ${VERSIONS} +do + verbose-run docker build . \ + ${PULL} \ + -f ${DOCKER_FILE} \ + --tag ${USER}/omniperf:ci-base-${DISTRO}-${VERSION} \ + --build-arg DISTRO=${DISTRO_IMAGE} \ + --build-arg VERSION=${VERSION} \ + --build-arg PYTHON_VERSIONS=\"${PYTHON_VERSIONS}\" + # --build-arg NJOBS=${NJOBS} \ + # --build-arg ELFUTILS_DOWNLOAD_VERSION=${ELFUTILS_VERSION} \ + # --build-arg BOOST_DOWNLOAD_VERSION=${BOOST_VERSION} +done + +if [ "${PUSH}" -gt 0 ]; then + for VERSION in ${VERSIONS} + do + verbose-run docker push ${USER}/omniperf:ci-base-${DISTRO}-${VERSION} + done +fi \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/build-docker.sh b/projects/rocprofiler-compute/docker/build-docker.sh new file mode 100755 index 0000000000..5d6f2d181d --- /dev/null +++ b/projects/rocprofiler-compute/docker/build-docker.sh @@ -0,0 +1,272 @@ +#!/usr/bin/env bash + +: ${USER:=$(whoami)} +: ${ROCM_VERSIONS:="5.0"} +: ${DISTRO:=ubuntu} +: ${VERSIONS:=20.04} +: ${PYTHON_VERSIONS:="6 7 8 9 10 11 12"} +: ${BUILD_CI:=""} +: ${PUSH:=0} +: ${PULL:=--pull} +: ${RETRY:=3} + +set -e + +tolower() +{ + echo "$@" | awk -F '\\|~\\|' '{print tolower($1)}'; +} + +toupper() +{ + echo "$@" | awk -F '\\|~\\|' '{print toupper($1)}'; +} + +usage() +{ + print_option() { printf " --%-20s %-24s %s\n" "${1}" "${2}" "${3}"; } + echo "Options:" + print_option "help -h" "" "This message" + print_option "no-pull" "" "Do not pull down most recent base container" + + echo "" + print_default_option() { printf " --%-20s %-24s %s (default: %s)\n" "${1}" "${2}" "${3}" "$(tolower ${4})"; } + print_default_option distro "[ubuntu|opensuse|rhel]" "OS distribution" "${DISTRO}" + print_default_option versions "[VERSION] [VERSION...]" "Ubuntu, OpenSUSE, or RHEL release" "${VERSIONS}" + print_default_option rocm-versions "[VERSION] [VERSION...]" "ROCm versions" "${ROCM_VERSIONS}" + print_default_option python-versions "[VERSION] [VERSION...]" "Python 3 minor releases" "${PYTHON_VERSIONS}" + print_default_option "user -u" "[USERNAME]" "DockerHub username" "${USER}" + print_default_option "retry -r" "[N]" "Number of attempts to build (to account for network errors)" "${RETRY}" + print_default_option push "" "Push the image to Dockerhub" "" + #print_default_option lto "[on|off]" "Enable LTO" "${LTO}" +} + +send-error() +{ + usage + echo -e "\nError: ${@}" + exit 1 +} + +verbose-run() +{ + echo -e "\n### Executing \"${@}\"... ###\n" + eval "${@}" +} + +verbose-build() +{ + echo -e "\n### Executing \"${@}\" a maximum of ${RETRY} times... ###\n" + for i in $(seq 1 1 ${RETRY}) + do + set +e + eval "${@}" + local RETC=$? + set -e + if [ "${RETC}" -eq 0 ]; then + break + else + echo -en "\n### Command failed with error code ${RETC}... " + if [ "${i}" -ne "${RETRY}" ]; then + echo -e "Retrying... ###\n" + sleep 3 + else + echo -e "Exiting... ###\n" + exit ${RETC} + fi + fi + done +} + +reset-last() +{ + last() { send-error "Unsupported argument :: ${1}"; } +} + +reset-last + +n=0 +while [[ $# -gt 0 ]] +do + case "${1}" in + -h|--help) + usage + exit 0 + ;; + "--distro") + shift + DISTRO=${1} + last() { DISTRO="${DISTRO} ${1}"; } + ;; + "--versions") + shift + VERSIONS=${1} + last() { VERSIONS="${VERSIONS} ${1}"; } + ;; + "--rocm-versions") + shift + ROCM_VERSIONS=${1} + last() { ROCM_VERSIONS="${ROCM_VERSIONS} ${1}"; } + ;; + "--python-versions") + shift + PYTHON_VERSIONS=${1} + last() { PYTHON_VERSIONS="${PYTHON_VERSIONS} ${1}"; } + ;; + --user|-u) + shift + USER=${1} + reset-last + ;; + --push) + PUSH=1 + reset-last + ;; + --no-pull) + PULL="" + reset-last + ;; + --retry|-r) + shift + RETRY=${1} + reset-last + ;; + "--*") + send-error "Unsupported argument at position $((${n} + 1)) :: ${1}" + ;; + *) + last ${1} + ;; + esac + n=$((${n} + 1)) + shift +done + +DOCKER_FILE="Dockerfile.${DISTRO}" + +if [ "${RETRY}" -lt 1 ]; then + RETRY=1 +fi + +if [ -n "${BUILD_CI}" ]; then DOCKER_FILE="${DOCKER_FILE}.ci"; fi +if [ ! -f ${DOCKER_FILE} ]; then cd docker; fi +if [ ! -f ${DOCKER_FILE} ]; then send-error "File \"${DOCKER_FILE}\" not found"; fi + +for VERSION in ${VERSIONS} +do + VERSION_MAJOR=$(echo ${VERSION} | sed 's/\./ /g' | awk '{print $1}') + VERSION_MINOR=$(echo ${VERSION} | sed 's/\./ /g' | awk '{print $2}') + VERSION_PATCH=$(echo ${VERSION} | sed 's/\./ /g' | awk '{print $3}') + for ROCM_VERSION in ${ROCM_VERSIONS} + do + CONTAINER=${USER}/omniperf:release-base-${DISTRO}-${VERSION}-rocm-${ROCM_VERSION} + ROCM_MAJOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $1}') + ROCM_MINOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $2}') + ROCM_PATCH=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $3}') + if [ -n "${ROCM_PATCH}" ]; then + ROCM_VERSN=$(( (${ROCM_MAJOR}*10000)+(${ROCM_MINOR}*100)+(${ROCM_PATCH}) )) + ROCM_SEP="." + else + ROCM_VERSN=$(( (${ROCM_MAJOR}*10000)+(${ROCM_MINOR}*100) )) + ROCM_SEP="" + fi + if [ "${DISTRO}" = "ubuntu" ]; then + ROCM_REPO_DIST="ubuntu" + ROCM_REPO_VERSION=${ROCM_VERSION} + case "${ROCM_VERSION}" in + 4.1* | 4.0*) + ROCM_REPO_DIST="xenial" + ;; + 5.3 | 5.3.* | 5.4 | 5.4.* | 5.5 | 5.5.* | 5.6 | 5.6.* | 5.7 | 5.7.* | 6.0 | 6.0.*) + case "${VERSION}" in + 22.04) + ROCM_REPO_DIST="ubuntu" + ;; + 20.04) + ROCM_REPO_DIST="focal" + ;; + 18.04) + ROCM_REPO_DIST="bionic" + ;; + *) + ;; + esac + ;; + *) + ;; + esac + echo + verbose-build docker build . ${PULL} --progress plain -f ${DOCKER_FILE} --tag ${CONTAINER} --build-arg DISTRO=${DISTRO} --build-arg VERSION=${VERSION} --build-arg ROCM_VERSION=${ROCM_VERSION} --build-arg ROCM_REPO_VERSION=${ROCM_REPO_VERSION} --build-arg ROCM_REPO_DIST=${ROCM_REPO_DIST} --build-arg PYTHON_VERSIONS=\"${PYTHON_VERSIONS}\" + elif [ "${DISTRO}" = "rhel" ]; then + if [ -z "${VERSION_MINOR}" ]; then + send-error "Please provide a major and minor version of the OS. Supported: >= 8.7, <= 9.3" + fi + + # Components used to create the sub-URL below + # set in amdgpu-install//rhel/ + RPM_PATH=${VERSION_MAJOR}.${VERSION_MINOR} + RPM_TAG=".el${VERSION_MAJOR}" + + # set the sub-URL in https://repo.radeon.com/amdgpu-install/ + case "${ROCM_VERSION}" in + 5.3 | 5.3.* | 5.4 | 5.4.* | 5.5 | 5.5.* | 5.6 | 5.6.* | 5.7 | 5.7.* | 6.0 | 6.0.*) + ROCM_RPM=${ROCM_VERSION}/rhel/${RPM_PATH}/amdgpu-install-${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1${RPM_TAG}.noarch.rpm + ;; + 5.2 | 5.2.* | 5.1 | 5.1.* | 5.0 | 5.0.* | 4.*) + send-error "Invalid ROCm version ${ROCM_VERSION}. Supported: >= 5.3.0, <= 5.5.x" + ;; + 0.0) + ;; + *) + send-error "Unsupported combination :: ${DISTRO}-${VERSION} + ROCm ${ROCM_VERSION}" + ;; + esac + + # use Rocky Linux as a base image for RHEL builds + DISTRO_BASE_IMAGE=rockylinux + + verbose-build docker build . ${PULL} --progress plain -f ${DOCKER_FILE} --tag ${CONTAINER} --build-arg DISTRO=${DISTRO_BASE_IMAGE} --build-arg VERSION=${VERSION} --build-arg ROCM_VERSION=${ROCM_VERSION} --build-arg AMDGPU_RPM=${ROCM_RPM} --build-arg PYTHON_VERSIONS=\"${PYTHON_VERSIONS}\" + elif [ "${DISTRO}" = "opensuse" ]; then + case "${VERSION}" in + 15.*) + DISTRO_IMAGE="opensuse/leap" + echo "DISTRO_IMAGE: ${DISTRO_IMAGE}" + ;; + *) + send-error "Invalid opensuse version ${VERSION}. Supported: 15.x" + ;; + esac + case "${ROCM_VERSION}" in + 5.3 | 5.3.* | 5.4 | 5.4.* | 5.5 | 5.5.* | 5.6 | 5.6.* | 5.7 | 5.7.* | 6.0 | 6.0.*) + ROCM_RPM=${ROCM_VERSION}/sle/${VERSION}/amdgpu-install-${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1.noarch.rpm + ;; + 5.2 | 5.2.*) + ROCM_RPM=22.20${ROCM_SEP}${ROCM_PATCH}/sle/${VERSION}/amdgpu-install-22.20.${ROCM_VERSN}-1.noarch.rpm + ;; + 5.1 | 5.1.*) + ROCM_RPM=22.10${ROCM_SEP}${ROCM_PATCH}/sle/15/amdgpu-install-22.10${ROCM_SEP}${ROCM_PATCH}.${ROCM_VERSN}-1.noarch.rpm + ;; + 5.0 | 5.0.*) + ROCM_RPM=21.50${ROCM_SEP}${ROCM_PATCH}/sle/15/amdgpu-install-21.50${ROCM_SEP}${ROCM_PATCH}.${ROCM_VERSN}-1.noarch.rpm + ;; + 4.5 | 4.5.*) + ROCM_RPM=21.40${ROCM_SEP}${ROCM_PATCH}/sle/15/amdgpu-install-21.40${ROCM_SEP}${ROCM_PATCH}.${ROCM_VERSN}-1.noarch.rpm + ;; + 0.0) + ;; + *) + send-error "Unsupported combination :: ${DISTRO}-${VERSION} + ROCm ${ROCM_VERSION}" + ;; + esac + if [[ "${VERSION_MAJOR}" -le 15 && "${VERSION_MINOR}" -le 5 ]]; then + PERL_REPO="15.6" + else + PERL_REPO="${VERSION_MAJOR}.${VERSION_MINOR}" + fi + verbose-build docker build . ${PULL} --progress plain -f ${DOCKER_FILE} --tag ${CONTAINER} --build-arg DISTRO=${DISTRO_IMAGE} --build-arg VERSION=${VERSION} --build-arg ROCM_VERSION=${ROCM_VERSION} --build-arg AMDGPU_RPM=${ROCM_RPM} --build-arg PERL_REPO=${PERL_REPO} --build-arg PYTHON_VERSIONS=\"${PYTHON_VERSIONS}\" + fi + if [ "${PUSH}" -ne 0 ]; then + docker push ${CONTAINER} + fi + done +done \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/rhel8/Dockerfile b/projects/rocprofiler-compute/docker/rhel8/Dockerfile deleted file mode 100644 index 70afcb13cb..0000000000 --- a/projects/rocprofiler-compute/docker/rhel8/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM --platform=linux/amd64 rockylinux:8 - -RUN yum -y install epel-release -RUN yum -y install dnf-plugins-core -RUN yum -y install cmake -RUN yum -y install gcc-c++ -RUN yum -y install python39 - -# Enable rocm package repo -COPY rocm.repo /etc/yum.repos.d -RUN yum config-manager --set-enabled powertools - -# Desired ROCm packages -RUN yum -y install rocm-dev5.1.3 \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/rhel8/rocm.repo b/projects/rocprofiler-compute/docker/rhel8/rocm.repo deleted file mode 100644 index 8b20489780..0000000000 --- a/projects/rocprofiler-compute/docker/rhel8/rocm.repo +++ /dev/null @@ -1,13 +0,0 @@ -[ROCm-5.1.3] -name=ROCm5.1.3 -baseurl=https://repo.radeon.com/rocm/centos8/5.1.3/main -enabled=1 -gpgcheck=1 -gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key - -[amdgpu] -name=amdgpu -baseurl=https://repo.radeon.com/amdgpu/latest/rhel/8.8/main/x86_64 -enabled=1 -gpgcheck=1 -gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/sle15sp3/Dockerfile b/projects/rocprofiler-compute/docker/sle15sp3/Dockerfile deleted file mode 100644 index a4e430052e..0000000000 --- a/projects/rocprofiler-compute/docker/sle15sp3/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM --platform=linux/amd64 registry.suse.com/suse/sle15:15.3 - -RUN zypper -n --gpg-auto-import-keys addrepo https://download.opensuse.org/repositories/devel:/languages:/perl/SLE_15_SP3/devel:languages:perl.repo - -COPY amdgpu.repo /etc/zypp/repos.d/amdgpu.repo - -RUN zypper -n --gpg-auto-import-keys install rocm-dev5.1.3 - -RUN zypper -n install gcc-c++ && \ - zypper -n install make && \ - zypper -n install git - \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/sle15sp3/amdgpu.repo b/projects/rocprofiler-compute/docker/sle15sp3/amdgpu.repo deleted file mode 100644 index 88eadf65c6..0000000000 --- a/projects/rocprofiler-compute/docker/sle15sp3/amdgpu.repo +++ /dev/null @@ -1,13 +0,0 @@ -[ROCm-5.1.3] -name=ROCm5.1.3 -baseurl=https://repo.radeon.com/rocm/zyp/5.1.3/main -enabled=1 -gpgcheck=0 -gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key - -[amdgpu] -name=amdgpu -baseurl=https://repo.radeon.com/amdgpu/latest/sle/15.3/main/x86_64 -enabled=1 -gpgcheck=0 -gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key \ No newline at end of file diff --git a/projects/rocprofiler-compute/docker/ubuntu20.04/Dockerfile b/projects/rocprofiler-compute/docker/ubuntu20.04/Dockerfile deleted file mode 100644 index 8e2582d9e4..0000000000 --- a/projects/rocprofiler-compute/docker/ubuntu20.04/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM --platform=linux/amd64 ubuntu:20.04 -WORKDIR /home - -USER root - -ENV DEBIAN_FRONTEND noninteractive -ENV TZ "US/Chicago" - -RUN apt-get update -RUN apt-get install -y wget -RUN wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb -RUN apt-get install -y ./amdgpu-install_5.3.50300-1_all.deb -RUN amdgpu-install --usecase=rocm -y --accept-eula - -RUN apt-get install -y build-essential \ No newline at end of file