@@ -15,6 +15,8 @@ WORKDIR /opt/app-root/bin
15
15
# OS Packages needs to be installed as root
16
16
USER 0
17
17
18
+ ARG TARGETARCH
19
+
18
20
# upgrade first to avoid fixable vulnerabilities begin
19
21
RUN dnf -y upgrade --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=0 \
20
22
&& dnf clean all -y
@@ -28,11 +30,24 @@ RUN --mount=type=cache,target=/var/cache/dnf \
28
30
if [ "$TARGETARCH" = "s390x" ]; then \
29
31
PACKAGES="$PACKAGES gcc gcc-c++ make openssl-devel autoconf automake libtool cmake python3-devel pybind11-devel openblas-devel unixODBC-devel openssl zlib-devel"; \
30
32
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 && \
31
36
if [ -n "$PACKAGES" ]; then \
37
+ echo "Installing: $PACKAGES" && \
32
38
dnf install -y $PACKAGES && \
33
39
dnf clean all && rm -rf /var/cache/yum; \
34
40
fi
35
41
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
+
36
51
# For s390x only, set ENV vars and install Rust
37
52
RUN if [ "$TARGETARCH" = "s390x" ]; then \
38
53
# Install Rust and set up environment
@@ -127,6 +142,55 @@ RUN --mount=type=cache,target=/root/.cache/pip \
127
142
mkdir -p /tmp/wheels; \
128
143
fi
129
144
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
+
130
194
#######################
131
195
# runtime-datascience #
132
196
#######################
@@ -146,6 +210,22 @@ LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
146
210
io.openshift.build.image="quay.io/opendatahub/workbench-images:runtime-datascience-ubi9-python-3.12"
147
211
148
212
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
149
229
150
230
USER 0
151
231
# Copy wheels from build stage (s390x only)
@@ -164,7 +244,13 @@ COPY ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
164
244
165
245
RUN --mount=type=cache,target=/root/.cache/pip \
166
246
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 \
168
254
# For s390x, we need special flags and environment variables for building packages
169
255
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 \
170
256
CFLAGS="-O3" CXXFLAGS="-O3" \
0 commit comments