Felipe97/llama-cpp-compiled
01.1k
1ARG UBUNTU_VERSION=24.042 3# This needs to generally match the container host's environment.4ARG ROCM_VERSION=7.2.15ARG AMDGPU_VERSION=7.2.16 7# Target the ROCm build image8ARG BASE_ROCM_DEV_CONTAINER=docker.io/rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete9 10ARG BUILD_DATE=N/A11ARG APP_VERSION=N/A12ARG APP_REVISION=N/A13 14ARG NODE_VERSION=2415 16FROM docker.io/node:$NODE_VERSION AS web17 18ARG APP_VERSION19 20WORKDIR /app/tools/ui21 22COPY tools/ui/package.json tools/ui/package-lock.json ./23RUN npm ci24 25COPY tools/ui/ ./26RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build27 28### Build image29FROM ${BASE_ROCM_DEV_CONTAINER} AS build30 31# Unless otherwise specified, we make a fat build.32# This is mostly tied to rocBLAS supported archs.33# check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-7.2.1/reference/system-requirements.html34# check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityrad/native_linux/native_linux_compatibility.html35# check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityryz/native_linux/native_linux_compatibility.html36 37ARG ROCM_DOCKER_ARCH='gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201'38 39# Set ROCm architectures40ENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}41 42RUN apt-get update \43 && apt-get install -y \44 build-essential \45 cmake \46 git \47 libssl-dev \48 curl \49 libgomp150 51WORKDIR /app52 53COPY . .54 55COPY --from=web /app/tools/ui/dist tools/ui/dist56 57RUN HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \58 cmake -S . -B build \59 -DGGML_HIP=ON \60 -DAMDGPU_TARGETS="$ROCM_DOCKER_ARCH" \61 -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON \62 -DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_TESTS=OFF \63 && cmake --build build --config Release -j$(nproc)64 65RUN mkdir -p /app/lib \66 && find build -name "*.so*" -exec cp -P {} /app/lib \;67 68RUN mkdir -p /app/full \69 && cp build/bin/* /app/full \70 && cp *.py /app/full \71 && cp -r conversion /app/full \72 && cp -r gguf-py /app/full \73 && cp -r requirements /app/full \74 && cp requirements.txt /app/full \75 && cp .devops/tools.sh /app/full/tools.sh76 77## Base image78FROM ${BASE_ROCM_DEV_CONTAINER} AS base79 80ARG BUILD_DATE=N/A81ARG APP_VERSION=N/A82ARG APP_REVISION=N/A83ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp84ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp85LABEL org.opencontainers.image.created=$BUILD_DATE \86 org.opencontainers.image.version=$APP_VERSION \87 org.opencontainers.image.revision=$APP_REVISION \88 org.opencontainers.image.title="llama.cpp" \89 org.opencontainers.image.description="LLM inference in C/C++" \90 org.opencontainers.image.url=$IMAGE_URL \91 org.opencontainers.image.source=$IMAGE_SOURCE92 93RUN apt-get update \94 && apt-get install -y libgomp1 curl ffmpeg \95 && apt autoremove -y \96 && apt clean -y \97 && rm -rf /tmp/* /var/tmp/* \98 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \99 && find /var/cache -type f -delete100 101COPY --from=build /app/lib/ /app102 103### Full104FROM base AS full105 106COPY --from=build /app/full /app107 108WORKDIR /app109 110RUN apt-get update \111 && apt-get install -y \112 git \113 python3-pip \114 python3 \115 python3-wheel \116 && pip install --break-system-packages --upgrade setuptools \117 && pip install --break-system-packages -r requirements.txt \118 && apt autoremove -y \119 && apt clean -y \120 && rm -rf /tmp/* /var/tmp/* \121 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \122 && find /var/cache -type f -delete123 124ENTRYPOINT ["/app/tools.sh"]125 126### Light, CLI only127FROM base AS light128 129COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app130 131WORKDIR /app132 133ENTRYPOINT [ "/app/llama-cli" ]134 135### Server, Server only136FROM base AS server137 138ENV LLAMA_ARG_HOST=0.0.0.0139 140COPY --from=build /app/full/llama /app/full/llama-server /app141 142WORKDIR /app143 144HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]145 146ENTRYPOINT [ "/app/llama-server" ]147 