Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +53 -12
Dockerfile
CHANGED
|
@@ -1,12 +1,53 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Etapa 1: Compilaci贸n de llama-server con CUDA 13.2 y Ubuntu 24.04
|
| 2 |
+
FROM nvidia/cuda:13.2.1-cudnn-devel-ubuntu24.04 AS llama-builder
|
| 3 |
+
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
+
|
| 6 |
+
# Instalamos las herramientas necesarias para compilar
|
| 7 |
+
RUN apt-get update && apt-get install -y \
|
| 8 |
+
git cmake build-essential \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
# Clonamos y compilamos llama.cpp
|
| 12 |
+
# ARCHITECTURES=89 es la clave para que corra perfecto en tu L4 (y en tu 4060)
|
| 13 |
+
RUN git clone --depth 1 https://github.com/ggerganov/llama.cpp /tmp/llama-cpp-src && \
|
| 14 |
+
cd /tmp/llama-cpp-src && \
|
| 15 |
+
cmake -B build \
|
| 16 |
+
-DGGML_CUDA=ON \
|
| 17 |
+
-DCMAKE_CUDA_ARCHITECTURES=89 \
|
| 18 |
+
-DLLAMA_BUILD_SERVER=ON \
|
| 19 |
+
-DCMAKE_BUILD_TYPE=Release && \
|
| 20 |
+
cmake --build build --target llama-server -j$(nproc) && \
|
| 21 |
+
mkdir -p /opt/llama-cpp && \
|
| 22 |
+
cp build/bin/llama-server /opt/llama-cpp/llama-server && \
|
| 23 |
+
chmod +x /opt/llama-cpp/llama-server
|
| 24 |
+
|
| 25 |
+
# Etapa 2: Imagen de ejecuci贸n (Runtime) - Mucho m谩s ligera
|
| 26 |
+
FROM nvidia/cuda:13.2.1-cudnn-runtime-ubuntu24.04
|
| 27 |
+
|
| 28 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 29 |
+
|
| 30 |
+
# Ubuntu 24.04 usa Python 3.12 por defecto
|
| 31 |
+
RUN apt-get update && apt-get install -y \
|
| 32 |
+
python3 python3-pip \
|
| 33 |
+
git git-lfs curl \
|
| 34 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 35 |
+
|
| 36 |
+
# Copiamos el binario que compilamos en la etapa anterior
|
| 37 |
+
COPY --from=llama-builder /opt/llama-cpp/llama-server /opt/llama-cpp/llama-server
|
| 38 |
+
|
| 39 |
+
WORKDIR /app
|
| 40 |
+
|
| 41 |
+
# Instalamos tus dependencias de Python
|
| 42 |
+
# Nota: En Ubuntu 24.04 usamos --break-system-packages para instalar directo en el contenedor
|
| 43 |
+
COPY requirements.txt .
|
| 44 |
+
RUN pip install --no-cache-dir --break-system-packages -r requirements.txt
|
| 45 |
+
|
| 46 |
+
# Copiamos todo tu c贸digo (app.py, modelos, etc.)
|
| 47 |
+
COPY . .
|
| 48 |
+
|
| 49 |
+
# Puerto por defecto de Hugging Face
|
| 50 |
+
EXPOSE 7860
|
| 51 |
+
|
| 52 |
+
# Iniciamos tu aplicaci贸n
|
| 53 |
+
CMD ["python3", "app.py"]
|