Skip to content

Commit 44938bf

Browse files
Update s390x builder (#1802)
* Disable automatic building of s390x docker image * Update docker image and build scripts for s390x * Switch devtoolset to 13 There is a not yet investigated build failure caused by gcc 12, but it doesn't reproduce with gcc 13. * Adapt binaries check for s390x * Switch to ubuntu:24.04 for s390x * Update libgomp.so.1 path for s390x
1 parent 6b90c09 commit 44938bf

File tree

7 files changed

+82
-66
lines changed

7 files changed

+82
-66
lines changed

.github/workflows/build-manywheel-images.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,3 @@ jobs:
137137
- name: Build Docker Image
138138
run: |
139139
manywheel/build_docker.sh
140-
build-docker-cpu-s390x:
141-
runs-on: linux.s390x
142-
env:
143-
GPU_ARCH_TYPE: cpu-s390x
144-
steps:
145-
- name: Checkout PyTorch
146-
uses: actions/checkout@v3
147-
- name: Authenticate if WITH_PUSH
148-
run: |
149-
if [[ "${WITH_PUSH}" == true ]]; then
150-
echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_ID}" --password-stdin
151-
fi
152-
- name: Build Docker Image
153-
run: |
154-
manywheel/build_docker.sh

check_binary.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fi
330330
if [[ "$PACKAGE_TYPE" == 'libtorch' ]]; then
331331
echo "Checking that MKL is available"
332332
build_and_run_example_cpp check-torch-mkl
333-
elif [[ "$(uname -m)" != "arm64" ]]; then
333+
elif [[ "$(uname -m)" != "arm64" && "$(uname -m)" != "s390x" ]]; then
334334
if [[ "$(uname)" != 'Darwin' || "$PACKAGE_TYPE" != *wheel ]]; then
335335
if [[ "$(uname -m)" == "aarch64" ]]; then
336336
echo "Checking that MKLDNN is available on aarch64"
@@ -354,7 +354,7 @@ if [[ "$PACKAGE_TYPE" == 'libtorch' ]]; then
354354
echo "Checking that XNNPACK is available"
355355
build_and_run_example_cpp check-torch-xnnpack
356356
else
357-
if [[ "$(uname)" != 'Darwin' || "$PACKAGE_TYPE" != *wheel ]]; then
357+
if [[ "$(uname)" != 'Darwin' || "$PACKAGE_TYPE" != *wheel ]] && [[ "$(uname -m)" != "s390x" ]]; then
358358
echo "Checking that XNNPACK is available"
359359
pushd /tmp
360360
python -c 'import torch.backends.xnnpack; exit(0 if torch.backends.xnnpack.enabled else 1)'
@@ -375,7 +375,7 @@ if [[ "$OSTYPE" == "msys" ]]; then
375375
fi
376376

377377
# Test that CUDA builds are setup correctly
378-
if [[ "$DESIRED_CUDA" != 'cpu' && "$DESIRED_CUDA" != 'cpu-cxx11-abi' && "$DESIRED_CUDA" != *"rocm"* ]]; then
378+
if [[ "$DESIRED_CUDA" != 'cpu' && "$DESIRED_CUDA" != 'cpu-cxx11-abi' && "$DESIRED_CUDA" != *"rocm"* && "$(uname -m)" != "s390x" ]]; then
379379
if [[ "$PACKAGE_TYPE" == 'libtorch' ]]; then
380380
build_and_run_example_cpp check-torch-cuda
381381
else

manywheel/Dockerfile_s390x

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
FROM --platform=linux/s390x docker.io/redhat/ubi9 as base
1+
FROM --platform=linux/s390x docker.io/ubuntu:24.04 as base
22

3-
# earliest available version in ubi9
4-
ARG DEVTOOLSET_VERSION=12
5-
6-
# Language variabes
7-
ENV LC_ALL=en_US.UTF-8
8-
ENV LANG=en_US.UTF-8
9-
ENV LANGUAGE=en_US.UTF-8
3+
# Language variables
4+
ENV LC_ALL=C.UTF-8
5+
ENV LANG=C.UTF-8
6+
ENV LANGUAGE=C.UTF-8
107

118
# Installed needed OS packages. This is to support all
129
# the binary builds (torch, vision, audio, text, data)
13-
RUN dnf -y install redhat-release
14-
RUN dnf -y update
15-
RUN dnf install -y --allowerasing \
10+
RUN apt update ; apt upgrade -y
11+
RUN apt install -y \
12+
build-essential \
1613
autoconf \
1714
automake \
1815
bzip2 \
@@ -27,20 +24,19 @@ RUN dnf install -y --allowerasing \
2724
util-linux \
2825
wget \
2926
which \
30-
xz \
27+
xz-utils \
3128
less \
3229
zstd \
33-
libgomp \
3430
cmake \
35-
gcc-toolset-${DEVTOOLSET_VERSION}-gcc \
36-
gcc-toolset-${DEVTOOLSET_VERSION}-gcc-c++ \
37-
gcc-toolset-${DEVTOOLSET_VERSION}-gcc-gfortran \
38-
gcc-toolset-${DEVTOOLSET_VERSION}-binutils
39-
40-
# Ensure the expected gcc-toolset is used
41-
ENV PATH=/opt/rh/gcc-toolset-${DEVTOOLSET_VERSION}/root/usr/bin:$PATH
42-
ENV LD_LIBRARY_PATH=/opt/rh/gcc-toolset-${DEVTOOLSET_VERSION}/root/usr/lib64:/opt/rh/gcc-toolset-${DEVTOOLSET_VERSION}/root/usr/lib:$LD_LIBRARY_PATH
43-
31+
python3 \
32+
python3-dev \
33+
python3-setuptools \
34+
python3-yaml \
35+
python3-typing-extensions \
36+
libblas-dev \
37+
libopenblas-dev \
38+
liblapack-dev \
39+
libatlas-base-dev
4440

4541
# git236+ would refuse to run git commands in repos owned by other users
4642
# Which causes version check to fail, as pytorch repo is bind-mounted into the image
@@ -57,9 +53,21 @@ ADD ./common/install_openssl.sh install_openssl.sh
5753
RUN bash ./install_openssl.sh && rm install_openssl.sh
5854
ENV SSL_CERT_FILE=/opt/_internal/certs.pem
5955

56+
# EPEL for cmake
57+
FROM base as patchelf
58+
# Install patchelf
59+
ADD ./common/install_patchelf.sh install_patchelf.sh
60+
RUN bash ./install_patchelf.sh && rm install_patchelf.sh
61+
RUN cp $(which patchelf) /patchelf
62+
63+
FROM patchelf as python
64+
# build python
65+
COPY manywheel/build_scripts /build_scripts
66+
ADD ./common/install_cpython.sh /build_scripts/install_cpython.sh
67+
RUN bash build_scripts/build.sh && rm -r build_scripts
68+
6069
FROM openssl as final
61-
# remove unncessary python versions
62-
RUN rm -rf /opt/python/cp26-cp26m /opt/_internal/cpython-2.6.9-ucs2
63-
RUN rm -rf /opt/python/cp26-cp26mu /opt/_internal/cpython-2.6.9-ucs4
64-
RUN rm -rf /opt/python/cp33-cp33m /opt/_internal/cpython-3.3.6
65-
RUN rm -rf /opt/python/cp34-cp34m /opt/_internal/cpython-3.4.6
70+
COPY --from=python /opt/python /opt/python
71+
COPY --from=python /opt/_internal /opt/_internal
72+
COPY --from=python /opt/python/cp37-cp37m/bin/auditwheel /usr/local/bin/auditwheel
73+
COPY --from=patchelf /usr/local/bin/patchelf /usr/local/bin/patchelf

manywheel/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ case "${GPU_ARCH_TYPE:-BLANK}" in
1515
rocm)
1616
bash "${SCRIPTPATH}/build_rocm.sh"
1717
;;
18-
cpu | cpu-cxx11-abi)
18+
cpu | cpu-cxx11-abi | cpu-s390x)
1919
bash "${SCRIPTPATH}/build_cpu.sh"
2020
;;
2121
*)

manywheel/build_cpu.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ if [[ "$OS_NAME" == *"CentOS Linux"* ]]; then
3232
elif [[ "$OS_NAME" == *"Red Hat Enterprise Linux"* ]]; then
3333
LIBGOMP_PATH="/usr/lib64/libgomp.so.1"
3434
elif [[ "$OS_NAME" == *"Ubuntu"* ]]; then
35-
LIBGOMP_PATH="/usr/lib/x86_64-linux-gnu/libgomp.so.1"
35+
if [[ "$(uname -m)" == "s390x" ]]; then
36+
LIBGOMP_PATH="/usr/lib/s390x-linux-gnu/libgomp.so.1"
37+
else
38+
LIBGOMP_PATH="/usr/lib/x86_64-linux-gnu/libgomp.so.1"
39+
fi
3640
fi
3741

3842
DEPS_LIST=(

manywheel/build_scripts/build.sh

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,37 @@ CURL_HASH=cf34fe0b07b800f1c01a499a6e8b2af548f6d0e044dca4a29d88a4bee146d131
1515
AUTOCONF_ROOT=autoconf-2.69
1616
AUTOCONF_HASH=954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969
1717

18-
# Dependencies for compiling Python that we want to remove from
19-
# the final image after compiling Python
20-
PYTHON_COMPILE_DEPS="zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel"
21-
22-
# Libraries that are allowed as part of the manylinux1 profile
23-
MANYLINUX1_DEPS="glibc-devel libstdc++-devel glib2-devel libX11-devel libXext-devel libXrender-devel mesa-libGL-devel libICE-devel libSM-devel ncurses-devel"
24-
2518
# Get build utilities
2619
MY_DIR=$(dirname "${BASH_SOURCE[0]}")
2720
source $MY_DIR/build_utils.sh
2821

29-
# Development tools and libraries
30-
yum -y install bzip2 make git patch unzip bison yasm diffutils \
31-
automake which file cmake28 \
32-
kernel-devel-`uname -r` \
33-
${PYTHON_COMPILE_DEPS}
22+
if [ "$(uname -m)" != "s390x" ] ; then
23+
# Dependencies for compiling Python that we want to remove from
24+
# the final image after compiling Python
25+
PYTHON_COMPILE_DEPS="zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel"
26+
27+
# Libraries that are allowed as part of the manylinux1 profile
28+
MANYLINUX1_DEPS="glibc-devel libstdc++-devel glib2-devel libX11-devel libXext-devel libXrender-devel mesa-libGL-devel libICE-devel libSM-devel ncurses-devel"
29+
30+
# Development tools and libraries
31+
yum -y install bzip2 make git patch unzip bison yasm diffutils \
32+
automake which file cmake28 \
33+
kernel-devel-`uname -r` \
34+
${PYTHON_COMPILE_DEPS}
35+
else
36+
# Dependencies for compiling Python that we want to remove from
37+
# the final image after compiling Python
38+
PYTHON_COMPILE_DEPS="zlib1g-dev libbz2-dev libncurses-dev libsqlite3-dev libdb-dev libpcap-dev liblzma-dev libffi-dev"
39+
40+
# Libraries that are allowed as part of the manylinux1 profile
41+
MANYLINUX1_DEPS="libglib2.0-dev libX11-dev libncurses-dev"
42+
43+
# Development tools and libraries
44+
apt install -y bzip2 make git patch unzip diffutils \
45+
automake which file cmake \
46+
linux-headers-virtual \
47+
${PYTHON_COMPILE_DEPS}
48+
fi
3449

3550
# Install newest autoconf
3651
build_autoconf $AUTOCONF_ROOT $AUTOCONF_HASH
@@ -76,12 +91,16 @@ ln -s $PY37_BIN/auditwheel /usr/local/bin/auditwheel
7691

7792
# Clean up development headers and other unnecessary stuff for
7893
# final image
79-
yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme \
80-
avahi freetype bitstream-vera-fonts \
81-
${PYTHON_COMPILE_DEPS} || true > /dev/null 2>&1
82-
yum -y install ${MANYLINUX1_DEPS}
83-
yum -y clean all > /dev/null 2>&1
84-
yum list installed
94+
if [ "$(uname -m)" != "s390x" ] ; then
95+
yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme \
96+
avahi freetype bitstream-vera-fonts \
97+
${PYTHON_COMPILE_DEPS} || true > /dev/null 2>&1
98+
yum -y install ${MANYLINUX1_DEPS}
99+
yum -y clean all > /dev/null 2>&1
100+
yum list installed
101+
else
102+
apt purge -y ${PYTHON_COMPILE_DEPS} || true > /dev/null 2>&1
103+
fi
85104
# we don't need libpython*.a, and they're many megabytes
86105
find /opt/_internal -name '*.a' -print0 | xargs -0 rm -f
87106
# Strip what we can -- and ignore errors, because this just attempts to strip

manywheel/build_scripts/manylinux1-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
def is_manylinux1_compatible():
44
# Only Linux, and only x86-64 / i686
55
from distutils.util import get_platform
6-
if get_platform() not in ["linux-x86_64", "linux-i686"]:
6+
if get_platform() not in ["linux-x86_64", "linux-i686", "linux-s390x"]:
77
return False
88

99
# Check for presence of _manylinux module

0 commit comments

Comments
 (0)