File size: 1,243 Bytes
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
# 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 \
    && 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 .

# Apply your proven source code fix
RUN sed -i 's/int8_t \* y_col =/const int8_t * y_col =/g' src/ggml-bitnet-mad.cpp

# Install Python requirements
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir gradio huggingface_hub

# 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 the high-performance kernels
RUN export CC=clang && export CXX=clang++ && python3 setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s

# Copy your local app code into the container
COPY app.py .

# Expose the standard port Hugging Face looks for
EXPOSE 7860

# Run the Gradio interface
CMD ["python3", "app.py"]