mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
- The image is Node 24 on Debian trixie with glvnd and X11's libraries (libxext6 libx11-6 libgl1 libegl1), without which NVIDIA's Vulkan driver (mounted by the container runtime) doesn't load or gives no vkCreateInstance (driver 610.57 on Modal's T4, A10G and A10). The entrypoint opens NVIDIA's driver when the host passed a GPU in, else Mesa's; WGPU_BACKEND=vulkan, and on the CPU EGL's vendors are hidden, since NVIDIA's EGL would hand wgpu an OpenGL adapter over llvmpipe. RAEA_CLOUD_DEVICE=gpu fails at start on no GPU; /v1/health says the device. - /v1/jobs takes a project as a tar and gives back what the render made (CL14); deploy/modal/raea_cloud.py runs it on a Modal GPU list (L4, else A10G, else T4), one container that sleeps after five idle minutes. - RAEA_CLOUD_GPU_URL on a CPU box sends raea render to the worker and lands its files back (CL15, image/raea.sh and server/offload.ts); deploy/k8s.gpu.yaml is such a worker. - test/smoke.sh: worker and box, ten checks, all pass on 0.1.1-rc3. On Modal, test/gpu/edit.tsx (576 lit blocks, 1080p, 90 frames): T4 156 s against llvmpipe on the same machine's 8 cores 203 s; a box on a Mac handed it to an A10 (119 s) and the MP4 came back.
66 lines
3.0 KiB
Bash
Executable File
66 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# raea cloud's entrypoint (docs/cloud.feature CL3, CL10): the home folder back from RAEA_CLOUD_STATE when it's set,
|
|
# raea's skills for each installed agent (matched to this image's raea), then the server. On SIGTERM (a platform
|
|
# stopping or sleeping the container) the server stops and the home folder is saved again.
|
|
set -uo pipefail
|
|
here=/opt/raea-cloud
|
|
: "${RAEA_CLOUD_TOKEN:?raea-cloud: set RAEA_CLOUD_TOKEN (openssl rand -hex 32); every request must carry it}"
|
|
|
|
# started as root: give the home folder to raea (a new volume is root's) and go on as raea, environment kept
|
|
if [ "$(id -u)" = 0 ]; then
|
|
[ "$(stat -c %u /home/raea)" = 1000 ] || chown -R raea:raea /home/raea
|
|
# a platform may set its own HOME for root (Modal's is /root)
|
|
export HOME=/home/raea
|
|
exec setpriv --reuid=raea --regid=raea --init-groups "$0" "$@"
|
|
fi
|
|
|
|
"$here/image/state.sh" restore
|
|
mkdir -p "${RAEA_CLOUD_WORK:-$HOME/work}"
|
|
|
|
# the device raea renders on (CL13). auto: NVIDIA's Vulkan driver when the host passed a GPU in and the driver opens
|
|
# it (the host's ICD file, else the image's, which names the library the NVIDIA runtime mounts), else Mesa (llvmpipe
|
|
# on the CPU, or radv on an AMD card in /dev/dri). gpu: the same, but no GPU is an error. cpu: llvmpipe only.
|
|
device=${RAEA_CLOUD_DEVICE:-auto}
|
|
opens() {
|
|
if [ -n "$1" ]; then VK_DRIVER_FILES=$1 timeout 60 vulkaninfo --summary; else timeout 60 vulkaninfo --summary; fi 2>/dev/null |
|
|
grep -q 'PHYSICAL_DEVICE_TYPE_\(DISCRETE\|INTEGRATED\|VIRTUAL\)_GPU'
|
|
}
|
|
# raea renders through Vulkan. NVIDIA's Vulkan driver needs EGL installed (libegl1), and EGL is also a GL device to
|
|
# wgpu: NVIDIA's EGL counts as a discrete GPU and outranked lavapipe, so a render meant for the CPU went to GL and failed
|
|
# (11-10). Rendering on the CPU therefore hides EGL's vendors.
|
|
on_cpu() {
|
|
# lvp_icd.json (Mesa 24 on), lvp_icd.x86_64.json before
|
|
lvp=$(ls /usr/share/vulkan/icd.d/lvp_icd*.json 2>/dev/null | head -1)
|
|
[ -n "$lvp" ] || { echo "raea-cloud: Mesa's lavapipe (lvp_icd*.json) isn't installed, so raea can't render on the CPU" >&2; exit 1; }
|
|
export VK_DRIVER_FILES=$lvp __EGL_VENDOR_LIBRARY_DIRS=/nonexistent
|
|
}
|
|
if [ "$device" = cpu ]; then
|
|
on_cpu
|
|
elif [ -z "${VK_DRIVER_FILES:-}" ]; then
|
|
for icd in /etc/vulkan/icd.d/nvidia_icd.json /usr/share/vulkan/icd.d/nvidia_icd.json "$here/image/nvidia_icd.json"; do
|
|
[ -f "$icd" ] && opens "$icd" && { export VK_DRIVER_FILES=$icd; break; }
|
|
done
|
|
if [ -z "${VK_DRIVER_FILES:-}" ] && ! opens ""; then
|
|
if [ "$device" = gpu ]; then
|
|
echo "raea-cloud: RAEA_CLOUD_DEVICE=gpu, but no GPU opened (vulkaninfo --summary lists none); was the container given one?" >&2
|
|
exit 1
|
|
fi
|
|
on_cpu
|
|
fi
|
|
fi
|
|
|
|
for a in $(node "$here/server/agents.ts" skills); do
|
|
raea skills install --agent "$a" >/dev/null 2>&1 || echo "raea-cloud: raea's skills for $a weren't installed"
|
|
done
|
|
|
|
node "$here/server/main.ts" &
|
|
server=$!
|
|
stop() {
|
|
kill -TERM "$server" 2>/dev/null
|
|
wait "$server" 2>/dev/null
|
|
"$here/image/state.sh" save
|
|
exit 0
|
|
}
|
|
trap stop TERM INT
|
|
wait "$server"
|