#!/bin/bash # Läuft AUF srv04 als Benutzer stephan (ohne sudo). Testinstanz für Modellkopf und Passung (admin2modellkopf.5, #1233, #1234). # Aufruf: bash remote.sh prepare|start|stop|status|clean # Alles liegt unter /tmp/nexus-test-0127 (tmpfs). Die Produktion (nexus.service, Port 8080) wird nicht angefasst. # `prepare` und `start` laden KEIN Modell. Geladen wird erst im Test, ein Modell nach dem anderen. set -u DIR=/tmp/nexus-test-0127 NEXUS_PORT=18127 N="$DIR/bin/nexus" CFG="$DIR/config.toml" M=/srv/models/gguf gpus() { nvidia-smi --query-gpu=index,memory.used,memory.total --format=csv,noheader; } case "${1:-}" in prepare) [ -x "$N" ] || { echo "Binary fehlt: $N"; exit 1; } mkdir -p "$DIR/data" sed -e "s|@DIR@|$DIR|g" -e "s|@NEXUS_PORT@|$NEXUS_PORT|g" "$DIR/config.toml.in" > "$CFG" [ -s "$CFG" ] || { echo "Konfiguration ist leer: $CFG"; exit 1; } "$N" selftest --config "$CFG" | tail -2 reg() { # Name Pfad GPUs [Kontext] "$N" model list --config "$CFG" 2>/dev/null | grep -q "^$1\b" && return 0 if [ -n "${4:-}" ]; then "$N" model add --name "$1" --path "$2" --gpus "$3" --context "$4" --config "$CFG" | tail -1 else "$N" model add --name "$1" --path "$2" --gpus "$3" --config "$CFG" | tail -1; fi } # Bonsai zweimal: ohne Kontext (llama.cpp nimmt den trainierten) und mit 2048, dazu ein dichtes, ein Mischmodell (MoE) # und ein Hybridmodell mit Vision-Projektor im Ordner. reg bonsai-nativ "$M/Bonsai-1.7B-Q1_0.gguf" 0 reg bonsai-c2048 "$M/Bonsai-1.7B-Q1_0.gguf" 0 2048 reg darkidol-8b "$M/DarkIdol-Llama-3.1-8B-Instruct-1.2-Uncensored-Q6_K.gguf" 0 4096 reg erebus-26b "$M/Erebus-RP-Engine-26B-A4B.Q4_K_M.gguf" 0,1 4096 reg qwen36-35b "$M/models/qwen36-UD-Q4_K_XL/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf" 0,1 4096 for m in bonsai-nativ bonsai-c2048 darkidol-8b erebus-26b qwen36-35b; do "$N" model enable --name "$m" --config "$CFG" | tail -1; done if ! "$N" user list --config "$CFG" 2>/dev/null | grep -q '^testadmin'; then umask 077 "$N" user create --name testadmin --role admin --config "$CFG" 2>&1 | grep -i 'passwort' | sed 's/.*: *//' > "$DIR/admin-passwort.txt" fi echo "Vorbereitet. Benutzer: testadmin, Passwort in $DIR/admin-passwort.txt (0600)." ;; start) [ -f "$CFG" ] || { echo "erst prepare"; exit 1; } if [ -f "$DIR/nexus.pid" ] && kill -0 "$(cat "$DIR/nexus.pid")" 2>/dev/null; then echo "läuft schon (PID $(cat "$DIR/nexus.pid"))"; exit 0; fi setsid nohup "$N" serve --config "$CFG" > "$DIR/serve.log" 2>&1 < /dev/null & echo $! > "$DIR/nexus.pid" for i in 1 2 3 4 5 6 7 8 9 10; do curl -s -m 2 "http://127.0.0.1:$NEXUS_PORT/gateway/v1/health" && { echo; break; } sleep 1 done echo "Testinstanz auf 127.0.0.1:$NEXUS_PORT (PID $(cat "$DIR/nexus.pid")). Tunnel von deinem Rechner: ssh -N -L 18127:127.0.0.1:18127 srv04" ;; stop) if [ -f "$DIR/nexus.pid" ]; then kill "$(cat "$DIR/nexus.pid")" 2>/dev/null; rm -f "$DIR/nexus.pid"; fi echo "Gestoppt. GPUs:"; gpus ;; status) echo "Nexus-Test:"; curl -s -m 2 "http://127.0.0.1:$NEXUS_PORT/gateway/v1/health" || echo "antwortet nicht"; echo echo "llama-server-Prozesse:"; ps -eo pid,args | grep "^ *[0-9]* /srv/apps/llama.cpp/build/bin/llama-server" | cut -c1-140 echo "GPUs:"; gpus ;; clean) bash "$0" stop rm -rf "$DIR" echo "Aufgeräumt. GPUs:"; gpus ;; *) echo "Aufruf: remote.sh prepare|start|stop|status|clean"; exit 2;; esac