11ARG GCC_VERSION=15.2.0
22ARG UBUNTU_VERSION=24.04
33
4- # ## Build OpenBLAS stage
5- FROM --platform=linux/s390x gcc:${GCC_VERSION} AS build-openblas
6-
7- ARG OPENBLAS_THREADS=8
8-
9- RUN --mount=type=cache,target=/var/cache/apt \
10- --mount=type=cache,target=/var/lib/apt/lists \
11- apt update -y && \
12- apt upgrade -y && \
13- apt install -y --no-install-recommends \
14- git pkg-config && \
15- rm -rf /var/lib/apt/lists/*
16-
17- WORKDIR /build
18- RUN git clone https://github.com/taronaeo/OpenBLAS-s390x /build
19-
20- RUN export NUM_THREADS=${OPENBLAS_THREADS} && \
21- export OPENBLAS_NUM_THREADS=$NUM_THREADS && \
22- export GOTO_NUM_THREADS=$NUM_THREADS && \
23- export OMP_NUM_THREADS=$NUM_THREADS && \
24- make -j $(nproc) USE_OPENMP=1 && \
25- make -j $(nproc) USE_OPENMP=1 PREFIX=/opt/openblas-libs install
26-
27-
284# ## Build Llama.cpp stage
29- FROM --platform=linux/s390x gcc:${GCC_VERSION} AS build-llama
5+ FROM --platform=linux/s390x gcc:${GCC_VERSION} AS build
306
317RUN --mount=type=cache,target=/var/cache/apt \
328 --mount=type=cache,target=/var/lib/apt/lists \
339 apt update -y && \
3410 apt upgrade -y && \
3511 apt install -y --no-install-recommends \
36- git cmake ccache ninja-build libcurl4-openssl-dev && \
12+ git cmake ccache ninja-build \
13+ # WARNING: Do not use libopenblas-openmp-dev. libopenblas-dev is faster.
14+ libopenblas-dev libcurl4-openssl-dev && \
3715 rm -rf /var/lib/apt/lists/*
3816
3917WORKDIR /app
4018COPY . .
41- COPY --from=build-openblas /opt/openblas-libs /opt/openblas-libs
4219
4320RUN --mount=type=cache,target=/root/.ccache \
4421 --mount=type=cache,target=/app/build \
@@ -50,9 +27,7 @@ RUN --mount=type=cache,target=/root/.ccache \
5027 -DGGML_BACKEND_DL=OFF \
5128 -DGGML_NATIVE=OFF \
5229 -DGGML_BLAS=ON \
53- -DGGML_BLAS_VENDOR=OpenBLAS \
54- -DBLAS_LIBRARIES="/opt/openblas-libs/lib/libopenblas.so" \
55- -DBLAS_INCLUDE_DIRS="/opt/openblas-libs/include" && \
30+ -DGGML_BLAS_VENDOR=OpenBLAS && \
5631 cmake --build build --config Release -j $(nproc) && \
5732 cmake --install build --prefix /opt/llama.cpp
5833
@@ -68,12 +43,9 @@ COPY requirements /opt/llama.cpp/gguf-py/requirements
6843FROM --platform=linux/s390x scratch AS collector
6944
7045# Copy llama.cpp binaries and libraries
71- COPY --from=build-llama /opt/llama.cpp/bin /llama.cpp/bin
72- COPY --from=build-llama /opt/llama.cpp/lib /llama.cpp/lib
73- COPY --from=build-llama /opt/llama.cpp/gguf-py /llama.cpp/gguf-py
74-
75- # Copy patched OpenBLAS libraries
76- COPY --from=build-openblas /opt/openblas-libs/lib /llama.cpp/lib
46+ COPY --from=build /opt/llama.cpp/bin /llama.cpp/bin
47+ COPY --from=build /opt/llama.cpp/lib /llama.cpp/lib
48+ COPY --from=build /opt/llama.cpp/gguf-py /llama.cpp/gguf-py
7749
7850
7951# ## Base image
@@ -83,7 +55,8 @@ RUN --mount=type=cache,target=/var/cache/apt \
8355 --mount=type=cache,target=/var/lib/apt/lists \
8456 apt update -y && \
8557 apt install -y --no-install-recommends \
86- curl libgfortran5 && \
58+ # WARNING: Do not use libopenblas-openmp-dev. libopenblas-dev is faster.
59+ curl libgomp1 libopenblas-dev && \
8760 apt autoremove -y && \
8861 apt clean -y && \
8962 rm -rf /tmp/* /var/tmp/* && \
0 commit comments