Skip to content

Commit bd465d5

Browse files
updated manywheel docker file
1 parent c45815a commit bd465d5

File tree

1 file changed

+25
-89
lines changed

1 file changed

+25
-89
lines changed
Lines changed: 25 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,33 @@
1-
FROM --platform=linux/ppc64le docker.io/ubuntu:24.04 as base
1+
# Use UBI 9.3 as base image
2+
FROM registry.access.redhat.com/ubi9/ubi:9.3
23

3-
# Language variables
4-
ENV LC_ALL=C.UTF-8
5-
ENV LANG=C.UTF-8
6-
ENV LANGUAGE=C.UTF-8
4+
# Install necessary dependencies
5+
RUN dnf install -y \
6+
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
7+
dnf install -y git cmake ninja-build gcc-toolset-13 rust cargo \
8+
python3 python3-devel && \
9+
dnf clean all
710

8-
# Install needed OS packages (supports binary builds for torch, vision, audio, etc.)
9-
RUN apt update && apt upgrade -y && \
10-
apt install -y \
11-
build-essential \
12-
sudo \
13-
autoconf \
14-
automake \
15-
bzip2 \
16-
curl \
17-
diffutils \
18-
file \
19-
git \
20-
make \
21-
patch \
22-
perl \
23-
unzip \
24-
util-linux \
25-
wget \
26-
which \
27-
xz-utils \
28-
less \
29-
zstd \
30-
cmake \
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 \
40-
linux-headers-generic \
41-
zlib1g-dev \
42-
libbz2-1.0 \
43-
libncurses5-dev \
44-
libsqlite3-dev \
45-
libdb-dev \
46-
libpcap-dev \
47-
liblzma-dev \
48-
libffi-dev || echo "Some packages could not be installed but are non-critical."
11+
# Set Python and pip aliases to use Python 3.9
12+
RUN ln -sf /usr/bin/python3 /usr/bin/python && \
13+
ln -sf /usr/bin/pip3 /usr/bin/pip
4914

50-
# Handle linux-headers installation gracefully
51-
RUN apt-get update && \
52-
(apt install -y linux-headers-$(uname -r) || apt install -y linux-headers-generic || \
53-
echo "Skipping linux-headers installation as it is not critical") && \
54-
apt-get clean && rm -rf /var/lib/apt/lists/*
15+
COPY requirements.txt .
16+
# Install Python packages via pip
17+
RUN pip install wheel setuptools pyyaml typing_extensions expecttest
5518

56-
RUN apt-get update && apt-get install -y software-properties-common && \
57-
add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update
19+
RUN source /opt/rh/gcc-toolset-13/enable && pip install -r requirements.txt
5820

59-
RUN apt-get install -y gcc-10 g++-10
21+
# Copy the PyTorch source code into the container
22+
COPY . /workspace/pytorch
6023

61-
# Confirm git installation and add safe.directory
62-
RUN git --version || (echo "Git installation failed!" && exit 1)
63-
RUN git config --global --add safe.directory "*"
24+
# Copy the build script and make it executable
25+
COPY .github/scripts/ppc64le-build.sh /ppc64le-build.sh
26+
RUN chmod +x /ppc64le-build.sh
6427

65-
# OpenSSL setup to ensure Python has SSL support
66-
FROM base as openssl
67-
# Set ulimit to avoid segmentation faults due to resource limits
68-
RUN ulimit -s unlimited
28+
# Verify permissions and ensure Unix line endings
29+
RUN dos2unix /ppc64le-build.sh || sed -i 's/\r$//' /ppc64le-build.sh
30+
RUN chmod +x /ppc64le-build.sh
6931

70-
ADD ./common/install_openssl-ppc64le.sh install_openssl.sh
71-
RUN export CFLAGS="-O0" && \
72-
bash ./install_openssl.sh && rm install_openssl.sh
73-
ENV SSL_CERT_FILE=/opt/_internal/certs.pem
74-
75-
# EPEL for cmake
76-
FROM base as patchelf
77-
# Install patchelf
78-
ADD ./common/install_patchelf.sh install_patchelf.sh
79-
RUN bash ./install_patchelf.sh && rm install_patchelf.sh
80-
RUN cp $(which patchelf) /patchelf
81-
82-
# Python build stage
83-
FROM patchelf as python
84-
# Copy build scripts and install Python
85-
COPY manywheel/build_scripts /build_scripts
86-
ADD ./common/install_cpython.sh /build_scripts/install_cpython.sh
87-
RUN bash build_scripts/build.sh && rm -r build_scripts
88-
89-
# Final stage to copy over Python, OpenSSL, and patchelf
90-
FROM openssl as final
91-
COPY --from=python /opt/python /opt/python
92-
COPY --from=python /opt/_internal /opt/_internal
93-
COPY --from=python /opt/python/cp39-cp39/bin/auditwheel /usr/local/bin/auditwheel
94-
COPY --from=patchelf /usr/local/bin/patchelf /usr/local/bin/patchelf
95-
96-
# Optional: Clean up to reduce image size
97-
RUN rm -rf /var/lib/apt/lists/*
32+
# Use CMD to run the script
33+
CMD ["/ppc64le-build.sh"]

0 commit comments

Comments
 (0)