Skip to content

Commit ad61aff

Browse files
committed
added arm64 Dockerfile and workflow entry
1 parent 8ff2060 commit ad61aff

File tree

2 files changed

+144
-5
lines changed

2 files changed

+144
-5
lines changed

.devops/arm64.Dockerfile

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Args for Build actions
2+
ARG BUILDPLATFORM_builder=linux/amd64
3+
ARG BUILDPLATFORM_runner=linux/arm64
4+
ARG TARGETARCH
5+
6+
# Stage 1: Builder Docker
7+
FROM --platform=$BUILDPLATFORM_builder debian:bookworm-slim AS builder
8+
9+
# FROM ubuntu:$UBUNTU_VERSION AS builder
10+
11+
# add arm64 deps
12+
RUN dpkg --add-architecture arm64
13+
14+
# Install build dependencies
15+
RUN apt-get update && apt-get install -y \
16+
build-essential \
17+
cmake \
18+
git \
19+
curl \
20+
ninja-build \
21+
ca-certificates \
22+
libopenblas-dev \
23+
libgomp1 \
24+
libcurl4-openssl-dev \
25+
gcc-aarch64-linux-gnu \
26+
g++-aarch64-linux-gnu \
27+
libc6-dev-arm64-cross \
28+
libcurl4-openssl-dev:arm64 \
29+
libssl-dev:arm64 \
30+
&& update-ca-certificates
31+
32+
WORKDIR /workspace
33+
34+
COPY . .
35+
36+
# Set your cross compilers environment variables (adjust if needed)
37+
ENV CC64=aarch64-linux-gnu-gcc
38+
ENV CXX64=aarch64-linux-gnu-g++
39+
40+
# remove 'armv9' since gcc-12 doesn't support it
41+
RUN sed -i '/armv9/d' "ggml/src/CMakeLists.txt"
42+
43+
# Run CMake configure and build
44+
45+
RUN cmake -S . -B build \
46+
-DCMAKE_SYSTEM_NAME=Linux \
47+
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
48+
-DCMAKE_C_COMPILER=$CC64 \
49+
-DCMAKE_CXX_COMPILER=$CXX64 \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DCURL_INCLUDE_DIR=/usr/aarch64-linux-gnu/include \
52+
-DCMAKE_BUILD_TYPE=Release \
53+
-DGGML_NATIVE=OFF \
54+
-DLLAMA_BUILD_TESTS=OFF \
55+
-DGGML_BACKEND_DL=ON \
56+
-DGGML_CPU_ALL_VARIANTS=ON
57+
RUN cmake --build build -j $(nproc)
58+
59+
RUN mkdir -p /app/lib && \
60+
find build -name "*.so" -exec cp {} /app/lib \;
61+
62+
RUN mkdir -p /app/full \
63+
&& cp build/bin/* /app/full \
64+
&& cp *.py /app/full \
65+
&& cp -r gguf-py /app/full \
66+
&& cp -r requirements /app/full \
67+
&& cp requirements.txt /app/full \
68+
&& cp .devops/tools.sh /app/full/tools.sh
69+
70+
# Stage 2: Runtime
71+
FROM --platform=$BUILDPLATFORM_runner debian:bookworm-slim As base
72+
73+
#FROM ubuntu:$UBUNTU_VERSION AS base
74+
75+
# Install runtime dependencies
76+
RUN apt-get update && apt-get install -y \
77+
libopenblas-dev \
78+
libgomp1 \
79+
curl \
80+
ca-certificates \
81+
&& rm -rf /var/lib/apt/lists/*
82+
83+
# Copy built binaries from builder
84+
COPY --from=builder /app/full /app
85+
86+
# Full
87+
FROM base AS full
88+
89+
COPY --from=builder /app/full /app
90+
91+
WORKDIR /app
92+
93+
RUN apt-get update \
94+
&& apt-get install -y \
95+
git \
96+
python3 \
97+
python3-pip
98+
99+
RUN pip install --upgrade pip setuptools wheel --break-system-packages
100+
RUN pip install -r requirements.txt --break-system-packages
101+
RUN apt autoremove -y
102+
RUN apt clean -y
103+
RUN rm -rf /tmp/* /var/tmp/*
104+
RUN find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete
105+
RUN find /var/cache -type f -delete
106+
107+
ENTRYPOINT ["/app/tools.sh"]
108+
109+
# Light
110+
FROM base AS light
111+
112+
COPY --from=builder /app/full/llama-cli /app
113+
114+
WORKDIR /app
115+
116+
ENTRYPOINT [ "/app/llama-cli" ]
117+
118+
# Server
119+
FROM base AS server
120+
121+
COPY --from=builder /app/full/llama-server /app
122+
123+
WORKDIR /app
124+
125+
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
126+
127+
ENTRYPOINT [ "/app/llama-server" ]

.github/workflows/docker.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ jobs:
3939
# Note: the arm64 images are failing, which prevents the amd64 images from being built
4040
# https://github.com/ggml-org/llama.cpp/issues/11888
4141
#- { tag: "cpu", dockerfile: ".devops/cpu.Dockerfile", platforms: "linux/amd64,linux/arm64", full: true, light: true, server: true, free_disk_space: false }
42-
- { tag: "cpu", dockerfile: ".devops/cpu.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false }
43-
- { tag: "cuda", dockerfile: ".devops/cuda.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false }
44-
- { tag: "musa", dockerfile: ".devops/musa.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true }
45-
- { tag: "intel", dockerfile: ".devops/intel.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true }
46-
- { tag: "vulkan", dockerfile: ".devops/vulkan.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false }
42+
#- { tag: "cpu", dockerfile: ".devops/cpu.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false }
43+
#- { tag: "cuda", dockerfile: ".devops/cuda.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false }
44+
#- { tag: "musa", dockerfile: ".devops/musa.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true }
45+
#- { tag: "intel", dockerfile: ".devops/intel.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: true }
46+
#- { tag: "vulkan", dockerfile: ".devops/vulkan.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, free_disk_space: false }
47+
- { tag: "arm64", dockerfile: ".devops/arm64.Dockerfile", platforms: "linux/arm64", full: true, light: true, server: true, free_disk_space: false }
4748
# Note: the rocm images are failing due to a compiler error and are disabled until this is fixed to allow the workflow to complete
4849
#- {tag: "rocm", dockerfile: ".devops/rocm.Dockerfile", platforms: "linux/amd64,linux/arm64", full: true, light: true, server: true, free_disk_space: true }
4950
steps:
@@ -52,14 +53,25 @@ jobs:
5253
with:
5354
fetch-depth: 0 # preserve git history, so we can determine the build number
5455

56+
#- name: Set up QEMU
57+
# uses: docker/setup-qemu-action@v3
58+
# with:
59+
# image: tonistiigi/binfmt:qemu-v7.0.0-28
60+
61+
#- name: Set up Docker Buildx
62+
# uses: docker/setup-buildx-action@v3
63+
5564
- name: Set up QEMU
65+
if: matrix.config.platforms != 'linux/arm64'
5666
uses: docker/setup-qemu-action@v3
5767
with:
5868
image: tonistiigi/binfmt:qemu-v7.0.0-28
5969

6070
- name: Set up Docker Buildx
71+
if: matrix.config.platforms != 'linux/arm64'
6172
uses: docker/setup-buildx-action@v3
6273

74+
6375
- name: Log in to Docker Hub
6476
uses: docker/login-action@v2
6577
with:

0 commit comments

Comments
 (0)