Skip to content

Commit 8f4a228

Browse files
Update Runtime Datascience Dockerfile with ppc64le changes
Signed-off-by: AaruniAggarwal <[email protected]>
1 parent 05957e4 commit 8f4a228

File tree

3 files changed

+224
-76
lines changed

3 files changed

+224
-76
lines changed

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

Lines changed: 105 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,33 @@ WORKDIR /opt/app-root/bin
88
# OS Packages needs to be installed as root
99
USER 0
1010

11+
ARG TARGETARCH
12+
1113
# upgrade first to avoid fixable vulnerabilities begin
1214
RUN 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 git 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/dnf
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
2040
USER 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
#######################
36108
FROM base AS runtime-datascience
37109

110+
ARG TARGETARCH
38111
ARG DATASCIENCE_SOURCE_CODE=runtimes/datascience/ubi9-python-3.12
39112

40113
LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
@@ -48,18 +121,45 @@ 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

50123
WORKDIR /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 /onnx_wheels /tmp/onnx_wheels
129+
130+
RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
131+
echo "Installing ppc64le ONNX wheels and OpenBLAS..." && \
132+
HOME=/root pip install /tmp/onnx_wheels/*.whl && \
133+
if [ -d "/openblas" ] && [ "$(ls -A /openblas 2>/dev/null)" ]; then \
134+
PREFIX=/usr/local make -C /openblas install; \
135+
fi && rm -rf /openblas /tmp/onnx_wheels; \
136+
else \
137+
echo "Skipping architecture-specific wheel installs for (${TARGETARCH})" && \
138+
rm -rf /tmp/wheels /openblas /tmp/onnx_wheels; \
139+
fi
51140

52141
# Install Python packages from requirements.txt
53142
COPY ${DATASCIENCE_SOURCE_CODE}/pylock.toml ./
54143
# Copy Elyra dependencies for air-gapped enviroment
55144
COPY ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
56145

57-
RUN echo "Installing softwares and packages" && \
146+
RUN --mount=type=cache,target=/root/.cache/pip \
147+
echo "Installing softwares and packages" && \
148+
if [ "$TARGETARCH" = "ppc64le" ]; then \
149+
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; \
150+
export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH; \
151+
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 && \
152+
pip install ml-dtypes && \
153+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml; \
154+
else \
58155
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
59156
# 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 \
157+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml; \
158+
fi && \
159+
# Fix permissions to support pip in Openshift environments
62160
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
63161
fix-permissions /opt/app-root -P
64162

163+
USER 1001
164+
65165
WORKDIR /opt/app-root/src

0 commit comments

Comments
 (0)