# Strata, built FROM SOURCE (NVIDIA CUDA 13). The engine is compiled here, packaged as an engine component package and then # installed into the same runtime image as the ready-made ones (tools/docker/Dockerfile): same Terminal, same entrypoint, same /data volume. # # Most people want the ready-made images instead (nothing compiled): docs/DOCKER.md. # # Every source build needs STRATA_COMMIT: .git is not copied into the build, and the Terminal archive has to carry a COMMIT file. # This is not the ready-made image's Dockerfile, so it is named with -f; the build then reads its ignore list from # tools/docker/Dockerfile.src.dockerignore. # # docker build -t strata:src --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -f tools/docker/Dockerfile.src . # RTX 20/30/40/50 (~25 min) # docker build -t strata:src --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -f tools/docker/Dockerfile.src --build-arg CUDA_ARCHITECTURES=86 . # # one card only (faster); 86 = RTX 30, 89 = RTX 40, 120 = RTX 50 # docker build -t strata:src-cuda12 --build-arg STRATA_COMMIT=$(git rev-parse HEAD) -f tools/docker/Dockerfile.src \ # --build-arg CUDA_IMAGE=nvidia/cuda:12.9.2-devel-ubuntu24.04 \ # --build-arg CUDA_ARCHITECTURES="60;61;70;75;80;86;89" . # GTX 10 / P100 / V100 (driver 575+): the picture reader is built # for the same architectures as the engine (checked on a Tesla P40 sm_61, a Tesla P100 sm_60 and a Tesla V100 sm_70); # --build-arg BUILD_VISION=0 leaves it out # docker run --rm --gpus all -p 127.0.0.1:8080:8080 --ulimit memlock=-1 --shm-size 2g --stop-timeout 120 \ # -v strata-data:/data -e MODEL=IQ3_XXS -e API_KEY=change-me-please-123 strata:src # # docker build has no GPU, so the CUDA architectures are given here instead of read from nvidia-smi. The engine is a fat binary with # a machine-code part per listed architecture (plus PTX for the newest, which later cards can JIT), and the runtime picks the one # matching your card. Narrow CUDA_ARCHITECTURES to your card for a faster build. Native code for the CPU that builds the image is NOT # used (STRATA_PORTABLE=ON), so the image runs on any x86-64 CPU with AVX2. # # Plain legacy-builder features only (no heredocs, no --mount). AMD (HIP) and Intel (SYCL) source builds: docs/AMD_HIP.md, docs/INTEL.md. ARG CUDA_IMAGE=nvidia/cuda:13.0.0-devel-ubuntu24.04 ARG RUNTIME_BASE=ubuntu:24.04 # ---- 1. compile the engine and make its component package FROM ${CUDA_IMAGE} AS engine-build ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1 PATH=/venv/bin:$PATH RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential ca-certificates git libgomp1 libatomic1 python3 python3-pip python3-venv unzip \ && rm -rf /var/lib/apt/lists/* WORKDIR /src COPY . . ARG CUDA_ARCHITECTURES="75;80;86;89;120" ARG BUILD_VISION=1 ARG BUILD_HY4=1 ARG BUILD_INKLING=1 # Ling-3.2-Air (strata-ling32): off until it is released; it is built for the architectures of CUDA_ARCHITECTURES that are 75 or newer (Turing runs the SIMT kernels; the tensor-core paths are sm_80+) ARG BUILD_LING32=0 ARG ENGINE_VERSION= RUN python3 -m venv /venv && /venv/bin/pip install --no-cache-dir -r terminal/requirements.txt -r terminal/requirements-build.txt # ggml comes from the vendored engine/third_party/strata-ggml; strata-vision is Strata's own reader (terminal/tools/vision/own): nothing is downloaded RUN set -e; \ real=""; for a in $(echo "$CUDA_ARCHITECTURES" | tr ';,' ' '); do real="$real;${a}-real"; done; real=${real#;}; \ last=$(echo "$CUDA_ARCHITECTURES" | tr ';,' ' ' | awk '{print $NF}'); \ sm60=OFF; for a in $(echo "$CUDA_ARCHITECTURES" | tr ';,' ' '); do if [ "$a" -lt 75 ]; then sm60=ON; fi; done; \ hy4=OFF; [ "$BUILD_HY4" = "1" ] && hy4=ON || true; \ ink=OFF; [ "$BUILD_INKLING" = "1" ] && ink=ON || true; \ ling=OFF; lingarch=""; if [ "$BUILD_LING32" = "1" ]; then ling=ON; for a in $(echo "$CUDA_ARCHITECTURES" | tr ';,' ' '); do if [ "$a" -ge 75 ]; then lingarch="$lingarch;${a}-real"; fi; done; lingarch="${lingarch#;};$last-virtual"; fi; \ /venv/bin/cmake -G Ninja -S engine -B build -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_CUDA=ON -DSTRATA_BUILD_TESTS=OFF \ -DSTRATA_EXPERIMENTAL_SM60=$sm60 -DSTRATA_BUILD_HY4=$hy4 -DSTRATA_BUILD_INKLING=$ink -DSTRATA_BUILD_LING32=$ling -DLING32_CUDA=$ling "-DLING32_CUDA_ARCH=${lingarch:-86}" \ -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_PORTABLE=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_BUILD_HY4_FLASH=ON \ "-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual"; \ . tools/packaging/engine_targets.sh; targets=$(engine_targets /venv/bin/cmake build); \ [ "$BUILD_HY4" = "1" ] && targets="$targets strata-hy4" || true; \ [ "$BUILD_INKLING" = "1" ] && targets="$targets strata-inkling" || true; \ [ "$BUILD_LING32" = "1" ] && targets="$targets strata-ling32" || true; \ /venv/bin/cmake --build build --target $targets -j "$(nproc)"; \ if [ "$BUILD_VISION" = "1" ]; then \ /venv/bin/cmake -G Ninja -S terminal/tools/vision -B build-vision -DCMAKE_BUILD_TYPE=Release \ -DSTRATA_VISION_CUDA=ON -DSTRATA_PORTABLE=ON "-DCMAKE_CUDA_ARCHITECTURES=${real};${last}-virtual"; \ /venv/bin/cmake --build build-vision --target strata-vision -j "$(nproc)"; \ fi RUN set -e; \ mkdir -p /stage /engine /shapes; \ cp build/strata /stage/; \ [ -f build/libstrata_kq.so ] && cp build/libstrata_kq.so /stage/ || true; \ [ -f build-vision/bin/strata-vision ] && cp build-vision/bin/strata-vision /stage/ || true; \ ver="${ENGINE_VERSION:-$(sed -n 's/^[[:space:]]*project([^)]*VERSION[[:space:]]*\([0-9][0-9.]*\).*/\1/p' engine/CMakeLists.txt | head -1)}"; \ cudafull=$(nvcc --version | sed -n 's/.*release \([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -1); cudamajor=${cudafull%%.*}; \ if [ "$cudamajor" = 13 ]; then mindriver=580.65; else mindriver=575.51; fi; \ vision_archs=""; [ -f /stage/strata-vision ] && vision_archs=", \"vision_archs\": \"$CUDA_ARCHITECTURES\""; \ echo "{\"version\": \"$ver\", \"source\": \"docker build\", \"archs\": \"$CUDA_ARCHITECTURES\", \"cuda\": \"$cudafull\", \"portable\": true${vision_archs}}" > /stage/BUILD.json; \ python3 tools/packaging/collect_libs.py --binary build/strata --search /usr/local/cuda/lib64 --out /stage --also 'libcublasLt.so*'; \ archs=""; for a in $(echo "$CUDA_ARCHITECTURES" | tr ';,' ' '); do archs="$archs --arch sm_$a"; done; \ last=$(echo "$CUDA_ARCHITECTURES" | tr ';,' ' ' | awk '{print $NF}'); \ python3 tools/packaging/package_engine.py --src /stage --backend cuda --version "$ver" --out /engine $archs --arch "compute_$last" \ --min-driver nvidia=$mindriver --variant cuda$cudamajor --platform linux-x86_64 --build-id "docker-source-${ver}-cuda${cudafull}" --include SYSTEM-LIBS.txt --include 'libstrata_kq*' \ --include strata-vision --include 'licenses/*'; \ if [ "$BUILD_HY4" = "1" ]; then \ hy4_bin=""; \ if [ -f build/strata-hy4 ]; then hy4_bin=build/strata-hy4; elif [ -f build/src/hy4flash/strata-hy4 ]; then hy4_bin=build/src/hy4flash/strata-hy4; fi; \ [ -n "$hy4_bin" ] || { echo "BUILD_HY4=1 but strata-hy4 was not built"; exit 1; }; \ mkdir -p /stage-hy4 /shapes/hy4/engine; \ cp "$hy4_bin" /stage-hy4/strata-hy4; \ cp /stage/BUILD.json /stage-hy4/BUILD.json; \ python3 tools/packaging/collect_libs.py --binary "$hy4_bin" --search /usr/local/cuda/lib64 --out /stage-hy4 --also 'libcublasLt.so*'; \ python3 tools/packaging/package_engine.py --src /stage-hy4 --backend cuda --shape hy4 --version "$ver" --out /shapes/hy4/engine $archs --arch "compute_$last" \ --min-driver nvidia=$mindriver --variant cuda$cudamajor --platform linux-x86_64 --build-id "docker-source-${ver}-cuda${cudafull}" --include SYSTEM-LIBS.txt --include 'licenses/*'; \ fi; \ if [ "$BUILD_INKLING" = "1" ]; then \ ink_bin=""; \ if [ -f build/src/inkling2/strata-inkling ]; then ink_bin=build/src/inkling2/strata-inkling; elif [ -f build/strata-inkling ]; then ink_bin=build/strata-inkling; fi; \ [ -n "$ink_bin" ] || { echo "BUILD_INKLING=1 but strata-inkling was not built"; exit 1; }; \ mkdir -p /stage-inkling /shapes/inkling2/engine; \ cp "$ink_bin" /stage-inkling/strata-inkling; \ cp /stage/BUILD.json /stage-inkling/BUILD.json; \ python3 tools/packaging/collect_libs.py --binary "$ink_bin" --search /usr/local/cuda/lib64 --out /stage-inkling --also 'libcublasLt.so*'; \ python3 tools/packaging/package_engine.py --src /stage-inkling --backend cuda --shape inkling2 --version "$ver" --out /shapes/inkling2/engine $archs --arch "compute_$last" \ --min-driver nvidia=$mindriver --variant cuda$cudamajor --platform linux-x86_64 --build-id "docker-source-${ver}-cuda${cudafull}" --include SYSTEM-LIBS.txt --include 'licenses/*'; \ fi; \ if [ "$BUILD_LING32" = "1" ]; then \ ling_bin=""; \ if [ -f build/src/ling32/strata-ling32 ]; then ling_bin=build/src/ling32/strata-ling32; elif [ -f build/ling32/strata-ling32 ]; then ling_bin=build/ling32/strata-ling32; elif [ -f build/strata-ling32 ]; then ling_bin=build/strata-ling32; fi; \ [ -n "$ling_bin" ] || { echo "BUILD_LING32=1 but strata-ling32 was not built"; exit 1; }; \ mkdir -p /stage-ling32 /shapes/ling32/engine /stage-ling32/licenses; \ cp "$ling_bin" /stage-ling32/strata-ling32; \ cp /stage/BUILD.json /stage-ling32/BUILD.json; \ cp tools/packaging/ling32/NOTICE-ling32.txt /stage-ling32/licenses/; \ python3 tools/packaging/collect_libs.py --binary "$ling_bin" --search /usr/local/cuda/lib64 --out /stage-ling32; \ ling_archs=""; for a in $(echo "$lingarch" | tr ';,' ' '); do a=${a%-real}; a=${a%-virtual}; ling_archs="$ling_archs --arch sm_$a"; done; \ python3 tools/packaging/package_engine.py --src /stage-ling32 --backend cuda --shape ling32 --entrypoint strata-ling32 --version "$ver" --out /shapes/ling32/engine $ling_archs \ --min-driver nvidia=$mindriver --variant cuda$cudamajor --platform linux-x86_64 --build-id "docker-source-${ver}-cuda${cudafull}" --include 'licenses/*'; \ fi; \ for d in /engine/*/ /shapes/*/engine/*/; do \ [ -d "$d" ] || continue; \ python3 tools/packaging/package_engine.py --verify "$d"; \ python3 tools/packaging/binary_deps.py "$d"; \ done # ---- 2. the Terminal (the release archive, built here) FROM ${RUNTIME_BASE} AS terminal ARG STRATA_COMMIT= ENV STRATA_BUILD_COMMIT=${STRATA_COMMIT} ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends python3 ca-certificates git && rm -rf /var/lib/apt/lists/* COPY . /src/ RUN python3 /src/tools/packaging/package_terminal.py --out /out --cache /cache \ && mkdir -p /opt/strata \ && tar -xzf /out/strata-terminal-*-linux-x86_64.tar.gz -C /opt/strata \ && mv /opt/strata/strata-terminal-* /opt/strata/terminal \ && /opt/strata/terminal/bin/strata --version # gguf-py (the model preparation tools) is part of the Terminal archive (engine/third_party/strata-gguf-py), so the first start fetches nothing from # GitHub and the image needs no llama.cpp: check that it is there RUN test -f /opt/strata/terminal/third_party/strata-gguf-py/gguf/__init__.py # ---- 3. the runtime image (the same as tools/docker/Dockerfile's, FLAVOR=cuda) FROM ${RUNTIME_BASE} ARG STRATA_VERSION=dev ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends tini ca-certificates libgomp1 libatomic1 libnuma1 zlib1g \ && rm -rf /var/lib/apt/lists/* /var/cache/apt/* COPY --from=terminal /opt/strata/terminal /opt/strata/terminal COPY --from=engine-build /engine/ /opt/strata/components/engine/ COPY --from=engine-build /shapes/ /opt/strata/components/shapes/ COPY tools/docker/entrypoint.sh tools/docker/healthcheck.sh /opt/strata/ COPY tools/docker/strata-wrapper.sh /usr/local/bin/strata RUN chmod 0755 /opt/strata/entrypoint.sh /opt/strata/healthcheck.sh /usr/local/bin/strata RUN set -e; \ for d in /opt/strata/components/engine/*/ /opt/strata/components/shapes/*/engine/*/; do \ [ -d "$d" ] || continue; \ miss=$(find "$d" -type f \( -name 'strata*' -o -name '*.so' -o -name '*.so.*' \) ! -name '*.json' ! -name '*.txt' | while read -r f; do \ head -c4 "$f" | grep -q ELF || continue; \ LD_LIBRARY_PATH="$d" ldd "$f" 2>/dev/null | grep 'not found' | grep -v -E 'libcuda\.so|libnvidia|libnvcuvid' | sed "s|^|$(basename "$f"): |"; \ done | sort -u); \ if [ -n "$miss" ]; then echo "MISSING LIBRARIES in $d"; echo "$miss"; exit 1; fi; \ echo "libraries of $d resolve inside this image"; \ done ENV STRATA_COMPONENTS_DIR=/opt/strata/components STRATA_INSTALL_DIR=/data/install XDG_STATE_HOME=/data/state \ XDG_CONFIG_HOME=/data/config HOME=/data/home PORT=8080 LANG=C.UTF-8 PYTHONUNBUFFERED=1 PYTHONNOUSERSITE=1 STRATA_IN_DOCKER=1 \ NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=compute,utility VOLUME ["/data"] EXPOSE 8080 LABEL org.opencontainers.image.title="Strata" com.strata.flavor="cuda" com.strata.build="from-source" org.opencontainers.image.version="${STRATA_VERSION}" HEALTHCHECK --interval=30s --timeout=8s --start-period=2h --retries=3 CMD ["/opt/strata/healthcheck.sh"] STOPSIGNAL SIGTERM ENTRYPOINT ["/usr/bin/tini", "--", "/opt/strata/entrypoint.sh"] CMD ["run"]