Spaces:
Sleeping
Sleeping
Sync from GitHub: dcdbd755536453bb053dd732d7d25cb3ad5a51c2
Browse files- Dockerfile +27 -9
Dockerfile
CHANGED
|
@@ -41,6 +41,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 41 |
build-essential \
|
| 42 |
ca-certificates \
|
| 43 |
curl \
|
|
|
|
|
|
|
|
|
|
| 44 |
&& rm -rf /var/lib/apt/lists/*
|
| 45 |
|
| 46 |
# HF Spaces convention: non-root user with UID 1000
|
|
@@ -57,27 +60,42 @@ ENV HOME=/home/user \
|
|
| 57 |
WORKDIR /home/user/bitnet
|
| 58 |
RUN git clone --recursive https://github.com/microsoft/BitNet.git /home/user/bitnet
|
| 59 |
|
| 60 |
-
# Install BitNet's Python build/utility deps
|
|
|
|
|
|
|
| 61 |
RUN pip install --no-cache-dir --user -r /home/user/bitnet/requirements.txt
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
#
|
| 65 |
-
#
|
|
|
|
|
|
|
| 66 |
RUN cd /home/user/bitnet \
|
| 67 |
-
&&
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
# Download
|
| 70 |
-
#
|
| 71 |
-
#
|
|
|
|
| 72 |
RUN python -c "\
|
| 73 |
from huggingface_hub import snapshot_download; \
|
|
|
|
|
|
|
|
|
|
| 74 |
snapshot_download('tiiuae/Falcon3-10B-Instruct-1.58bit-GGUF', \
|
| 75 |
local_dir='/home/user/models/falcon3-10b-gguf', \
|
| 76 |
allow_patterns=['*.gguf'])"
|
| 77 |
|
| 78 |
# Paths exposed to app.py via env vars
|
| 79 |
ENV BITNET_CPP_BINARY=/home/user/bitnet/build/bin/llama-cli
|
| 80 |
-
ENV BITNET_CHAT_GGUF_DIR=/home/user/
|
| 81 |
ENV FALCON_EXTRACTOR_GGUF_DIR=/home/user/models/falcon3-10b-gguf
|
| 82 |
|
| 83 |
# ββ Python app deps + repo ββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 41 |
build-essential \
|
| 42 |
ca-certificates \
|
| 43 |
curl \
|
| 44 |
+
pkg-config \
|
| 45 |
+
libcurl4-openssl-dev \
|
| 46 |
+
libssl-dev \
|
| 47 |
&& rm -rf /var/lib/apt/lists/*
|
| 48 |
|
| 49 |
# HF Spaces convention: non-root user with UID 1000
|
|
|
|
| 60 |
WORKDIR /home/user/bitnet
|
| 61 |
RUN git clone --recursive https://github.com/microsoft/BitNet.git /home/user/bitnet
|
| 62 |
|
| 63 |
+
# Install BitNet's Python build/utility deps (gguf, huggingface_hub,
|
| 64 |
+
# numpy, torch-cpu, etc. β used by their conversion + download scripts,
|
| 65 |
+
# which we're about to bypass for the compile, but keep for ggml tools).
|
| 66 |
RUN pip install --no-cache-dir --user -r /home/user/bitnet/requirements.txt
|
| 67 |
|
| 68 |
+
# Compile llama-cli directly via cmake. Bypasses setup_env.py (which
|
| 69 |
+
# swallows cmake errors into logs/compile.log with no way to see them
|
| 70 |
+
# on build failure). -j 2 limits parallel compile jobs so LLVM kernel
|
| 71 |
+
# compilation doesn't OOM the build runner. On compile failure, dump
|
| 72 |
+
# all cmake + compile logs so next-iteration debugging has signal.
|
| 73 |
RUN cd /home/user/bitnet \
|
| 74 |
+
&& cmake -B build \
|
| 75 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 76 |
+
-DBITNET_X86_TL2=ON \
|
| 77 |
+
&& (cmake --build build -j 2 --target llama-cli || \
|
| 78 |
+
(echo "==================== BUILD FAILED ====================" && \
|
| 79 |
+
find /home/user/bitnet -name "CMakeError.log" -o -name "CMakeOutput.log" -o -name "compile.log" 2>/dev/null | \
|
| 80 |
+
while read f; do echo "=== $f ===" && cat "$f" || true; done ; \
|
| 81 |
+
exit 1))
|
| 82 |
|
| 83 |
+
# Download GGUF weights directly via huggingface_hub (decoupled from
|
| 84 |
+
# the BitNet repo's preprocess scripts since those assume a specific
|
| 85 |
+
# directory layout). Both models' GGUF files land in known dirs that
|
| 86 |
+
# BitnetCppClient.resolve_gguf finds at runtime.
|
| 87 |
RUN python -c "\
|
| 88 |
from huggingface_hub import snapshot_download; \
|
| 89 |
+
snapshot_download('microsoft/bitnet-b1.58-2B-4T-gguf', \
|
| 90 |
+
local_dir='/home/user/models/bitnet-2b-gguf', \
|
| 91 |
+
allow_patterns=['*.gguf']); \
|
| 92 |
snapshot_download('tiiuae/Falcon3-10B-Instruct-1.58bit-GGUF', \
|
| 93 |
local_dir='/home/user/models/falcon3-10b-gguf', \
|
| 94 |
allow_patterns=['*.gguf'])"
|
| 95 |
|
| 96 |
# Paths exposed to app.py via env vars
|
| 97 |
ENV BITNET_CPP_BINARY=/home/user/bitnet/build/bin/llama-cli
|
| 98 |
+
ENV BITNET_CHAT_GGUF_DIR=/home/user/models/bitnet-2b-gguf
|
| 99 |
ENV FALCON_EXTRACTOR_GGUF_DIR=/home/user/models/falcon3-10b-gguf
|
| 100 |
|
| 101 |
# ββ Python app deps + repo ββββββββββββββββββββββββββββββββββββββββββ
|