KBaba7/llama.cpp
0
1ARG UBUNTU_VERSION=24.042 3# This needs to generally match the container host's environment.4ARG ROCM_VERSION=6.35ARG AMDGPU_VERSION=6.36 7# Target the CUDA build image8ARG BASE_ROCM_DEV_CONTAINER=rocm/dev-ubuntu-${UBUNTU_VERSION}:${ROCM_VERSION}-complete9 10### Build image11FROM ${BASE_ROCM_DEV_CONTAINER} AS build12 13# Unless otherwise specified, we make a fat build.14# List from https://github.com/ggerganov/llama.cpp/pull/1087#issuecomment-168280787815# This is mostly tied to rocBLAS supported archs.16# gfx803, gfx900, gfx1032, gfx1101, gfx1102,not officialy supported17# gfx906 is deprecated18#check https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.2.4/reference/system-requirements.html19 20#ARG ROCM_DOCKER_ARCH='gfx803,gfx900,gfx906,gfx908,gfx90a,gfx942,gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102'21ARG ROCM_DOCKER_ARCH=gfx110022 23# Set nvcc architectured24ENV AMDGPU_TARGETS=${ROCM_DOCKER_ARCH}25# Enable ROCm26# ENV CC=/opt/rocm/llvm/bin/clang27# ENV CXX=/opt/rocm/llvm/bin/clang++28 29RUN apt-get update \30 && apt-get install -y \31 build-essential \32 cmake \33 git \34 libcurl4-openssl-dev \35 curl \36 libgomp137 38WORKDIR /app39 40COPY . .41 42RUN HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \43 cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=$ROCM_DOCKER_ARCH -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON \44 && cmake --build build --config Release -j$(nproc)45 46RUN mkdir -p /app/lib \47 && find build -name "*.so" -exec cp {} /app/lib \;48 49RUN mkdir -p /app/full \50 && cp build/bin/* /app/full \51 && cp *.py /app/full \52 && cp -r gguf-py /app/full \53 && cp -r requirements /app/full \54 && cp requirements.txt /app/full \55 && cp .devops/tools.sh /app/full/tools.sh56 57## Base image58FROM ${BASE_ROCM_DEV_CONTAINER} AS base59 60RUN apt-get update \61 && apt-get install -y libgomp1 curl\62 && apt autoremove -y \63 && apt clean -y \64 && rm -rf /tmp/* /var/tmp/* \65 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \66 && find /var/cache -type f -delete67 68COPY --from=build /app/lib/ /app69 70### Full71FROM base AS full72 73COPY --from=build /app/full /app74 75WORKDIR /app76 77RUN apt-get update \78 && apt-get install -y \79 git \80 python3-pip \81 python3 \82 python3-wheel\83 && pip install --break-system-packages --upgrade setuptools \84 && pip install --break-system-packages -r requirements.txt \85 && apt autoremove -y \86 && apt clean -y \87 && rm -rf /tmp/* /var/tmp/* \88 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \89 && find /var/cache -type f -delete90 91ENTRYPOINT ["/app/tools.sh"]92 93### Light, CLI only94FROM base AS light95 96COPY --from=build /app/full/llama-cli /app97 98WORKDIR /app99 100ENTRYPOINT [ "/app/llama-cli" ]101 102### Server, Server only103FROM base AS server104 105ENV LLAMA_ARG_HOST=0.0.0.0106 107COPY --from=build /app/full/llama-server /app108 109WORKDIR /app110 111HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]112 113ENTRYPOINT [ "/app/llama-server" ]114 