From 8c54f85dc2177e099962ee24d2d70071efdf93b5 Mon Sep 17 00:00:00 2001 From: ethanwee1 Date: Tue, 22 Apr 2025 18:21:10 +0000 Subject: [PATCH 1/4] Update for CentOS Stream 9 --- .ci/docker/centos-rocm/Dockerfile | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/.ci/docker/centos-rocm/Dockerfile b/.ci/docker/centos-rocm/Dockerfile index 2138183ba575..e683e587d1eb 100644 --- a/.ci/docker/centos-rocm/Dockerfile +++ b/.ci/docker/centos-rocm/Dockerfile @@ -1,8 +1,7 @@ ARG CENTOS_VERSION -FROM centos:${CENTOS_VERSION} +FROM quay.io/centos/centos:stream${CENTOS_VERSION} -ARG CENTOS_VERSION # Set AMD gpu targets to build for ARG PYTORCH_ROCM_ARCH @@ -14,20 +13,21 @@ ENV PYTORCH_ROCM_ARCH ${PYTORCH_ROCM_ARCH} COPY ./common/install_base.sh install_base.sh RUN bash ./install_base.sh && rm install_base.sh +#Install langpack +RUN yum install -y glibc-langpack-en + # Update CentOS git version RUN yum -y remove git RUN yum -y remove git-* -RUN yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm || \ - (yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm && \ - sed -i "s/packages.endpoint/packages.endpointdev/" /etc/yum.repos.d/endpoint.repo) RUN yum install -y git # Install devtoolset -ARG DEVTOOLSET_VERSION -COPY ./common/install_devtoolset.sh install_devtoolset.sh -RUN bash ./install_devtoolset.sh && rm install_devtoolset.sh +RUN dnf install -y rpmdevtools ENV BASH_ENV "/etc/profile" +# Install ninja +RUN dnf --enablerepo=crb install -y ninja-build + # (optional) Install non-default glibc version ARG GLIBC_VERSION COPY ./common/install_glibc.sh install_glibc.sh @@ -56,14 +56,7 @@ RUN if [ -n "${PROTOBUF}" ]; then bash ./install_protobuf.sh; fi RUN rm install_protobuf.sh ENV INSTALLED_PROTOBUF ${PROTOBUF} -# (optional) Install database packages like LMDB and LevelDB -ARG DB -COPY ./common/install_db.sh install_db.sh -RUN if [ -n "${DB}" ]; then bash ./install_db.sh; fi -RUN rm install_db.sh -ENV INSTALLED_DB ${DB} - -# (optional) Install vision packages like OpenCV +# (optional) Install vision packages like OpenCV and ffmpeg ARG VISION COPY ./common/install_vision.sh ./common/cache_vision_models.sh ./common/common_utils.sh ./ RUN if [ -n "${VISION}" ]; then bash ./install_vision.sh; fi From edbdb4f268c6604f4491e438b845a5f33c6c2548 Mon Sep 17 00:00:00 2001 From: Jithun Nair Date: Mon, 28 Apr 2025 18:59:14 +0000 Subject: [PATCH 2/4] cherry-pick CentOS9-related changes from https://github.com/ROCm/pytorch/commit/8a7fd64cc72a3c3d92329a68105b53037839801c --- .ci/docker/common/install_base.sh | 27 +++++++++++--- .ci/docker/common/install_conda.sh | 9 +++-- .ci/docker/common/install_rocm.sh | 56 ++++++++++++++++++++--------- .ci/docker/common/install_vision.sh | 14 +++++--- 4 files changed, 78 insertions(+), 28 deletions(-) diff --git a/.ci/docker/common/install_base.sh b/.ci/docker/common/install_base.sh index a489dae2c9e4..0e15bc931746 100755 --- a/.ci/docker/common/install_base.sh +++ b/.ci/docker/common/install_base.sh @@ -104,14 +104,21 @@ install_ubuntu() { install_centos() { # Need EPEL for many packages we depend on. # See http://fedoraproject.org/wiki/EPEL - yum --enablerepo=extras install -y epel-release + # extras repo is not there for CentOS 9 and epel-release is already part of repo list + if [[ $OS_VERSION == 9 ]]; then + yum install -y epel-release + ALLOW_ERASE="--allowerasing" + else + yum --enablerepo=extras install -y epel-release + ALLOW_ERASE="" + fi ccache_deps="asciidoc docbook-dtds docbook-style-xsl libxslt" numpy_deps="gcc-gfortran" # Note: protobuf-c-{compiler,devel} on CentOS are too old to be used # for Caffe2. That said, we still install them to make sure the build # system opts to build/use protoc and libprotobuf from third-party. - yum install -y \ + yum install -y $ALLOW_ERASE \ $ccache_deps \ $numpy_deps \ autoconf \ @@ -128,15 +135,23 @@ install_centos() { glibc-headers \ glog-devel \ libstdc++-devel \ - libsndfile-devel \ make \ - opencv-devel \ sudo \ wget \ vim \ unzip \ gdb + if [[ $OS_VERSION == 9 ]] + then + dnf --enablerepo=crb -y install libsndfile-devel + yum install -y procps + else + yum install -y \ + opencv-devel \ + libsndfile-devel + fi + # Cleanup yum clean all rm -rf /var/cache/yum @@ -144,8 +159,10 @@ install_centos() { rm -rf /var/lib/yum/history } -# Install base packages depending on the base OS ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') +OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"') + +# Install base packages depending on the base OS case "$ID" in ubuntu) install_ubuntu diff --git a/.ci/docker/common/install_conda.sh b/.ci/docker/common/install_conda.sh index 150f8d748e1c..ae6d870836b1 100755 --- a/.ci/docker/common/install_conda.sh +++ b/.ci/docker/common/install_conda.sh @@ -45,8 +45,13 @@ if [ -n "$ANACONDA_PYTHON_VERSION" ]; then # Prevent conda from updating to 4.14.0, which causes docker build failures # See https://hud.pytorch.org/pytorch/pytorch/commit/754d7f05b6841e555cea5a4b2c505dd9e0baec1d - # Uncomment the below when resolved to track the latest conda update - # as_jenkins conda update -y -n base conda + # Uncomment the below when resolved to track the latest conda update, + # but this is required for CentOS stream 9 builds + ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') + OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"') + if [[ $ID == centos && $OS_VERSION == 9 ]]; then + as_jenkins conda update -y -n base conda + fi if [[ $(uname -m) == "aarch64" ]]; then export SYSROOT_DEP="sysroot_linux-aarch64=2.17" diff --git a/.ci/docker/common/install_rocm.sh b/.ci/docker/common/install_rocm.sh index 4243d2b2e4fd..54442755c5b5 100644 --- a/.ci/docker/common/install_rocm.sh +++ b/.ci/docker/common/install_rocm.sh @@ -86,26 +86,42 @@ install_centos() { yum update -y yum install -y kmod yum install -y wget - yum install -y openblas-devel + + if [[ $OS_VERSION == 9 ]]; then + dnf install -y openblas-serial + dnf install -y dkms kernel-headers kernel-devel + else + yum install -y openblas-devel + yum install -y dkms kernel-headers-`uname -r` kernel-devel-`uname -r` + fi yum install -y epel-release - yum install -y dkms kernel-headers-`uname -r` kernel-devel-`uname -r` - # Add amdgpu repository - local amdgpu_baseurl + if [[ $(ver $ROCM_VERSION) -ge $(ver 4.5) ]]; then + # Add amdgpu repository + local amdgpu_baseurl + if [[ $OS_VERSION == 9 ]]; then + amdgpu_baseurl="https://repo.radeon.com/amdgpu/${AMDGPU_VERSIONS[$ROCM_VERSION]}/rhel/9.1/main/x86_64" + else + if [[ $(ver $ROCM_VERSION) -ge $(ver 5.3) ]]; then + amdgpu_baseurl="https://repo.radeon.com/amdgpu/${ROCM_VERSION}/rhel/7.9/main/x86_64" + else + amdgpu_baseurl="https://repo.radeon.com/amdgpu/${AMDGPU_VERSIONS[$ROCM_VERSION]}/rhel/7.9/main/x86_64" + fi + fi + echo "[AMDGPU]" > /etc/yum.repos.d/amdgpu.repo + echo "name=AMDGPU" >> /etc/yum.repos.d/amdgpu.repo + echo "baseurl=${amdgpu_baseurl}" >> /etc/yum.repos.d/amdgpu.repo + echo "enabled=1" >> /etc/yum.repos.d/amdgpu.repo + echo "gpgcheck=1" >> /etc/yum.repos.d/amdgpu.repo + echo "gpgkey=http://repo.radeon.com/rocm/rocm.gpg.key" >> /etc/yum.repos.d/amdgpu.repo + fi + if [[ $OS_VERSION == 9 ]]; then - amdgpu_baseurl="https://repo.radeon.com/amdgpu/${ROCM_VERSION}/rhel/9.0/main/x86_64" + local rocm_baseurl="invalid-url" else - amdgpu_baseurl="https://repo.radeon.com/amdgpu/${ROCM_VERSION}/rhel/7.9/main/x86_64" + local rocm_baseurl="http://repo.radeon.com/rocm/yum/${ROCM_VERSION}/main" fi - echo "[AMDGPU]" > /etc/yum.repos.d/amdgpu.repo - echo "name=AMDGPU" >> /etc/yum.repos.d/amdgpu.repo - echo "baseurl=${amdgpu_baseurl}" >> /etc/yum.repos.d/amdgpu.repo - echo "enabled=1" >> /etc/yum.repos.d/amdgpu.repo - echo "gpgcheck=1" >> /etc/yum.repos.d/amdgpu.repo - echo "gpgkey=http://repo.radeon.com/rocm/rocm.gpg.key" >> /etc/yum.repos.d/amdgpu.repo - - local rocm_baseurl="http://repo.radeon.com/rocm/yum/${ROCM_VERSION}" echo "[ROCm]" > /etc/yum.repos.d/rocm.repo echo "name=ROCm" >> /etc/yum.repos.d/rocm.repo echo "baseurl=${rocm_baseurl}" >> /etc/yum.repos.d/rocm.repo @@ -113,9 +129,13 @@ install_centos() { echo "gpgcheck=1" >> /etc/yum.repos.d/rocm.repo echo "gpgkey=http://repo.radeon.com/rocm/rocm.gpg.key" >> /etc/yum.repos.d/rocm.repo - yum update -y - - yum install -y \ + if [[ $OS_VERSION == 9 ]]; then + yum update -y --nogpgcheck + dnf --enablerepo=crb install -y perl-File-BaseDir python3-wheel + yum install -y --nogpgcheck rocm-ml-sdk rocm-developer-tools + else + yum update -y + yum install -y \ rocm-dev \ rocm-utils \ rocm-libs \ @@ -146,6 +166,8 @@ install_centos() { rm -rf /var/lib/yum/history } +OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"') + # Install Python packages depending on the base OS ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') case "$ID" in diff --git a/.ci/docker/common/install_vision.sh b/.ci/docker/common/install_vision.sh index 78c445568ddc..532d8d14a55c 100755 --- a/.ci/docker/common/install_vision.sh +++ b/.ci/docker/common/install_vision.sh @@ -15,10 +15,14 @@ install_ubuntu() { install_centos() { # Need EPEL for many packages we depend on. # See http://fedoraproject.org/wiki/EPEL - yum --enablerepo=extras install -y epel-release - - yum install -y \ - opencv-devel + if [[ $OS_VERSION == 9 ]]; then + yum install -y epel-release + else + yum --enablerepo=extras install -y epel-release + yum install -y \ + opencv-devel \ + ffmpeg-devel + fi # Cleanup yum clean all @@ -27,6 +31,8 @@ install_centos() { rm -rf /var/lib/yum/history } +OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"') + # Install base packages depending on the base OS ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') case "$ID" in From b6fc48accb7346b91e055052f7a0587ad3b19d97 Mon Sep 17 00:00:00 2001 From: Jithun Nair Date: Mon, 28 Apr 2025 22:28:05 +0000 Subject: [PATCH 3/4] syntax --- .ci/docker/common/install_rocm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/docker/common/install_rocm.sh b/.ci/docker/common/install_rocm.sh index 54442755c5b5..5f655f2010d4 100644 --- a/.ci/docker/common/install_rocm.sh +++ b/.ci/docker/common/install_rocm.sh @@ -143,6 +143,7 @@ install_centos() { rocprofiler-dev \ roctracer-dev \ amd-smi-lib + fi # precompiled miopen kernels; search for all unversioned packages # if search fails it will abort this script; use true to avoid case where search fails From c26b31268ee16058ebc135a62ae361d8ccf20aa2 Mon Sep 17 00:00:00 2001 From: Jagadish Krishnamoorthy Date: Tue, 1 Apr 2025 09:19:40 -0700 Subject: [PATCH 4/4] Revert to prev sccache by ROCm Signed-off-by: Jagadish Krishnamoorthy (cherry picked from commit 1ad5bb95d796283d5f56ac1edd16f1731d24a49d) (cherry picked from commit 519160d466782f5a62365be051fcb3ef90fa0b00) --- .ci/docker/common/install_cache.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.ci/docker/common/install_cache.sh b/.ci/docker/common/install_cache.sh index b2cff619a57c..0e181bd7f43d 100644 --- a/.ci/docker/common/install_cache.sh +++ b/.ci/docker/common/install_cache.sh @@ -36,7 +36,12 @@ sed -e 's|PATH="\(.*\)"|PATH="/opt/cache/bin:\1"|g' -i /etc/environment export PATH="/opt/cache/bin:$PATH" # Setup compiler cache -install_ubuntu +if [ -n "$ROCM_VERSION" ]; then + curl --retry 3 http://repo.radeon.com/misc/.sccache_amd/sccache -o /opt/cache/bin/sccache +else + install_ubuntu +fi + chmod a+x /opt/cache/bin/sccache function write_sccache_stub() {