FROM runpod/pytorch:1.5.0-cu1320-torch2130-ubuntu2404
WORKDIR /root

RUN mkdir llama.cpp
COPY --exclude=build/ llama.cpp ./llama.cpp/
WORKDIR /root/llama.cpp
ENV LD_LIBRARY_PATH=/usr/local/cuda-13.2/compat:${LD_LIBRARY_PATH}
ENV LIBRARY_PATH=/usr/local/cuda-13.2/compat:${LIBRARY_PATH}

RUN cmake -B build -S . \
     -DCMAKE_BUILD_TYPE=Release \
     -DGGML_CUDA=ON \
     -DCMAKE_CUDA_ARCHITECTURES=120 \
     -DLLAMA_BUILD_TESTS=OFF \
     -DLLAMA_BUILD_EXAMPLES=ON \
    && cmake --build build -j$(nproc) \
    && cmake --build build --target install \
    && rm -rf build

WORKDIR /root
RUN git clone https://github.com/silveroxides/convert_to_quant && cd convert_to_quant && pip install -r requirements.txt && pip install .

RUN mkdir nvfp4_gguf_quant
WORKDIR /root/nvfp4_gguf_quant
COPY --exclude=__pycache__ nvfp4gguf ./nvfp4gguf
COPY --chmod=0644 gguf_to_nvfp4_gguf.py hf_to_nvfp4_gguf.py hf_to_nvfp4_safetensors.py requirements.txt safetensors_to_nvfp4_gguf.py .

RUN pip install -r requirements.txt
COPY --chmod=0644 docker/README.txt /workspace/README.txt
COPY --chmod=0755 docker/hf_to_nvfp4_gguf docker/hf_to_nvfp4_safetensors docker/gguf_to_nvfp4_gguf docker/safetensors_to_nvfp4_gguf /usr/local/bin/

RUN apt remove -y python3-cryptography && pip install heretic-llm

WORKDIR /workspace

