Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

Container: keep the pruned SDK for runtime kernel compilation, add compiler and libatomic, numeric GPU group ids in the docs

YanissAmz6bdf35ec2a49
diff --git a/doc/container.md b/doc/container.md
index 5f2e865..bfc12c6 100644
--- a/doc/container.md
+++ b/doc/container.md
@@ -14,7 +14,7 @@ The build follows the README Quickstart: ROCm torch and `rocm-sdk-devel` from AM
```bash
docker run --rm --name kyojin \
- --device /dev/kfd --device /dev/dri --group-add video --group-add render \
+ --device /dev/kfd --device /dev/dri --group-add "$(getent group video | cut -d: -f3)" --group-add "$(getent group render | cut -d: -f3)" \
--security-opt seccomp=unconfined --ipc=host \
-v /path/to/Qwen3.8-Flash-Next-EXL3-Yamz:/models:ro \
-e KYOJIN_MODEL=qwen -e CONTEXT=32768 -e PORT=8000 -p 8000:8000 \
@@ -32,6 +32,8 @@ podman run --rm --name kyojin \
Then `curl http://localhost:8000/health` and `python tools/bench.py --base http://localhost:8000/v1` from the host. The port stays closed while the model loads (about a minute for Qwen). GLM tunes its kernels for about 10 minutes on a first launch (see README); keep the container, or mount a volume on `/root/.cache`, between runs if you want that kept.
+The image has no `video` or `render` group by name, so docker needs the numeric group ids of the host (`getent group video render`). In the llama-swap example below, replace `${VIDEO_GID}` and `${RENDER_GID}` by those numbers.
+
## Variables
| Variable | Default | Meaning |
@@ -61,7 +63,7 @@ services:
kyojin-qwen:
image: kyojin
devices: ["/dev/kfd:/dev/kfd", "/dev/dri:/dev/dri"]
- group_add: ["video", "render"]
+ group_add: ["${VIDEO_GID}", "${RENDER_GID}"] # numeric ids from: getent group video render
security_opt: ["seccomp=unconfined"]
ipc: host
volumes: ["/path/to/Qwen3.8-Flash-Next-EXL3-Yamz:/models:ro"]
@@ -80,7 +82,7 @@ llama-swap config entry (it starts and stops the container itself; `cmd` runs in
models:
qwen38:
cmd: >
- docker run --rm --name kyojin-qwen --device /dev/kfd --device /dev/dri --group-add video --group-add render
+ docker run --rm --name kyojin-qwen --device /dev/kfd --device /dev/dri --group-add ${VIDEO_GID} --group-add ${RENDER_GID}
--security-opt seccomp=unconfined --ipc=host -v /path/to/pack:/models:ro
-e KYOJIN_MODEL=qwen -e CONTEXT=65536 -p 8101:8000 kyojin
cmdStop: docker stop kyojin-qwen
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 3405cbc..9cadb98 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -14,7 +14,8 @@ RUN python3 -m venv .venv
ENV PATH=/opt/kyojin/.venv/bin:$PATH
COPY requirements.txt .
COPY . .
-# One layer on purpose: the 12 GB SDK tree (needed only to compile) never reaches an image layer.
+# One layer on purpose: the pip downloads and the unpruned SDK tree never reach an image layer.
+# The SDK (hipcc, headers) stays in the image: the servers compile a few HIP kernels on first start.
RUN pip install --pre torch rocm-sdk-devel --index-url https://rocm.nightlies.amd.com/v2/gfx1151/ \
&& pip install -r requirements.txt \
&& rocm-sdk init \
@@ -22,16 +23,17 @@ RUN pip install --pre torch rocm-sdk-devel --index-url https://rocm.nightlies.am
&& source tools/strix_halo/env.sh \
&& ./build.sh \
&& python -c "import torch, exllamav3_ext" \
- && rm -rf "$EXL3_ROCM_SDK" build .rebuild.* .sdk-deps /root/.cache
+ && rm -rf build .rebuild.* .sdk-deps /root/.cache \
+ && cd "$EXL3_ROCM_SDK" && rm -rf clients share/rocprofiler-sdk share/hipblaslt share/rocdecode share/rocsparse bin/*gtest* bin/*-test bin/*-bench bin/*-gemm-tune bin/*test*
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1
-RUN apt-get update && apt-get install -y --no-install-recommends python3 libnuma1 libatomic1 libgomp1 libdrm2 libelf1 curl ca-certificates \
+RUN apt-get update && apt-get install -y --no-install-recommends python3 g++ libc6-dev python3-dev libnuma1 libatomic1 libgomp1 libdrm2 libelf1 curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /opt/kyojin /opt/kyojin
WORKDIR /opt/kyojin
ENV PATH=/opt/kyojin/.venv/bin:$PATH \
- EXL3_HSA_LIB=/opt/kyojin/.venv/lib/python3.12/site-packages/_rocm_sdk_core/lib/libhsa-runtime64.so.1
+ EXL3_ROCM_SDK=/opt/kyojin/.venv/lib/python3.12/site-packages/_rocm_sdk_devel
ENV MODEL_DIR=/models PORT=8000 HOME=/root
EXPOSE 8000
VOLUME ["/models"]