Spaces:
Build error
Build error
Upload 7 files
Browse files- Dockerfile +6 -15
- app.py +2 -0
Dockerfile
CHANGED
|
@@ -1,32 +1,23 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Install
|
| 4 |
-
# We keep build tools and musl for compatibility.
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
build-essential \
|
| 7 |
cmake \
|
| 8 |
-
libopenblas-dev \
|
| 9 |
-
libopenblas0 \
|
| 10 |
pkg-config \
|
| 11 |
-
musl \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
# Fix for musl-linked wheels
|
| 15 |
-
RUN ln -s /lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 || true
|
| 16 |
-
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
# Install Python deps
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
# We
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
--prefer-binary \
|
| 29 |
-
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
|
| 30 |
|
| 31 |
COPY . .
|
| 32 |
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Install minimal build tools
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
build-essential \
|
| 6 |
cmake \
|
|
|
|
|
|
|
| 7 |
pkg-config \
|
|
|
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
# Install Python deps
|
| 13 |
COPY requirements.txt .
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
+
# Build the LATEST llama-cpp-python from source.
|
| 17 |
+
# We disable BLAS (OpenBLAS/OpenCL) to significantly speed up compilation
|
| 18 |
+
# and avoid the 20-minute Hugging Face build timeout.
|
| 19 |
+
# Standard CPU optimization is still very fast for a 4B model.
|
| 20 |
+
RUN CMAKE_ARGS="-DGGML_BLAS=OFF" pip install --no-cache-dir llama-cpp-python
|
|
|
|
|
|
|
| 21 |
|
| 22 |
COPY . .
|
| 23 |
|
app.py
CHANGED
|
@@ -28,7 +28,9 @@ print(f"Model downloaded: {model_path}")
|
|
| 28 |
print(f"File size: {os.path.getsize(model_path) / (1024*1024):.2f} MB")
|
| 29 |
|
| 30 |
# Import llama_cpp after ensuring it's installed
|
|
|
|
| 31 |
from llama_cpp import Llama
|
|
|
|
| 32 |
|
| 33 |
# CPU thread count — match HF free tier (2 vCPUs)
|
| 34 |
N_THREADS = int(os.environ.get("N_THREADS", "2"))
|
|
|
|
| 28 |
print(f"File size: {os.path.getsize(model_path) / (1024*1024):.2f} MB")
|
| 29 |
|
| 30 |
# Import llama_cpp after ensuring it's installed
|
| 31 |
+
import llama_cpp
|
| 32 |
from llama_cpp import Llama
|
| 33 |
+
print(f"llama-cpp-python version: {llama_cpp.__version__}")
|
| 34 |
|
| 35 |
# CPU thread count — match HF free tier (2 vCPUs)
|
| 36 |
N_THREADS = int(os.environ.get("N_THREADS", "2"))
|