Merge branch 'main' into gemma4-mtp

This commit is contained in:
keptn42 committed 2026-10-12 02:38:12 +02:00
commit 45109ebb45
2 files changed
+31 -13

No files matched your search

+19 -5
View File
@@ -131,22 +131,31 @@ RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \
# ----------------------------------------------------------------------------------------- rootfs
FROM build AS rootfs
# hfget.sh, which fetches the Hugging Face repo a --model id names, runs curl and jq, and curl needs
# a CA bundle to reach the hub over TLS. Installed in this stage, not in `build`, so adding them does
# not recompile the engine.
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl jq ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# The marker makes this stage, and so the shipped image, depend on the test stage.
COPY --from=test /build/host-tests-passed /rootfs/opt/radiance/share/radiance/.host-tests-passed
# Every library the binaries and plugins load, plus comgr, which the HIP runtime opens at run time
# and cannot initialise a device without, goes into one directory the dynamic loader searches by
# default: no ld.so.cache, no LD_LIBRARY_PATH. libdrm_amdgpu names the card from amdgpu.ids. A
# static busybox provides the health check's wget and a shell for `docker exec`. docker/licenses.sh
# static busybox provides the health check's wget and a shell for `docker exec`; curl, jq and the
# CA bundle are hfget.sh's, and the bundle is ca-certificates' Mozilla set, which is the directory
# named for it in the license list. docker/licenses.sh
# traces each of those files to its package and records its license and source in
# /usr/share/doc/THIRD-PARTY. Then every ELF file is resolved from inside the tree, so nothing can
# depend on a library the image lacks.
RUN set -e; R=/rootfs; L=$R/usr/lib/x86_64-linux-gnu; \
mkdir -p $L $R/lib64 $R/usr/bin $R/bin $R/usr/share/libdrm $R/data $R/tmp; \
mkdir -p $L $R/lib64 $R/usr/bin $R/bin $R/usr/share/libdrm $R/etc/ssl/certs $R/data $R/tmp; \
chmod 1777 $R/tmp; \
cp -a /stage/opt/radiance $R/opt/; \
elves=$(find $R/opt/radiance -type f -exec sh -c 'head -c4 "$1" | grep -q ELF' _ {} \; -print); \
strip --strip-unneeded $elves; \
libs=$(for f in $elves /opt/rocm/lib/libamd_comgr.so.3; do ldd "$f"; done \
libs=$(for f in $elves /usr/bin/curl /usr/bin/jq /opt/rocm/lib/libamd_comgr.so.3; do ldd "$f"; done \
| awk '/=> \//{print $3} /^\t\/lib64\//{print $1}' | sort -u); \
for lib in $libs; do \
case "$lib" in */ld-linux-x86-64.so.2) cp -L "$lib" $R/lib64/ ;; *) cp -L "$lib" $L/ ;; esac; \
@@ -154,13 +163,18 @@ RUN set -e; R=/rootfs; L=$R/usr/lib/x86_64-linux-gnu; \
cp -L /opt/rocm/lib/libamd_comgr.so.3 $L/; \
cp /usr/share/libdrm/amdgpu.ids $R/usr/share/libdrm/; \
cp /bin/busybox $R/usr/bin/busybox; ln -s /usr/bin/busybox $R/bin/sh; \
cp /usr/bin/curl /usr/bin/jq $R/usr/bin/; \
cp /etc/ssl/certs/ca-certificates.crt $R/etc/ssl/certs/; \
sh /src/docker/licenses.sh $R $libs /opt/rocm/lib/libamd_comgr.so.3 \
/usr/share/libdrm/amdgpu.ids /bin/busybox; \
for f in $(cd $R && find opt/radiance usr/lib -type f -exec sh -c 'head -c4 "$1" | grep -q ELF' _ {} \; -print); do \
/usr/share/libdrm/amdgpu.ids /bin/busybox /usr/bin/curl /usr/bin/jq \
/usr/share/ca-certificates/mozilla; \
for f in $(cd $R && find opt/radiance usr/lib -type f -exec sh -c 'head -c4 "$1" | grep -q ELF' _ {} \; -print) \
usr/bin/curl usr/bin/jq; do \
out=$(chroot $R /lib64/ld-linux-x86-64.so.2 --list "/$f" 2>&1) || { echo "$f: $out" >&2; exit 1; }; \
if echo "$out" | grep -q 'not found'; then echo "$f: $out" >&2; exit 1; fi; \
done; \
chroot $R /opt/radiance/bin/radiance --help > /dev/null; \
chroot $R /usr/bin/curl --version > /dev/null; chroot $R /usr/bin/jq --version > /dev/null; \
du -sh $R $L $R/opt/radiance
# ---------------------------------------------------------------------------------------- runtime
+12 -8
View File
@@ -30,11 +30,13 @@
# saturate the link and more only makes the destination seek.
set -e
# ---- child mode: one file, named by "<oid><tab><size><tab><path>" in $1, everything else inherited
# ---- child mode: one file, named by "<size><tab><oid><tab><path>" in $1, everything else inherited.
# Size first: a non-LFS file has no oid, and busybox `xargs -I` strips the leading blanks of a line,
# so a line that began with its empty oid field would reach the child one tab short.
# sh cannot export a function, so parallelism is one re-entry of this script per file under
# `xargs -P` rather than a worker pool.
if [ -n "$HFGET_CHILD" ]; then
oid=${1%% *}; rest=${1#* }; size=${rest%% *}; path=${rest#* }
size=${1%% *}; rest=${1#* }; oid=${rest%% *}; path=${rest#* }
key=${oid:-$size} # LFS: sha256, non-LFS: size
out=$HFGET_DEST/$path
man=$HFGET_DEST/.hfget-manifest
@@ -116,11 +118,11 @@ sel='.[] | select(.type == "file")'
list=$(mktemp "${TMPDIR:-/tmp}/hfget.XXXXXX")
trap 'rm -f "$list" "$dest/.hfget-manifest.tmp"' EXIT INT TERM
printf '%s' "$listing" | jq -r "$sel"' | "\(.lfs.oid // "")\t\(.size)\t\(.path)"' > "$list"
printf '%s' "$listing" | jq -r "$sel"' | "\(.size)\t\(.lfs.oid // "")\t\(.path)"' > "$list"
n=$(wc -l < "$list")
[ "$n" -gt 0 ] || { echo "hfget: the listing has no files" >&2; exit 3; }
need=$(awk -F'\t' '{s += $2} END {printf "%.1f", s / 1073741824}' "$list")
need=$(awk -F'\t' '{s += $1} END {printf "%.1f", s / 1073741824}' "$list")
mkdir -p "$dest"
: > "$dest/.hfget-manifest.tmp"
# WHAT IS STILL TO FETCH, not the repo's size: a warm cache of a model larger than the free space
@@ -130,7 +132,7 @@ todo=0
# Split by expansion, as the child does: a tab is IFS whitespace, so `read` would merge the empty
# key of a non-LFS file into the next field.
while IFS= read -r line; do
oid=${line%% *}; rest=${line#* }; size=${rest%% *}; path=${rest#* }
size=${line%% *}; rest=${line#* }; oid=${rest%% *}; path=${rest#* }
cur=0
if [ -f "$dest/$path" ]; then cur=$(wc -c < "$dest/$path"); fi
if [ "$cur" = "$size" ] && [ -f "$dest/.hfget-manifest" ]; then
@@ -139,12 +141,14 @@ while IFS= read -r line; do
fi
if [ "$cur" -lt "$size" ]; then todo=$((todo + size - cur)); fi
done < "$list"
free=$(df -BG --output=avail "$dest" | tail -1 | tr -dc '0-9')
# Free space in KiB from POSIX `df -Pk` (one line per filesystem, 1024-byte blocks): GNU's
# `-BG --output=avail` is not in busybox, which is the df the container image has.
free=$(df -Pk "$dest" | awk 'NR == 2 { print $4 }')
echo "hfget: $n file(s), $need GiB -> $dest"
[ "$have_st" -gt 0 ] && echo "hfget: safetensors present, pickle weight formats skipped"
echo "hfget: $(awk -v t="$todo" 'BEGIN { printf "%.1f", t / 1073741824 }') GiB to fetch," \
"$free GiB free on the destination filesystem"
awk -v t="$todo" -v f="$free" 'BEGIN { exit !(t / 1073741824 > f) }' \
"$(awk -v f="$free" 'BEGIN { printf "%.1f", f / 1048576 }') GiB free on the destination filesystem"
awk -v t="$todo" -v f="$free" 'BEGIN { exit !(t > f * 1024) }' \
&& { echo "hfget: THE DOWNLOAD DOES NOT FIT" >&2; exit 3; }
export HFGET_CHILD=1 HFGET_DEST="$dest" HFGET_REPO="$repo" HFGET_REV="$rev" HFGET_MAN_OUT="$dest/.hfget-manifest.tmp"