Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/MojoLlama/blob/main/docker/Dockerfile.sycl # MojoLlama Archived Mojo/MAX quantizer and serving research repository (read-only history) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `MojoLlama / docker / Dockerfile.sycl` 117 lines · 5499 bytes Raw Blame History 1 # ============================================================================= 2 # MojoLlama — Intel SYCL Dockerfile 3 # Multi-stage build: 4 # Stage 1 (builder): builds llama-server (SYCL/oneAPI) + AVX2 C kernels 5 # Stage 2 (runtime): oneAPI runtime + Python 3.11 + mojollama 6 # ============================================================================= 7 # syntax=docker/dockerfile:1 8 9 # ── Stage 1: Build llama.cpp (SYCL) + C kernels ───────────────────────── 10 FROM intel/oneapi-basekit:2025.1.0-0-devel-ubuntu22.04 AS builder 11 12 LABEL stage="builder" 13 14 RUN apt-get update && \ 15 apt-get install -y --no-install-recommends \ 16 build-essential cmake git ca-certificates gcc g++ libomp-dev \ 17 && rm -rf /var/lib/apt/lists/* 18 19 # ── Build llama-server with SYCL ──────────────────────────────────────── 20 ARG LLAMACPP_REPO=https://github.com/ggml-org/llama.cpp.git 21 ARG LLAMACPP_BRANCH=master 22 RUN git clone --depth 1 --branch "${LLAMACPP_BRANCH}" "${LLAMACPP_REPO}" /tmp/llama.cpp 23 WORKDIR /tmp/llama.cpp 24 RUN . /opt/intel/oneapi/setvars.sh --force && \ 25 mkdir -p build && cd build && \ 26 cmake .. -DCMAKE_BUILD_TYPE=Release \ 27 -DGGML_SYCL=ON \ 28 -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx \ 29 -DLLAMA_CURL=OFF -DLLAMA_SERVER_VERBOSE=OFF \ 30 -DBUILD_SHARED_LIBS=OFF -DLLAMA_CCACHE=OFF \ 31 && cmake --build . --target llama-server -- -j"$(nproc)" 32 RUN chmod +x /tmp/llama.cpp/convert_hf_to_gguf.py 33 34 # ── Build TurboEngine AVX2 C kernels ──────────────────────────────────── 35 COPY src/mojollama/kernels/ /build/kernels/ 36 COPY src/mojollama/kernels/legacy-c/turbo_kernels_v2.c /build/kernels/ 37 WORKDIR /build/kernels 38 RUN gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ 39 -o quant_kernels_omp.so quant_kernels_omp.c -lm && \ 40 gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ 41 -o cengine_batch_instr.so cengine_batch_instr.c -lm && \ 42 gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ 43 -o simd_ops.so simd_ops.c -lm && \ 44 gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC \ 45 -o gqa_attention.so gqa_attention.c -lm && \ 46 gcc -O3 -mavx2 -mfma -mf16c -shared -fPIC \ 47 -o turbo_kernels_v2.so turbo_kernels_v2.c -lm 48 49 # ── Stage 2: Runtime image ─────────────────────────────────────────────── 50 FROM intel/oneapi-basekit:2025.1.0-0-runtime-ubuntu22.04 51 52 LABEL org.opencontainers.image.title="MojoLlama SYCL" 53 LABEL org.opencontainers.image.description="LLM inference server — Intel SYCL/oneAPI GPU + TurboEngine CPU" 54 LABEL org.opencontainers.image.source="https://git.bamse.cloud/a730/MojoLlama" 55 LABEL org.opencontainers.image.licenses="Apache-2.0" 56 LABEL org.opencontainers.image.version="1.0.0" 57 58 ENV PYTHONDONTWRITEBYTECODE=1 \ 59 PYTHONUNBUFFERED=1 \ 60 PYTHONPATH=/app/src 61 62 RUN apt-get update && \ 63 apt-get install -y --no-install-recommends \ 64 curl ca-certificates libomp-dev python3-pip \ 65 && rm -rf /var/lib/apt/lists/* 66 67 RUN groupadd -r mojollama && \ 68 useradd -r -g mojollama -d /home/mojollama -m -s /sbin/nologin mojollama 69 70 # ── Copy llama-server binary ──────────────────────────────────────────── 71 COPY --from=builder --chown=root:root \ 72 /tmp/llama.cpp/build/bin/llama-server \ 73 /tmp/llama.cpp/build/bin/llama-server 74 COPY --from=builder --chown=root:root \ 75 /tmp/llama.cpp/convert_hf_to_gguf.py \ 76 /tmp/llama.cpp/convert_hf_to_gguf.py 77 RUN chmod 755 /tmp/llama.cpp/build/bin/llama-server /tmp/llama.cpp/convert_hf_to_gguf.py 78 79 # ── Copy MojoLlama source first ───────────────────────────────────────── 80 WORKDIR /app 81 COPY src/mojollama/ /app/src/mojollama/ 82 83 # ── Overwrite with freshly compiled TurboEngine AVX2 kernels ──────────── 84 COPY --from=builder --chown=root:root \ 85 /build/kernels/quant_kernels_omp.so \ 86 /build/kernels/cengine_batch_instr.so \ 87 /build/kernels/simd_ops.so \ 88 /build/kernels/gqa_attention.so \ 89 /build/kernels/turbo_kernels_v2.so \ 90 /app/src/mojollama/kernels/ 91 92 # ── Python deps (no MAX — SYCL/Intel not supported by MAX) ────────────── 93 RUN pip install --no-cache-dir gguf numpy transformers requests 94 95 # ── Pre-download TinyLlama for testing ────────────────────────────────── 96 RUN mkdir -p /models && \ 97 curl -fSL --retry 3 --retry-delay 5 \ 98 -o /models/tinyllama-1.1b.Q4_K_M.gguf \ 99 "https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf" \ 100 || echo "[WARN] TinyLlama download failed" 101 102 COPY www/ /app/www/ 103 COPY docker-entrypoint.sh /app/docker-entrypoint.sh 104 RUN chmod 755 /app/docker-entrypoint.sh 105 106 RUN mkdir -p /models /home/mojollama/.mojollama && \ 107 chown -R mojollama:mojollama /app /models /home/mojollama/.mojollama 108 109 HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ 110 CMD curl -sf http://localhost:8080/health || exit 1 111 112 EXPOSE 8080 8081 113 114 USER mojollama 115 116 ENTRYPOINT ["/app/docker-entrypoint.sh"] 117 CMD []