@@ -8,13 +8,33 @@ WORKDIR /opt/app-root/bin
88# OS Packages needs to be installed as root
99USER 0
1010
11+ ARG TARGETARCH
12+
1113# upgrade first to avoid fixable vulnerabilities begin
1214RUN dnf -y upgrade --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=0 \
1315 && dnf clean all -y
1416# upgrade first to avoid fixable vulnerabilities end
1517
16- # Install useful OS packages
17- RUN dnf install -y mesa-libGL skopeo libxcrypt-compat && dnf clean all && rm -rf /var/cache/yum
18+ # Install useful OS packages (and dev tools for ppc64le only)
19+ RUN --mount=type=cache,target=/var/cache/dnf \
20+ echo "Building for architecture: ${TARGETARCH}" && \
21+ if [ "$TARGETARCH" = "ppc64le" ]; then \
22+ PACKAGES="mesa-libGL skopeo libxcrypt-compat gcc-toolset-13 make wget unzip rust cargo unixODBC-devel cmake ninja-build"; \
23+ else \
24+ PACKAGES="mesa-libGL skopeo libxcrypt-compat"; \
25+ fi && \
26+ echo "Installing: $PACKAGES" && \
27+ dnf install -y --nogpgcheck --allowerasing --nobest $PACKAGES && \
28+ dnf clean all && rm -rf /var/cache/yum
29+
30+ RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
31+ echo 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/' >> /etc/profile.d/ppc64le.sh && \
32+ echo 'export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH' >> /etc/profile.d/ppc64le.sh && \
33+ echo 'export OPENBLAS_VERSION=0.3.30' >> /etc/profile.d/ppc64le.sh && \
34+ echo 'export ONNX_VERSION=1.19.0' >> /etc/profile.d/ppc64le.sh && \
35+ echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> /etc/profile.d/ppc64le.sh; \
36+ echo 'export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1' >> /etc/profile.d/ppc64le.sh; \
37+ fi
1838
1939# Other apps and tools installed as default user
2040USER 1001
@@ -30,11 +50,64 @@ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/oc
3050 rm -f /tmp/openshift-client-linux.tar.gz
3151# Install the oc client end
3252
53+ ###################################
54+ # openblas builder stage for ppc64le
55+ ##################################
56+
57+ FROM base AS openblas-builder
58+ USER root
59+ WORKDIR /root
60+
61+ ARG TARGETARCH
62+
63+ ENV OPENBLAS_VERSION=0.3.30
64+
65+ RUN echo "openblas-builder stage TARGETARCH: ${TARGETARCH}"
66+
67+ # Download and build OpenBLAS
68+ RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
69+ source /opt/rh/gcc-toolset-13/enable && \
70+ wget https://github.com/OpenMathLib/OpenBLAS/releases/download/v${OPENBLAS_VERSION}/OpenBLAS-${OPENBLAS_VERSION}.zip && \
71+ unzip OpenBLAS-${OPENBLAS_VERSION}.zip && cd OpenBLAS-${OPENBLAS_VERSION} && \
72+ make -j$(nproc) TARGET=POWER9 BINARY=64 USE_OPENMP=1 USE_THREAD=1 NUM_THREADS=120 DYNAMIC_ARCH=1 INTERFACE64=0; \
73+ else \
74+ echo "Not ppc64le, skipping OpenBLAS build" && mkdir -p /root/dummy; \
75+ fi
76+
77+ ###################################
78+ # onnx builder stage for ppc64le
79+ ###################################
80+
81+ FROM base AS onnx-builder
82+ USER root
83+ WORKDIR /root
84+
85+ ARG TARGETARCH
86+ ENV ONNX_VERSION=1.19.0
87+
88+ RUN echo "onnx-builder stage TARGETARCH: ${TARGETARCH}"
89+
90+ RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
91+ source /opt/rh/gcc-toolset-13/enable && \
92+ git clone --recursive https://github.com/onnx/onnx.git && \
93+ cd onnx && git checkout v${ONNX_VERSION} && \
94+ git submodule update --init --recursive && \
95+ pip install -r requirements.txt && \
96+ export CMAKE_ARGS="-DPython3_EXECUTABLE=$(which python3.12)" && \
97+ pip wheel . -w /onnx_wheels; \
98+ else \
99+ echo "Not ppc64le, skipping ONNX build" && mkdir -p /onnx_wheels; \
100+ fi
101+
102+ # Create dummy control file
103+ RUN touch /tmp/control
104+
33105#######################
34106# runtime-datascience #
35107#######################
36108FROM base AS runtime-datascience
37109
110+ ARG TARGETARCH
38111ARG DATASCIENCE_SOURCE_CODE=runtimes/datascience/ubi9-python-3.12
39112
40113LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
@@ -48,18 +121,46 @@ LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
48121 io.openshift.build.image="quay.io/opendatahub/workbench-images:runtime-datascience-ubi9-python-3.12"
49122
50123WORKDIR /opt/app-root/bin
124+ USER 0
125+
126+ # Install ppc64le-built wheels if available
127+ COPY --from=openblas-builder /root/OpenBLAS-* /openblas
128+ COPY --from=onnx-builder /tmp/control /dev/null
129+ COPY --from=onnx-builder /onnx_wheels /tmp/onnx_wheels
130+
131+ RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
132+ echo "Installing ppc64le ONNX wheels and OpenBLAS..." && \
133+ HOME=/root pip install /tmp/onnx_wheels/*.whl && \
134+ if [ -d "/openblas" ] && [ "$(ls -A /openblas 2>/dev/null)" ]; then \
135+ PREFIX=/usr/local make -C /openblas install; \
136+ fi && rm -rf /openblas /tmp/onnx_wheels; \
137+ else \
138+ echo "Skipping architecture-specific wheel installs for (${TARGETARCH})" && \
139+ rm -rf /tmp/wheels /openblas /tmp/onnx_wheels; \
140+ fi
51141
52142# Install Python packages from requirements.txt
53143COPY ${DATASCIENCE_SOURCE_CODE}/pylock.toml ./
54144# Copy Elyra dependencies for air-gapped enviroment
55145COPY ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
56146
57- RUN echo "Installing softwares and packages" && \
147+ RUN --mount=type=cache,target=/root/.cache/pip \
148+ echo "Installing softwares and packages" && \
149+ if [ "$TARGETARCH" = "ppc64le" ]; then \
150+ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; \
151+ export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH; \
152+ GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 && \
153+ pip install ml-dtypes && \
154+ uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml; \
155+ else \
58156 # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
59157 # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
60- uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \
61- # Fix permissions to support pip in Openshift environments \
158+ uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml; \
159+ fi && \
160+ # Fix permissions to support pip in Openshift environments
62161 chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
63162 fix-permissions /opt/app-root -P
64163
164+ USER 1001
165+
65166WORKDIR /opt/app-root/src
0 commit comments