Skip to content

Commit b739607

Browse files
feat(ppc64le): build runtime datascience image on ppc64le (#2215)
Signed-off-by: AaruniAggarwal <[email protected]> Co-authored-by: Jiri Daněk <[email protected]>
1 parent ad79849 commit b739607

File tree

6 files changed

+149
-58
lines changed

6 files changed

+149
-58
lines changed

.tekton/odh-pipeline-runtime-datascience-cpu-py312-ubi9-pull-request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ spec:
3636
- name: build-platforms
3737
value:
3838
- linux/x86_64
39+
- linux/ppc64le
3940
- linux/s390x
4041
- name: dockerfile
4142
value: runtimes/datascience/ubi9-python-3.12/Dockerfile.cpu

.tekton/odh-pipeline-runtime-minimal-cpu-py312-ubi9-pull-request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ spec:
3737
value:
3838
- linux/x86_64
3939
- linux/arm64
40+
- linux/ppc64le
4041
- linux/s390x
4142
- name: dockerfile
4243
value: runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu

runtimes/datascience/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ WORKDIR /opt/app-root/bin
1515
# OS Packages needs to be installed as root
1616
USER 0
1717

18+
ARG TARGETARCH
19+
1820
# upgrade first to avoid fixable vulnerabilities begin
1921
RUN dnf -y upgrade --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=0 \
2022
&& dnf clean all -y
@@ -28,11 +30,24 @@ RUN --mount=type=cache,target=/var/cache/dnf \
2830
if [ "$TARGETARCH" = "s390x" ]; then \
2931
PACKAGES="$PACKAGES gcc gcc-c++ make openssl-devel autoconf automake libtool cmake python3-devel pybind11-devel openblas-devel unixODBC-devel openssl zlib-devel"; \
3032
fi && \
33+
if [ "$TARGETARCH" = "ppc64le" ]; then \
34+
PACKAGES="$PACKAGES git gcc-toolset-13 make wget unzip rust cargo unixODBC-devel cmake ninja-build"; \
35+
fi && \
3136
if [ -n "$PACKAGES" ]; then \
37+
echo "Installing: $PACKAGES" && \
3238
dnf install -y $PACKAGES && \
3339
dnf clean all && rm -rf /var/cache/yum; \
3440
fi
3541

42+
RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
43+
echo 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/' >> /etc/profile.d/ppc64le.sh && \
44+
echo 'export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH' >> /etc/profile.d/ppc64le.sh && \
45+
echo 'export OPENBLAS_VERSION=0.3.30' >> /etc/profile.d/ppc64le.sh && \
46+
echo 'export ONNX_VERSION=1.19.0' >> /etc/profile.d/ppc64le.sh && \
47+
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> /etc/profile.d/ppc64le.sh && \
48+
echo 'export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1' >> /etc/profile.d/ppc64le.sh; \
49+
fi
50+
3651
# For s390x only, set ENV vars and install Rust
3752
RUN if [ "$TARGETARCH" = "s390x" ]; then \
3853
# Install Rust and set up environment
@@ -127,6 +142,55 @@ RUN --mount=type=cache,target=/root/.cache/pip \
127142
mkdir -p /tmp/wheels; \
128143
fi
129144

145+
###################################
146+
# openblas builder stage for ppc64le
147+
##################################
148+
149+
FROM cpu-base AS openblas-builder
150+
USER root
151+
WORKDIR /root
152+
153+
ARG TARGETARCH
154+
155+
ENV OPENBLAS_VERSION=0.3.30
156+
157+
RUN echo "openblas-builder stage TARGETARCH: ${TARGETARCH}"
158+
159+
# Download and build OpenBLAS
160+
RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
161+
source /opt/rh/gcc-toolset-13/enable && \
162+
wget https://github.com/OpenMathLib/OpenBLAS/releases/download/v${OPENBLAS_VERSION}/OpenBLAS-${OPENBLAS_VERSION}.zip && \
163+
unzip OpenBLAS-${OPENBLAS_VERSION}.zip && cd OpenBLAS-${OPENBLAS_VERSION} && \
164+
make -j$(nproc) TARGET=POWER9 BINARY=64 USE_OPENMP=1 USE_THREAD=1 NUM_THREADS=120 DYNAMIC_ARCH=1 INTERFACE64=0; \
165+
else \
166+
echo "Not ppc64le, skipping OpenBLAS build" && mkdir -p /root/OpenBLAS-dummy; \
167+
fi
168+
169+
###################################
170+
# onnx builder stage for ppc64le
171+
###################################
172+
173+
FROM cpu-base AS onnx-builder
174+
USER root
175+
WORKDIR /root
176+
177+
ARG TARGETARCH
178+
ENV ONNX_VERSION=1.19.0
179+
180+
RUN echo "onnx-builder stage TARGETARCH: ${TARGETARCH}"
181+
182+
RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
183+
source /opt/rh/gcc-toolset-13/enable && \
184+
git clone --recursive https://github.com/onnx/onnx.git && \
185+
cd onnx && git checkout v${ONNX_VERSION} && \
186+
git submodule update --init --recursive && \
187+
pip install -r requirements.txt && \
188+
export CMAKE_ARGS="-DPython3_EXECUTABLE=$(which python3.12)" && \
189+
pip wheel . -w /onnx_wheels; \
190+
else \
191+
echo "Not ppc64le, skipping ONNX build" && mkdir -p /onnx_wheels; \
192+
fi
193+
130194
#######################
131195
# runtime-datascience #
132196
#######################
@@ -146,6 +210,22 @@ LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
146210
io.openshift.build.image="quay.io/opendatahub/workbench-images:runtime-datascience-ubi9-python-3.12"
147211

148212
WORKDIR /opt/app-root/bin
213+
USER 0
214+
215+
# Install ppc64le-built wheels if available
216+
COPY --from=openblas-builder /root/OpenBLAS-* /openblas
217+
COPY --from=onnx-builder /onnx_wheels /tmp/onnx_wheels
218+
219+
RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
220+
echo "Installing ppc64le ONNX wheels and OpenBLAS..." && \
221+
HOME=/root pip install /tmp/onnx_wheels/*.whl && \
222+
if [ -d "/openblas" ] && [ "$(ls -A /openblas 2>/dev/null)" ]; then \
223+
PREFIX=/usr/local make -C /openblas install; \
224+
fi && rm -rf /openblas /tmp/onnx_wheels; \
225+
else \
226+
echo "Skipping architecture-specific wheel installs for (${TARGETARCH})" && \
227+
rm -rf /tmp/wheels /openblas /tmp/onnx_wheels; \
228+
fi
149229

150230
USER 0
151231
# Copy wheels from build stage (s390x only)
@@ -164,7 +244,13 @@ COPY ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
164244

165245
RUN --mount=type=cache,target=/root/.cache/pip \
166246
echo "Installing softwares and packages" && \
167-
if [ "$TARGETARCH" = "s390x" ]; then \
247+
if [ "$TARGETARCH" = "ppc64le" ]; then \
248+
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; \
249+
export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH; \
250+
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 \
251+
pip install ml-dtypes && \
252+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml; \
253+
elif [ "$TARGETARCH" = "s390x" ]; then \
168254
# For s390x, we need special flags and environment variables for building packages
169255
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 \
170256
CFLAGS="-O3" CXXFLAGS="-O3" \

0 commit comments

Comments
 (0)