fix: correct ISO rebuild paths and update GPU detection for USB structure
- Fixed quick-rebuild-iso.sh paths from /hermes/ to /opt/hermes/ - Fixed ISO boot structure (uses GRUB eltorito/efi, not isolinux) - Added MBR extraction fallback for xorriso - Updated start-llama-server.bat to reference existing USB paths (bin/ollama/, Llama-3.2-1B model, llama-server-vulkan.exe) - Works with existing USB structure — no restructure needed - All bat files: ASCII text, CRLF line terminators
This commit is contained in:
@@ -1,125 +1,244 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
title Hermes Portable - Offline LLM Server with GPU Detection
|
||||||
|
|
||||||
:: ==============================================================================
|
:: ==============================================================================
|
||||||
:: Hermes Portable Rescue - llama-server launcher with GPU detection
|
|
||||||
|
:: Hermes Portable Rescue - llama-server launcher with multi-brand GPU detection
|
||||||
|
|
||||||
:: ==============================================================================
|
:: ==============================================================================
|
||||||
|
|
||||||
:: Detects GPU brand (NVIDIA, AMD, Intel, integrated) and launches the
|
:: Detects GPU brand (NVIDIA, AMD, Intel, integrated) and launches the
|
||||||
|
|
||||||
:: appropriate llama-server build (Vulkan for GPU, CPU-only fallback).
|
:: appropriate llama-server build (Vulkan for GPU, CPU-only fallback).
|
||||||
|
|
||||||
:: ==============================================================================
|
:: ==============================================================================
|
||||||
|
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cd /d "%~dp0"
|
cd /d "%~dp0"
|
||||||
|
|
||||||
set LLAMA_DIR=%~dp0bin\llama
|
|
||||||
set MODEL_DIR=%~dp0bin\ollama
|
|
||||||
set MODEL=%MODEL_DIR%\qwen2.5-coder-1.5b-q4_k_m.gguf
|
set LLAMA_DIR=%~dp0bin\ollama
|
||||||
|
|
||||||
|
set MODEL=%LLAMA_DIR%\Llama-3.2-1B-Instruct-Q4_K_M.gguf
|
||||||
|
|
||||||
set PORT=11434
|
set PORT=11434
|
||||||
|
|
||||||
set GPU_FOUND=0
|
set GPU_FOUND=0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
echo ============================================
|
echo ============================================
|
||||||
|
|
||||||
echo Hermes LLM Server - GPU Detection
|
echo Hermes LLM Server - GPU Detection
|
||||||
|
|
||||||
echo ============================================
|
echo ============================================
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:: --- Detection 1: nvidia-smi (NVIDIA) --------------------------------------
|
:: --- Detection 1: nvidia-smi (NVIDIA) --------------------------------------
|
||||||
|
|
||||||
nvidia-smi >nul 2>&1
|
nvidia-smi >nul 2>&1
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
for /f "tokens=*" %%a in ('nvidia-smi --query-gpu=name --format=csv,noheader 2^>nul') do (
|
for /f "tokens=*" %%a in ('nvidia-smi --query-gpu=name --format=csv,noheader 2^>nul') do (
|
||||||
|
|
||||||
set GPU_NAME=%%a
|
set GPU_NAME=%%a
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
echo [OK] NVIDIA GPU detected: !GPU_NAME!
|
echo [OK] NVIDIA GPU detected: !GPU_NAME!
|
||||||
|
|
||||||
set GPU_FOUND=1
|
set GPU_FOUND=1
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Detection 2: WMIC - check for AMD/Intel GPUs
|
|
||||||
|
|
||||||
|
:: --- Detection 2: WMIC - check for AMD/Intel GPUs ---------------------------
|
||||||
|
|
||||||
if !GPU_FOUND! equ 0 (
|
if !GPU_FOUND! equ 0 (
|
||||||
|
|
||||||
wmic path win32_videocontroller get name 2>nul | findstr /i "nvidia" >nul
|
wmic path win32_videocontroller get name 2>nul | findstr /i "nvidia" >nul
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
echo [OK] NVIDIA GPU detected via WMI
|
echo [OK] NVIDIA GPU detected via WMI
|
||||||
|
|
||||||
set GPU_FOUND=1
|
set GPU_FOUND=1
|
||||||
|
|
||||||
) else (
|
) else (
|
||||||
|
|
||||||
wmic path win32_videocontroller get name 2>nul | findstr /i "amd radeon" >nul
|
wmic path win32_videocontroller get name 2>nul | findstr /i "amd radeon" >nul
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
echo [OK] AMD GPU detected via WMI
|
echo [OK] AMD GPU detected via WMI
|
||||||
|
|
||||||
set GPU_FOUND=1
|
set GPU_FOUND=1
|
||||||
|
|
||||||
) else (
|
) else (
|
||||||
|
|
||||||
wmic path win32_videocontroller get name 2>nul | findstr /i "intel arc" >nul
|
wmic path win32_videocontroller get name 2>nul | findstr /i "intel arc" >nul
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
echo [OK] Intel GPU detected via WMI
|
echo [OK] Intel GPU detected via WMI
|
||||||
|
|
||||||
set GPU_FOUND=1
|
set GPU_FOUND=1
|
||||||
|
|
||||||
) else (
|
) else (
|
||||||
|
|
||||||
wmic path win32_videocontroller get name 2>nul | findstr /i "intel hd intel iris intel uhd" >nul
|
wmic path win32_videocontroller get name 2>nul | findstr /i "intel hd intel iris intel uhd" >nul
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
echo [OK] Intel integrated graphics detected via WMI
|
echo [OK] Intel integrated graphics detected via WMI
|
||||||
|
|
||||||
set GPU_FOUND=1
|
set GPU_FOUND=1
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Detection 3: vulkaninfo (direct Vulkan probe)
|
|
||||||
|
|
||||||
|
:: --- Detection 3: vulkaninfo (direct Vulkan probe) ---------------------------
|
||||||
|
|
||||||
if !GPU_FOUND! equ 0 (
|
if !GPU_FOUND! equ 0 (
|
||||||
|
|
||||||
where vulkaninfo >nul 2>&1
|
where vulkaninfo >nul 2>&1
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
vulkaninfo --summary 2>nul | findstr /c:"Vulkan Instance" >nul
|
vulkaninfo --summary 2>nul | findstr /c:"Vulkan Instance" >nul
|
||||||
|
|
||||||
if !errorlevel! equ 0 (
|
if !errorlevel! equ 0 (
|
||||||
|
|
||||||
echo [OK] Vulkan-capable device detected
|
echo [OK] Vulkan-capable device detected
|
||||||
|
|
||||||
set GPU_FOUND=1
|
set GPU_FOUND=1
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Check model exists
|
|
||||||
|
|
||||||
|
:: --- Check model exists ----------------------------------------------------
|
||||||
|
|
||||||
if not exist "!MODEL!" (
|
if not exist "!MODEL!" (
|
||||||
|
|
||||||
echo [ERROR] Model not found: !MODEL!
|
echo [ERROR] Model not found: !MODEL!
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
echo Please download a GGUF model and place it at:
|
echo Please download a GGUF model and place it at:
|
||||||
|
|
||||||
echo !MODEL!
|
echo !MODEL!
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo Recommended: Qwen 2.5 Coder 1.5B Q4_K_M
|
|
||||||
echo https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF
|
|
||||||
echo.
|
|
||||||
pause
|
pause
|
||||||
|
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Launch
|
|
||||||
|
|
||||||
|
:: --- Launch ----------------------------------------------------------------
|
||||||
|
|
||||||
if !GPU_FOUND! equ 1 (
|
if !GPU_FOUND! equ 1 (
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
echo [*] Starting llama-server with GPU acceleration (Vulkan)...
|
echo [*] Starting llama-server with GPU acceleration (Vulkan)...
|
||||||
echo [*] Model: qwen2.5-coder-1.5b-q4_k_m.gguf
|
|
||||||
|
echo [*] Model: Llama-3.2-1B (Q4_K_M)
|
||||||
|
|
||||||
echo [*] Server: http://127.0.0.1:!PORT!/v1
|
echo [*] Server: http://127.0.0.1:!PORT!/v1
|
||||||
|
|
||||||
echo [*] Flags: --n-gpu-layers 99 --mlock --cont-batching -c 4096
|
echo [*] Flags: --n-gpu-layers 99 --mlock --cont-batching -c 4096
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
echo [*] Press Ctrl+C to stop the server.
|
echo [*] Press Ctrl+C to stop the server.
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"!LLAMA_DIR!\llama-server-vulkan.exe" ^
|
||||||
|
|
||||||
|
--host 127.0.0.1 --port !PORT! ^
|
||||||
|
|
||||||
|
-m "!MODEL!" ^
|
||||||
|
|
||||||
|
--n-gpu-layers 99 ^
|
||||||
|
|
||||||
|
--mlock ^
|
||||||
|
|
||||||
|
--cont-batching ^
|
||||||
|
|
||||||
|
-c 4096
|
||||||
|
|
||||||
|
) else (
|
||||||
|
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [*] No compatible GPU found. Starting CPU-only mode.
|
||||||
|
|
||||||
|
echo [*] Model: Llama-3.2-1B (Q4_K_M)
|
||||||
|
|
||||||
|
echo [*] Server: http://127.0.0.1:!PORT!/v1
|
||||||
|
|
||||||
|
echo [*] Flags: --mlock --cont-batching -c 4096
|
||||||
|
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [*] Press Ctrl+C to stop the server.
|
||||||
|
|
||||||
|
echo.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"!LLAMA_DIR!\llama-server.exe" ^
|
"!LLAMA_DIR!\llama-server.exe" ^
|
||||||
--host 127.0.0.1 --port !PORT! ^
|
|
||||||
-m "!MODEL!" ^
|
|
||||||
--n-gpu-layers 99 ^
|
|
||||||
--mlock ^
|
|
||||||
--cont-batching ^
|
|
||||||
-c 4096
|
|
||||||
) else (
|
|
||||||
echo.
|
|
||||||
echo [*] No compatible GPU found. Starting CPU-only mode.
|
|
||||||
echo [*] Model: qwen2.5-coder-1.5b-q4_k_m.gguf
|
|
||||||
echo [*] Server: http://127.0.0.1:!PORT!/v1
|
|
||||||
echo [*] Flags: --mlock --cont-batching -c 4096
|
|
||||||
echo.
|
|
||||||
echo [*] Press Ctrl+C to stop the server.
|
|
||||||
echo.
|
|
||||||
|
|
||||||
"!LLAMA_DIR!\cpu\llama-server-cpu.exe" ^
|
|
||||||
--host 127.0.0.1 --port !PORT! ^
|
--host 127.0.0.1 --port !PORT! ^
|
||||||
|
|
||||||
-m "!MODEL!" ^
|
-m "!MODEL!" ^
|
||||||
|
|
||||||
--mlock ^
|
--mlock ^
|
||||||
|
|
||||||
--cont-batching ^
|
--cont-batching ^
|
||||||
|
|
||||||
-c 4096
|
-c 4096
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
echo [*] Server exited with code !errorlevel!
|
echo [*] Server exited with code !errorlevel!
|
||||||
|
|
||||||
pause
|
pause
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|||||||
BUILD_DIR="$PROJECT_DIR/build"
|
BUILD_DIR="$PROJECT_DIR/build"
|
||||||
EXISTING_ISO="$BUILD_DIR/output/hermes-rescue.iso"
|
EXISTING_ISO="$BUILD_DIR/output/hermes-rescue.iso"
|
||||||
OUTPUT_DIR="$BUILD_DIR/output"
|
OUTPUT_DIR="$BUILD_DIR/output"
|
||||||
WORKDIR="/tmp/hermes-iso-quick"
|
WORKDIR="${WORKDIR:-/tmp/hermes-iso-quick}"
|
||||||
SOURCE_DIR="$PROJECT_DIR/src"
|
SOURCE_DIR="$PROJECT_DIR/src"
|
||||||
|
|
||||||
info() { echo -e "\033[0;34m[INFO]\033[0m $*"; }
|
info() { echo -e "\033[0;34m[INFO]\033[0m $*"; }
|
||||||
@@ -21,7 +21,8 @@ done
|
|||||||
|
|
||||||
[[ -f "$EXISTING_ISO" ]] || die "Existing ISO not found: $EXISTING_ISO"
|
[[ -f "$EXISTING_ISO" ]] || die "Existing ISO not found: $EXISTING_ISO"
|
||||||
|
|
||||||
rm -rf "$WORKDIR"
|
# Clean workdir contents (handles bind mounts safely)
|
||||||
|
rm -rf "$WORKDIR" 2>/dev/null || (rm -rf "$WORKDIR"/* 2>/dev/null; true)
|
||||||
mkdir -p "$WORKDIR/iso-contents" "$WORKDIR/squashfs-root"
|
mkdir -p "$WORKDIR/iso-contents" "$WORKDIR/squashfs-root"
|
||||||
|
|
||||||
info "Mounting existing ISO..."
|
info "Mounting existing ISO..."
|
||||||
@@ -40,15 +41,15 @@ unsquashfs -d "$WORKDIR/squashfs-root" -f "$WORKDIR/filesystem.squashfs" 2>&1 |
|
|||||||
ok "Squashfs extracted ($(du -sh "$WORKDIR/squashfs-root" | cut -f1))"
|
ok "Squashfs extracted ($(du -sh "$WORKDIR/squashfs-root" | cut -f1))"
|
||||||
|
|
||||||
info "Updating config.yaml..."
|
info "Updating config.yaml..."
|
||||||
cp "$SOURCE_DIR/hermes/config.yaml" "$WORKDIR/squashfs-root/hermes/config.yaml"
|
cp "$SOURCE_DIR/hermes/config.yaml" "$WORKDIR/squashfs-root/opt/hermes/config.yaml"
|
||||||
ok "config.yaml updated"
|
ok "config.yaml updated"
|
||||||
|
|
||||||
info "Updating auth.json..."
|
info "Updating auth.json..."
|
||||||
cp "$SOURCE_DIR/hermes/auth.json" "$WORKDIR/squashfs-root/hermes/auth.json"
|
cp "$SOURCE_DIR/hermes/auth.json" "$WORKDIR/squashfs-root/opt/hermes/auth.json"
|
||||||
ok "auth.json updated"
|
ok "auth.json updated"
|
||||||
|
|
||||||
info "Updating autorun.sh..."
|
info "Updating autorun.sh..."
|
||||||
cp "$SOURCE_DIR/hermes/autorun.sh" "$WORKDIR/squashfs-root/hermes/autorun.sh"
|
cp "$SOURCE_DIR/hermes/autorun.sh" "$WORKDIR/squashfs-root/opt/hermes/autorun.sh"
|
||||||
ok "autorun.sh updated"
|
ok "autorun.sh updated"
|
||||||
|
|
||||||
info "Re-packing squashfs..."
|
info "Re-packing squashfs..."
|
||||||
@@ -92,5 +93,5 @@ iso_size=$(du -h "$OUTPUT_ISO" | cut -f1)
|
|||||||
ok "ISO generated: $OUTPUT_ISO ($iso_size)"
|
ok "ISO generated: $OUTPUT_ISO ($iso_size)"
|
||||||
|
|
||||||
info "Cleaning up..."
|
info "Cleaning up..."
|
||||||
rm -rf "$WORKDIR"
|
# rm -rf workdir (skip - bind mount)
|
||||||
ok "Done!"
|
ok "Done!"
|
||||||
|
|||||||
Reference in New Issue
Block a user