Spaces:
Sleeping
Sleeping
File size: 1,784 Bytes
0aa64c9 b566c43 0aa64c9 35ccb82 9dd9ab5 0aa64c9 b566c43 0aa64c9 b566c43 9dd9ab5 b566c43 0c1543a b566c43 d713dbf b566c43 d713dbf b566c43 0aa64c9 b566c43 0aa64c9 b566c43 0aa64c9 e98b568 0aa64c9 b566c43 9dd9ab5 b566c43 0aa64c9 a603eca 0aa64c9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # Use an official Python runtime as a parent image
FROM python:3.12-slim
# Install system dependencies needed to compile BitNet
RUN apt-get update && apt-get install -y \
cmake \
clang \
build-essential \
git \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set up a working directory
WORKDIR /app
# Clone the BitNet repo
RUN git clone --recursive https://github.com/microsoft/BitNet.git .
# 1. Apply your proven Clang const-correctness fix
RUN sed -i 's/int8_t \* y_col =/const int8_t * y_col =/g' src/ggml-bitnet-mad.cpp
# 2. Fix the runtime "Word Salad / Gibberish" kernel bug (PR #551 / Issue #585)
RUN sed -i 's/#define QK_I2_S 64/#define QK_I2_S 128/g' src/ggml-bitnet-mad.cpp
# Install Python requirements (keeps your original pattern)
RUN pip install --no-cache-dir -r requirements.txt || true
RUN pip install --no-cache-dir gradio huggingface_hub edge-tts gTTS transformers openai-whisper
# Pre-download the model into the image so the Space boots up instantly
RUN python3 -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='microsoft/bitnet-b1.58-2B-4T-gguf', filename='ggml-model-i2_s.gguf', local_dir='models/BitNet-b1.58-2B-4T')"
# Compile kernels; verify the compiled llama-cli binary exists to prevent the post-conversion exit code 1
RUN export CC=clang && export CXX=clang++ && \
(python3 setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s || test -f build/bin/llama-cli)
# Copy your local app code into the container
COPY app.py .
# Hugging Face Spaces non-root user configuration
RUN useradd -m -u 1000 user && \
chown -R user:user /app && \
chmod -R 777 /app /tmp
USER user
# Expose the standard port Hugging Face looks for
EXPOSE 7860
# Run the Gradio interface
CMD ["python3", "app.py"] |