char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
61141f148
char/aliceai-t5-moe
1ARG UBUNTU_VERSION=24.04 2 3# This needs to generally match the container host's environment. 4ARG ROCM_VERSION=7.2.1 5ARG AMDGPU_VERSION=7.2.1 6 7# Target the ROCm build image 8ARG BASE_ROCM_DEV_CONTAINER=docker.io/rocm/dev-ubuntu-${ UBUNTU_VERSION } :${ ROCM_VERSION } -complete 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 28### Build image 29FROM ${ BASE_ROCM_DEV_CONTAINER } AS build 30 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.html 34# check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityrad/native_linux/native_linux_compatibility.html 35# check https://rocm.docs.amd.com/projects/radeon-ryzen/en/latest/docs/compatibility/compatibilityryz/native_linux/native_linux_compatibility.html 36 37ARG ROCM_DOCKER_ARCH='gfx908;gfx90a;gfx942;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201' 38 39# Set ROCm architectures 40ENV 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 libgomp1 50 51WORKDIR /app 52 53COPY . . 54 55COPY --from=web /app/tools/ui/dist tools/ui/dist 56 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.sh 76 77## Base image 78FROM ${ BASE_ROCM_DEV_CONTAINER } AS base 79 80ARG BUILD_DATE=N/A 81ARG APP_VERSION=N/A 82ARG APP_REVISION=N/A 83ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp 84ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp 85LABEL 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_SOURCE 92 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 -delete 100 101COPY --from=build /app/lib/ /app 102 103### Full 104FROM baseAS full 105 106COPY --from=build /app/full /app 107 108WORKDIR /app 109 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 -delete 123 124ENTRYPOINT ["/app/tools.sh" ] 125 126### Light, CLI only 127FROM baseAS light 128 129COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app 130 131WORKDIR /app 132 133ENTRYPOINT ["/app/llama-cli" ] 134 135### Server, Server only 136FROM baseAS server 137 138ENV LLAMA_ARG_HOST=0.0.0.0 139 140COPY --from=build /app/full/llama /app/full/llama-server /app 141 142WORKDIR /app 143 144HEALTHCHECK CMD ["curl" ,"-f" ,"http://localhost:8080/health" ] 145 146ENTRYPOINT ["/app/llama-server" ]