char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
5d8ccdf9d
char/aliceai-t5-moe
1ARG UBUNTU_VERSION=24.04 2# This needs to generally match the container host's environment. 3ARG CUDA_VERSION=12.8.1 4ARG GCC_VERSION=14 5# Target the CUDA build image 6ARG BASE_CUDA_DEV_CONTAINER=docker.io/nvidia/cuda:${ CUDA_VERSION } -devel-ubuntu${ UBUNTU_VERSION } 7 8ARG BASE_CUDA_RUN_CONTAINER=docker.io/nvidia/cuda:${ CUDA_VERSION } -runtime-ubuntu${ UBUNTU_VERSION } 9 10ARG BUILD_DATE=N/A 11ARG APP_VERSION=N/A 12ARG APP_REVISION=N/A 13 14ARG NODE_VERSION=24 15 16FROM docker.io/node: $ NODE_VERSION AS web 17 18ARG APP_VERSION 19 20WORKDIR /app/tools/ui 21 22COPY tools/ui/package.json tools/ui/package-lock.json ./ 23RUN npm ci 24 25COPY tools/ui/ ./ 26RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build 27 28FROM ${ BASE_CUDA_DEV_CONTAINER } AS build 29 30ARG GCC_VERSION 31# CUDA architecture to build for (defaults to all supported archs) 32ARG CUDA_DOCKER_ARCH=default 33 34RUN apt-get update && \ 35 apt-get install -y gcc-${GCC_VERSION} g++-${GCC_VERSION} build-essential cmake python3 python3-pip git libssl-dev libgomp1 36 37ENV CC=gcc-${ GCC_VERSION } CXX=g++-${ GCC_VERSION } CUDAHOSTCXX=g++-${ GCC_VERSION } 38 39WORKDIR /app 40 41COPY . . 42 43COPY --from=web /app/tools/ui/dist tools/ui/dist 44 45RUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \ 46 export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \ 47 fi && \ 48 cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ 49 cmake --build build --config Release -j$(nproc) 50 51RUN mkdir -p /app/lib && \ 52 find build -name "*.so*" -exec cp -P {} /app/lib \; 53 54RUN mkdir -p /app/full \ 55 && cp build/bin/* /app/full \ 56 && cp *.py /app/full \ 57 && cp -r conversion /app/full \ 58 && cp -r gguf-py /app/full \ 59 && cp -r requirements /app/full \ 60 && cp requirements.txt /app/full \ 61 && cp .devops/tools.sh /app/full/tools.sh 62 63## Base image 64FROM ${ BASE_CUDA_RUN_CONTAINER } AS base 65 66ARG BUILD_DATE=N/A 67ARG APP_VERSION=N/A 68ARG APP_REVISION=N/A 69ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp 70ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp 71LABEL org.opencontainers.image.created=$ BUILD_DATE \ 72 org.opencontainers.image.version=$ APP_VERSION \ 73 org.opencontainers.image.revision=$ APP_REVISION \ 74 org.opencontainers.image.title="llama.cpp" \ 75 org.opencontainers.image.description="LLM inference in C/C++" \ 76 org.opencontainers.image.url=$ IMAGE_URL \ 77 org.opencontainers.image.source=$ IMAGE_SOURCE 78 79RUN apt-get update \ 80 && apt-get install -y libgomp1 curl ffmpeg \ 81 && apt autoremove -y \ 82 && apt clean -y \ 83 && rm -rf /tmp/* /var/tmp/* \ 84 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ 85 && find /var/cache -type f -delete 86 87COPY --from=build /app/lib/ /app 88 89### Full 90FROM baseAS full 91 92COPY --from=build /app/full /app 93 94WORKDIR /app 95 96RUN apt-get update \ 97 && apt-get install -y \ 98 git \ 99 python3 \ 100 python3-pip \ 101 python3-wheel \ 102 && pip install --break-system-packages --upgrade setuptools \ 103 && pip install --break-system-packages -r requirements.txt \ 104 && apt autoremove -y \ 105 && apt clean -y \ 106 && rm -rf /tmp/* /var/tmp/* \ 107 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ 108 && find /var/cache -type f -delete 109 110 111ENTRYPOINT ["/app/tools.sh" ] 112 113### Light, CLI only 114FROM baseAS light 115 116COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app 117 118WORKDIR /app 119 120ENTRYPOINT ["/app/llama-cli" ] 121 122### Server, Server only 123FROM baseAS server 124 125ENV LLAMA_ARG_HOST=0.0.0.0 126 127COPY --from=build /app/full/llama /app/full/llama-server /app 128 129WORKDIR /app 130 131HEALTHCHECK CMD ["curl" ,"-f" ,"http://localhost:8080/health" ] 132 133ENTRYPOINT ["/app/llama-server" ]