90 lignes
4.0 KiB
Docker
90 lignes
4.0 KiB
Docker
### LLaMACpp Builder Container with rocm for GPUs
|
|
### Usa le build lemonade-sdk/llamacpp-rocm (per-target: gfx90a, gfx908, gfx103X, gfx110X, gfx1150, gfx1151, gfx120X)
|
|
###
|
|
### BUILD (gfx1151, default):
|
|
### podman build -t llamacpp:rocm -f llamacpp-rocm.Containerfile .
|
|
### BUILD (gfx1150):
|
|
### podman build --build-arg GPU_TARGET=gfx1150 -t llamacpp:rocm -f llamacpp-rocm.Containerfile .
|
|
### Export: podman save -o /home/badstorm/llamacpp-rocm.tar localhost/llamacpp:rocm
|
|
|
|
FROM ubuntu:26.04
|
|
|
|
ARG GPU_TARGET=gfx1151
|
|
|
|
USER root
|
|
EXPOSE 8090
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y curl unzip jq tar grep sed git ffmpeg nano python3-pip python3 python3-wheel \
|
|
&& pip install --break-system-packages --upgrade setuptools \
|
|
&& pip install --break-system-packages -U "huggingface_hub[cli]" \
|
|
&& if [ -f requirements.txt ]; then pip install --break-system-packages -r requirements.txt; fi \
|
|
&& apt autoremove -y \
|
|
&& apt clean -y \
|
|
&& rm -rf /tmp/* /var/tmp/* \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
|
|
&& find /var/cache -type f -delete
|
|
|
|
WORKDIR /app
|
|
|
|
# Prende l'ultima release lemonade-sdk/llamacpp-rocm per il target GPU richiesto
|
|
RUN curl -s https://api.github.com/repos/lemonade-sdk/llamacpp-rocm/releases/latest -o /tmp/latest.json \
|
|
&& TAG=$(jq -r '.tag_name' /tmp/latest.json) \
|
|
&& if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then \
|
|
echo "ERRORE: impossibile recuperare il tag latest"; exit 1; \
|
|
fi \
|
|
&& echo "Ultima versione llamacpp-rocm: $TAG" \
|
|
&& ASSET_URL=$(jq -r --arg t "$GPU_TARGET" '.assets[] | select(.name | test("^llama-.*-ubuntu-rocm-" + $t + "-x64\\.zip$")) | .browser_download_url' /tmp/latest.json) \
|
|
&& if [ -z "$ASSET_URL" ]; then \
|
|
echo "ERRORE: nessun asset per target ${GPU_TARGET} nella release ${TAG}"; \
|
|
echo "Asset disponibili:"; jq -r '.assets[].name' /tmp/latest.json; \
|
|
exit 1; \
|
|
fi \
|
|
&& echo "Scarico: $ASSET_URL" \
|
|
&& curl -L "$ASSET_URL" -o llama.zip \
|
|
&& unzip -q llama.zip -d /app \
|
|
&& rm llama.zip /tmp/latest.json
|
|
|
|
# Lemonade e' spesso indietro di settimane: sovrascriviamo i binari/librerie llama.cpp con l'ultima release ufficiale, tenendo le librerie ROCm bundlate da lemonade (nessuna collisione di nomi).
|
|
RUN curl -s https://api.github.com/repos/ggml-org/llama.cpp/releases/latest -o /tmp/upstream.json \
|
|
&& UP_TAG=$(jq -r '.tag_name' /tmp/upstream.json) \
|
|
&& if [ -z "$UP_TAG" ] || [ "$UP_TAG" = "null" ]; then \
|
|
echo "ERRORE: impossibile recuperare il tag latest di ggml-org/llama.cpp"; exit 1; \
|
|
fi \
|
|
&& echo "Ultima versione ufficiale llama.cpp: $UP_TAG" \
|
|
&& UP_URL=$(jq -r '.assets[] | select(.name | test("^llama-.*-bin-ubuntu-rocm-[0-9.]+-x64\\.tar\\.gz$")) | .browser_download_url' /tmp/upstream.json | head -1) \
|
|
&& if [ -z "$UP_URL" ]; then \
|
|
echo "ERRORE: nessun asset ubuntu-rocm nella release ${UP_TAG}"; \
|
|
echo "Asset disponibili:"; jq -r '.assets[].name' /tmp/upstream.json; \
|
|
exit 1; \
|
|
fi \
|
|
&& echo "Scarico: $UP_URL" \
|
|
&& curl -L "$UP_URL" -o llama-upstream.tar.gz \
|
|
&& tar -xzf llama-upstream.tar.gz -C /app --strip-components=1 \
|
|
&& rm llama-upstream.tar.gz /tmp/upstream.json
|
|
|
|
RUN find /app -maxdepth 1 -type f -exec chmod +x {} \;
|
|
|
|
WORKDIR /app
|
|
|
|
ENV PATH=/app:$PATH
|
|
ENV LD_LIBRARY_PATH=/app:$LD_LIBRARY_PATH
|
|
ENV HF_XET_HIGH_PERFORMANCE=1
|
|
ENV LLAMA_ARG_HOST=0.0.0.0
|
|
ENV LLAMA_ARG_PORT=8090
|
|
# Default single-model rimosso: in router mode il modello lo decide il preset
|
|
# (/config/preset.ini via LLAMA_ARG_MODELS_PRESET). Se un'immagine prodotta
|
|
# prima di questa modifica viene usata, il .container deve svuotare
|
|
# LLAMA_ARG_HF_REPO per evitare download non richiesti.
|
|
#ENV LLAMA_ARG_HF_REPO=unsloth/Qwen3.5-35B-A3B-GGUF:Q2_K_XL
|
|
ENV LLAMA_ARG_LOAD_MODE=none
|
|
ENV LLAMA_ARG_CTX_SIZE=128000
|
|
#ENV LLAMA_ARG_MMPROJ_URL=
|
|
#ENV LLAMA_API_KEY=""
|
|
#ENV HF_HOME=
|
|
#ENV HUGGING_FACE_HUB_TOKEN=
|
|
|
|
ENTRYPOINT ["/app/llama-server"]
|
|
CMD ["--no-warmup"]
|