@@ -8,13 +8,33 @@ WORKDIR /opt/app-root/bin
8
8
# OS Packages needs to be installed as root
9
9
USER 0
10
10
11
+ ARG TARGETARCH
12
+
11
13
# upgrade first to avoid fixable vulnerabilities begin
12
14
RUN dnf -y upgrade --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=0 \
13
15
&& dnf clean all -y
14
16
# upgrade first to avoid fixable vulnerabilities end
15
17
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/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
18
38
19
39
# Other apps and tools installed as default user
20
40
USER 1001
@@ -30,11 +50,61 @@ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/oc
30
50
rm -f /tmp/openshift-client-linux.tar.gz
31
51
# Install the oc client end
32
52
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
+
33
102
#######################
34
103
# runtime-datascience #
35
104
#######################
36
105
FROM base AS runtime-datascience
37
106
107
+ ARG TARGETARCH
38
108
ARG DATASCIENCE_SOURCE_CODE=runtimes/datascience/ubi9-python-3.12
39
109
40
110
LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
@@ -48,18 +118,45 @@ LABEL name="odh-notebook-runtime-datascience-ubi9-python-3.12" \
48
118
io.openshift.build.image="quay.io/opendatahub/workbench-images:runtime-datascience-ubi9-python-3.12"
49
119
50
120
WORKDIR /opt/app-root/bin
121
+ USER 0
122
+
123
+ # Install ppc64le-built wheels if available
124
+ COPY --from=openblas-builder /root/OpenBLAS-* /openblas
125
+ COPY --from=onnx-builder /onnx_wheels /tmp/onnx_wheels
126
+
127
+ RUN if [ "$TARGETARCH" = "ppc64le" ]; then \
128
+ echo "Installing ppc64le ONNX wheels and OpenBLAS..." && \
129
+ HOME=/root pip install /tmp/onnx_wheels/*.whl && \
130
+ if [ -d "/openblas" ] && [ "$(ls -A /openblas 2>/dev/null)" ]; then \
131
+ PREFIX=/usr/local make -C /openblas install; \
132
+ fi && rm -rf /openblas /tmp/onnx_wheels; \
133
+ else \
134
+ echo "Skipping architecture-specific wheel installs for (${TARGETARCH})" && \
135
+ rm -rf /tmp/wheels /openblas /tmp/onnx_wheels; \
136
+ fi
51
137
52
138
# Install Python packages from requirements.txt
53
139
COPY ${DATASCIENCE_SOURCE_CODE}/pylock.toml ./
54
140
# Copy Elyra dependencies for air-gapped enviroment
55
141
COPY ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
56
142
57
- RUN echo "Installing softwares and packages" && \
143
+ RUN --mount=type=cache,target=/root/.cache/pip \
144
+ echo "Installing softwares and packages" && \
145
+ if [ "$TARGETARCH" = "ppc64le" ]; then \
146
+ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig; \
147
+ export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:$LD_LIBRARY_PATH; \
148
+ GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 && \
149
+ pip install ml-dtypes && \
150
+ uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml; \
151
+ else \
58
152
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
59
153
# 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 \
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
+ fi && \
156
+ # Fix permissions to support pip in Openshift environments
62
157
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
63
158
fix-permissions /opt/app-root -P
64
159
160
+ USER 1001
161
+
65
162
WORKDIR /opt/app-root/src
0 commit comments