Created
April 18, 2026 07:56
-
-
Save davit312/29bb75cf8f38603e58b45d6e8a1f5753 to your computer and use it in GitHub Desktop.
Dockerfile for bitnet repo: https://hub.docker.com/repository/docker/davi807plus/bitnet/general
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # --- Stage 1: The Builder --- | |
| FROM python:3.12-trixie AS builder | |
| WORKDIR /app | |
| # Install build-time dependencies | |
| RUN apt update && apt install -y \ | |
| lsb-release git cmake curl | |
| # Clone and patch the code | |
| # Swap comments if don't have Bitnet local repo | |
| # RUN apt install -y git && \ | |
| # git clone --recursive https://github.com/microsoft/BitNet.git . | |
| # Swap comments with git clone | |
| COPY BitNet . | |
| # The fix for the error you encountered earlier | |
| RUN sed -i '811s/int8_t \* y_col/const int8_t \* y_col/' src/ggml-bitnet-mad.cpp | |
| # Create virtual env and build binaries | |
| RUN python3 -m venv /opt/venv | |
| ENV PATH="/opt/venv/bin:$PATH" | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| RUN wget https://apt.llvm.org/llvm.sh && \ | |
| chmod +x llvm.sh && ./llvm.sh 20 && \ | |
| ln -s /usr/bin/clang-20 /usr/bin/clang && \ | |
| ln -s /usr/bin/clang++-20 /usr/bin/clang++ | |
| RUN hf download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir models/BitNet-b1.58-2B-4T | |
| RUN python3 setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s | |
| # Cleanup | |
| RUN find /opt/venv -name "__pycache__" -type d -exec rm -rf {} + | |
| # Comment this for 'b1.58-2B-4T' tag | |
| RUN rm -rf /app/models/BitNet-b1.58-2B-4T | |
| # --- Stage 2: The Slim Runner --- | |
| FROM python:3.12-slim-trixie AS runner | |
| WORKDIR /app | |
| RUN apt update && apt install -y \ | |
| libgomp1 libstdc++6 && \ | |
| apt clean && rm -rf /var/lib/apt/lists/* | |
| # Copy the Python virtual env from builder | |
| COPY --from=builder /opt/venv /opt/venv | |
| # Copy source and compiled binaries | |
| COPY --from=builder /app /app | |
| ENV PATH="/opt/venv/bin:$PATH" | |
| # Create a small script so it works everywhere | |
| RUN echo '#!/bin/bash\npython3 /app/run_inference.py "$@"' > /usr/local/bin/bitnet && \ | |
| chmod +x /usr/local/bin/bitnet | |
| # Default command | |
| CMD ["bitnet", "-m", "models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf", "-cnv", "-p", "You are a helpful assistant."] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Manage comments on:
line
12-16to choose run git clone or notline
39-40to include or not default model file on final image