Spaces:
Sleeping
Sleeping
| FROM ubuntu:24.04 | |
| # โโ System dependencies โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| cmake \ | |
| curl \ | |
| wget \ | |
| ca-certificates \ | |
| python3 \ | |
| python3-pip \ | |
| python3-dev \ | |
| python3-venv \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # โโ Python env โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| RUN python3 -m venv /opt/venv | |
| ENV PATH="/opt/venv/bin:$PATH" | |
| # PyTorch CPU (conversion only โ no GPU needed) | |
| RUN pip install --upgrade pip && \ | |
| pip install --no-cache-dir \ | |
| torch==2.5.1+cpu \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| # HF ecosystem + conversion deps | |
| RUN pip install --no-cache-dir \ | |
| transformers \ | |
| huggingface_hub[cli] \ | |
| safetensors \ | |
| sentencepiece \ | |
| tiktoken \ | |
| gguf \ | |
| numpy \ | |
| tqdm | |
| # โโ Clone llama.cpp (fast โ no compile here, that happens at container start) โ | |
| # We need the source for two things: | |
| # 1. convert_hf_to_gguf.py (Python, runs immediately) | |
| # 2. llama-quantize source (compiled at runtime to avoid build timeout) | |
| RUN git clone --depth 1 https://github.com/ggml-org/llama.cpp.git /opt/llama.cpp | |
| RUN pip install --no-cache-dir -r /opt/llama.cpp/requirements.txt || true | |
| # โโ Runtime secrets โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ENV HF_TOKEN="" | |
| ENV HF_DATASET_REPO="" | |
| ENV LLAMA_CPP_DIR="/opt/llama.cpp" | |
| # โโ Working directories โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| RUN mkdir -p /workspace/model-fp8 \ | |
| /workspace/model-bf16 \ | |
| /workspace/model-gguf \ | |
| /workspace/output | |
| WORKDIR /workspace | |
| COPY scripts/ /workspace/scripts/ | |
| RUN chmod +x /workspace/scripts/*.sh | |
| ENTRYPOINT ["/bin/bash", "/workspace/scripts/entrypoint.sh"] | |