Skip to content

Commit 51ce1cc

Browse files
rraminenpruthvistony
authored andcommitted
CONSOLIDATED COMMITS: Centos stream9 PyTorch support
==================================================== [SOW MS3] Centos stream9 PyTorch image support (#1090) * changes to build Centos stream 9 images * Added scripts for centos and centos stream images * Added an extra line * Add ninja installation * Optimized code * Fixes * Add comment * Optimized code * Added AMDGPU mapping for ROCm 5.2 and invalid-url for rocm_baseurl Co-authored-by: Jithun Nair <[email protected]> Updated to latest conda for CentOS stream 9 [CS9] Updates to CentOS stream 9 build (#1326) - Add missing common_utils.sh - Update the install vision part - Move to amdgpu rhel 9.3 builds - Update to pick python from conda path - Add a missing package - Add ROCM_PATH and magma - Updated repo radeon path
1 parent bf7009d commit 51ce1cc

File tree

7 files changed

+230
-30
lines changed

7 files changed

+230
-30
lines changed

.ci/docker/build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ if [[ "$image" == *cuda* && ${OS} == "ubuntu" ]]; then
499499
fi
500500
fi
501501

502+
if [[ "$image" == *centos9* ]]; then
503+
DOCKERFILE_NAME="Dockerfile.centos.stream"
504+
else
505+
DOCKERFILE_NAME="Dockerfile"
506+
fi
507+
502508
# Build image
503509
docker build \
504510
--no-cache \
@@ -541,7 +547,7 @@ docker build \
541547
--build-arg "ACL=${ACL:-}" \
542548
--build-arg "SKIP_SCCACHE_INSTALL=${SKIP_SCCACHE_INSTALL:-}" \
543549
--build-arg "SKIP_LLVM_SRC_BUILD_INSTALL=${SKIP_LLVM_SRC_BUILD_INSTALL:-}" \
544-
-f $(dirname ${DOCKERFILE})/Dockerfile \
550+
-f $(dirname ${DOCKERFILE})/${DOCKERFILE_NAME} \
545551
-t "$tmp_tag" \
546552
"$@" \
547553
.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
ARG CENTOS_VERSION
2+
3+
FROM quay.io/centos/centos:stream${CENTOS_VERSION}
4+
5+
6+
# Set AMD gpu targets to build for
7+
ARG PYTORCH_ROCM_ARCH
8+
ENV PYTORCH_ROCM_ARCH ${PYTORCH_ROCM_ARCH}
9+
10+
# Install required packages to build Caffe2
11+
12+
# Install common dependencies (so that this step can be cached separately)
13+
ARG EC2
14+
COPY ./common/install_base.sh install_base.sh
15+
RUN bash ./install_base.sh && rm install_base.sh
16+
17+
#Install langpack
18+
RUN yum install -y glibc-langpack-en
19+
20+
# Update CentOS git version
21+
RUN yum -y remove git
22+
RUN yum -y remove git-*
23+
RUN yum install -y git
24+
25+
# Install devtoolset
26+
RUN dnf install -y rpmdevtools
27+
ENV BASH_ENV "/etc/profile"
28+
29+
# Install ninja
30+
RUN dnf --enablerepo=crb install -y ninja-build
31+
32+
# (optional) Install non-default glibc version
33+
ARG GLIBC_VERSION
34+
COPY ./common/install_glibc.sh install_glibc.sh
35+
RUN if [ -n "${GLIBC_VERSION}" ]; then bash ./install_glibc.sh; fi
36+
RUN rm install_glibc.sh
37+
38+
# Install user
39+
COPY ./common/install_user.sh install_user.sh
40+
RUN bash ./install_user.sh && rm install_user.sh
41+
42+
# Install conda and other packages (e.g., numpy, pytest)
43+
ARG ANACONDA_PYTHON_VERSION
44+
ARG CONDA_CMAKE
45+
ENV ANACONDA_PYTHON_VERSION=$ANACONDA_PYTHON_VERSION
46+
ENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH
47+
COPY requirements-ci.txt /opt/conda/requirements-ci.txt
48+
COPY ./common/install_conda.sh install_conda.sh
49+
COPY ./common/common_utils.sh common_utils.sh
50+
RUN bash ./install_conda.sh && rm install_conda.sh common_utils.sh /opt/conda/requirements-ci.txt
51+
52+
# (optional) Install protobuf for ONNX
53+
ARG PROTOBUF
54+
COPY ./common/install_protobuf.sh install_protobuf.sh
55+
RUN if [ -n "${PROTOBUF}" ]; then bash ./install_protobuf.sh; fi
56+
RUN rm install_protobuf.sh
57+
ENV INSTALLED_PROTOBUF ${PROTOBUF}
58+
59+
# (optional) Install database packages like LMDB and LevelDB
60+
ARG DB
61+
COPY ./common/install_db.sh install_db.sh
62+
RUN if [ -n "${DB}" ]; then bash ./install_db.sh; fi
63+
RUN rm install_db.sh
64+
ENV INSTALLED_DB ${DB}
65+
66+
# (optional) Install vision packages like OpenCV and ffmpeg
67+
ARG VISION
68+
COPY ./common/install_vision.sh ./common/cache_vision_models.sh ./common/common_utils.sh ./
69+
RUN if [ -n "${VISION}" ]; then bash ./install_vision.sh; fi
70+
RUN rm install_vision.sh cache_vision_models.sh common_utils.sh
71+
ENV INSTALLED_VISION ${VISION}
72+
73+
# Install rocm
74+
ARG ROCM_VERSION
75+
COPY ./common/install_rocm.sh install_rocm.sh
76+
RUN bash ./install_rocm.sh
77+
RUN rm install_rocm.sh
78+
COPY ./common/install_rocm_magma.sh install_rocm_magma.sh
79+
RUN bash ./install_rocm_magma.sh
80+
RUN rm install_rocm_magma.sh
81+
82+
ENV ROCM_PATH /opt/rocm
83+
ENV PATH /opt/rocm/bin:$PATH
84+
ENV PATH /opt/rocm/hcc/bin:$PATH
85+
ENV PATH /opt/rocm/hip/bin:$PATH
86+
ENV PATH /opt/rocm/opencl/bin:$PATH
87+
ENV PATH /opt/rocm/llvm/bin:$PATH
88+
ENV MAGMA_HOME /opt/rocm/magma
89+
ENV LANG en_US.utf8
90+
ENV LC_ALL en_US.utf8
91+
92+
# (optional) Install non-default CMake version
93+
ARG CMAKE_VERSION
94+
COPY ./common/install_cmake.sh install_cmake.sh
95+
RUN if [ -n "${CMAKE_VERSION}" ]; then bash ./install_cmake.sh; fi
96+
RUN rm install_cmake.sh
97+
98+
# (optional) Install non-default Ninja version
99+
ARG NINJA_VERSION
100+
COPY ./common/install_ninja.sh install_ninja.sh
101+
RUN if [ -n "${NINJA_VERSION}" ]; then bash ./install_ninja.sh; fi
102+
RUN rm install_ninja.sh
103+
104+
ARG TRITON
105+
# Install triton, this needs to be done before sccache because the latter will
106+
# try to reach out to S3, which docker build runners don't have access
107+
ENV CMAKE_C_COMPILER cc
108+
ENV CMAKE_CXX_COMPILER c++
109+
COPY ./common/install_triton.sh install_triton.sh
110+
COPY ./common/common_utils.sh common_utils.sh
111+
COPY ci_commit_pins/triton-rocm.txt triton-rocm.txt
112+
COPY triton_version.txt triton_version.txt
113+
RUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi
114+
RUN rm install_triton.sh common_utils.sh triton-rocm.txt triton_version.txt
115+
116+
# Install ccache/sccache (do this last, so we get priority in PATH)
117+
COPY ./common/install_cache.sh install_cache.sh
118+
ENV PATH /opt/cache/bin:$PATH
119+
RUN bash ./install_cache.sh && rm install_cache.sh
120+
121+
# Include BUILD_ENVIRONMENT environment variable in image
122+
ARG BUILD_ENVIRONMENT
123+
ENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT}
124+
125+
USER jenkins
126+
CMD ["bash"]

.ci/docker/common/install_base.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,21 @@ install_ubuntu() {
9191
install_centos() {
9292
# Need EPEL for many packages we depend on.
9393
# See http://fedoraproject.org/wiki/EPEL
94-
yum --enablerepo=extras install -y epel-release
94+
# extras repo is not there for CentOS 9 and epel-release is already part of repo list
95+
if [[ $OS_VERSION == 9 ]]; then
96+
yum install -y epel-release
97+
ALLOW_ERASE="--allowerasing"
98+
else
99+
yum --enablerepo=extras install -y epel-release
100+
ALLOW_ERASE=""
101+
fi
95102

96103
ccache_deps="asciidoc docbook-dtds docbook-style-xsl libxslt"
97104
numpy_deps="gcc-gfortran"
98105
# Note: protobuf-c-{compiler,devel} on CentOS are too old to be used
99106
# for Caffe2. That said, we still install them to make sure the build
100107
# system opts to build/use protoc and libprotobuf from third-party.
101-
yum install -y \
108+
yum install -y $ALLOW_ERASE \
102109
$ccache_deps \
103110
$numpy_deps \
104111
autoconf \
@@ -115,24 +122,34 @@ install_centos() {
115122
glibc-headers \
116123
glog-devel \
117124
libstdc++-devel \
118-
libsndfile-devel \
119125
make \
120-
opencv-devel \
121126
sudo \
122127
wget \
123128
vim \
124129
unzip \
125130
gdb
126131

132+
if [[ $OS_VERSION == 9 ]]
133+
then
134+
dnf --enablerepo=crb -y install libsndfile-devel
135+
yum install -y procps
136+
else
137+
yum install -y \
138+
opencv-devel \
139+
libsndfile-devel
140+
fi
141+
127142
# Cleanup
128143
yum clean all
129144
rm -rf /var/cache/yum
130145
rm -rf /var/lib/yum/yumdb
131146
rm -rf /var/lib/yum/history
132147
}
133148

134-
# Install base packages depending on the base OS
135149
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
150+
OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
151+
152+
# Install base packages depending on the base OS
136153
case "$ID" in
137154
ubuntu)
138155
install_ubuntu

.ci/docker/common/install_conda.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ if [ -n "$ANACONDA_PYTHON_VERSION" ]; then
4545

4646
# Prevent conda from updating to 4.14.0, which causes docker build failures
4747
# See https://hud.pytorch.org/pytorch/pytorch/commit/754d7f05b6841e555cea5a4b2c505dd9e0baec1d
48-
# Uncomment the below when resolved to track the latest conda update
49-
# as_jenkins conda update -y -n base conda
48+
# Uncomment the below when resolved to track the latest conda update,
49+
# but this is required for CentOS stream 9 builds
50+
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
51+
OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
52+
if [[ $ID == centos && $OS_VERSION == 9 ]]; then
53+
as_jenkins conda update -y -n base conda
54+
fi
5055

5156
if [[ $(uname -m) == "aarch64" ]]; then
5257
export SYSROOT_DEP="sysroot_linux-aarch64=2.17"

.ci/docker/common/install_db.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ install_ubuntu() {
1313
install_centos() {
1414
# Need EPEL for many packages we depend on.
1515
# See http://fedoraproject.org/wiki/EPEL
16-
yum --enablerepo=extras install -y epel-release
16+
if [[ $OS_VERSION == 9 ]]; then
17+
yum install -y epel-release
18+
else
19+
yum --enablerepo=extras install -y epel-release
20+
fi
21+
22+
yum install -y \
23+
hiredis-devel \
24+
leveldb-devel
25+
26+
if [[ $OS_VERSION == 9 ]]; then
27+
dnf --enablerepo=crb -y install lmdb-devel snappy-devel
28+
else
29+
yum install -y \
30+
lmdb-devel \
31+
snappy-devel
32+
fi
1733

1834
# Cleanup
1935
yum clean all
@@ -22,6 +38,8 @@ install_centos() {
2238
rm -rf /var/lib/yum/history
2339
}
2440

41+
OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
42+
2543
# Install base packages depending on the base OS
2644
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
2745
case "$ID" in

.ci/docker/common/install_rocm.sh

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,56 @@ install_centos() {
7272
yum update -y
7373
yum install -y kmod
7474
yum install -y wget
75-
yum install -y openblas-devel
75+
76+
if [[ $OS_VERSION == 9 ]]; then
77+
dnf install -y openblas-serial
78+
dnf install -y dkms kernel-headers kernel-devel
79+
else
80+
yum install -y openblas-devel
81+
yum install -y dkms kernel-headers-`uname -r` kernel-devel-`uname -r`
82+
fi
7683

7784
yum install -y epel-release
78-
yum install -y dkms kernel-headers-`uname -r` kernel-devel-`uname -r`
7985

80-
# Add amdgpu repository
81-
local amdgpu_baseurl
86+
if [[ $(ver $ROCM_VERSION) -ge $(ver 4.5) ]]; then
87+
# Add amdgpu repository
88+
local amdgpu_baseurl
89+
if [[ $OS_VERSION == 9 ]]; then
90+
amdgpu_baseurl="https://repo.radeon.com/amdgpu/${AMDGPU_VERSIONS[$ROCM_VERSION]}/rhel/9.1/main/x86_64"
91+
else
92+
if [[ $(ver $ROCM_VERSION) -ge $(ver 5.3) ]]; then
93+
amdgpu_baseurl="https://repo.radeon.com/amdgpu/${ROCM_VERSION}/rhel/7.9/main/x86_64"
94+
else
95+
amdgpu_baseurl="https://repo.radeon.com/amdgpu/${AMDGPU_VERSIONS[$ROCM_VERSION]}/rhel/7.9/main/x86_64"
96+
fi
97+
fi
98+
echo "[AMDGPU]" > /etc/yum.repos.d/amdgpu.repo
99+
echo "name=AMDGPU" >> /etc/yum.repos.d/amdgpu.repo
100+
echo "baseurl=${amdgpu_baseurl}" >> /etc/yum.repos.d/amdgpu.repo
101+
echo "enabled=1" >> /etc/yum.repos.d/amdgpu.repo
102+
echo "gpgcheck=1" >> /etc/yum.repos.d/amdgpu.repo
103+
echo "gpgkey=http://repo.radeon.com/rocm/rocm.gpg.key" >> /etc/yum.repos.d/amdgpu.repo
104+
fi
105+
82106
if [[ $OS_VERSION == 9 ]]; then
83-
amdgpu_baseurl="https://repo.radeon.com/amdgpu/${ROCM_VERSION}/rhel/9.0/main/x86_64"
107+
local rocm_baseurl="invalid-url"
84108
else
85-
amdgpu_baseurl="https://repo.radeon.com/amdgpu/${ROCM_VERSION}/rhel/7.9/main/x86_64"
109+
local rocm_baseurl="http://repo.radeon.com/rocm/yum/${ROCM_VERSION}/main"
86110
fi
87-
echo "[AMDGPU]" > /etc/yum.repos.d/amdgpu.repo
88-
echo "name=AMDGPU" >> /etc/yum.repos.d/amdgpu.repo
89-
echo "baseurl=${amdgpu_baseurl}" >> /etc/yum.repos.d/amdgpu.repo
90-
echo "enabled=1" >> /etc/yum.repos.d/amdgpu.repo
91-
echo "gpgcheck=1" >> /etc/yum.repos.d/amdgpu.repo
92-
echo "gpgkey=http://repo.radeon.com/rocm/rocm.gpg.key" >> /etc/yum.repos.d/amdgpu.repo
93-
94-
local rocm_baseurl="http://repo.radeon.com/rocm/yum/${ROCM_VERSION}"
95111
echo "[ROCm]" > /etc/yum.repos.d/rocm.repo
96112
echo "name=ROCm" >> /etc/yum.repos.d/rocm.repo
97113
echo "baseurl=${rocm_baseurl}" >> /etc/yum.repos.d/rocm.repo
98114
echo "enabled=1" >> /etc/yum.repos.d/rocm.repo
99115
echo "gpgcheck=1" >> /etc/yum.repos.d/rocm.repo
100116
echo "gpgkey=http://repo.radeon.com/rocm/rocm.gpg.key" >> /etc/yum.repos.d/rocm.repo
101117

102-
yum update -y
103-
104-
yum install -y \
118+
if [[ $OS_VERSION == 9 ]]; then
119+
yum update -y --nogpgcheck
120+
dnf --enablerepo=crb install -y perl-File-BaseDir
121+
yum install -y --nogpgcheck rocm-ml-sdk rocm-developer-tools
122+
else
123+
yum update -y
124+
yum install -y \
105125
rocm-dev \
106126
rocm-utils \
107127
rocm-libs \
@@ -132,6 +152,8 @@ install_centos() {
132152
rm -rf /var/lib/yum/history
133153
}
134154

155+
OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
156+
135157
# Install Python packages depending on the base OS
136158
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
137159
case "$ID" in

.ci/docker/common/install_vision.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ install_ubuntu() {
1515
install_centos() {
1616
# Need EPEL for many packages we depend on.
1717
# See http://fedoraproject.org/wiki/EPEL
18-
yum --enablerepo=extras install -y epel-release
19-
20-
yum install -y \
21-
opencv-devel
18+
if [[ $OS_VERSION == 9 ]]; then
19+
yum install -y epel-release
20+
else
21+
yum --enablerepo=extras install -y epel-release
22+
yum install -y \
23+
opencv-devel \
24+
ffmpeg-devel
25+
fi
2226

2327
# Cleanup
2428
yum clean all
@@ -27,6 +31,8 @@ install_centos() {
2731
rm -rf /var/lib/yum/history
2832
}
2933

34+
OS_VERSION=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"')
35+
3036
# Install base packages depending on the base OS
3137
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
3238
case "$ID" in

0 commit comments

Comments
 (0)