Files
hermes-portable-rescue/build/output/start-llama-server.bat
T
shawn 4e0ab94ee2 feat: GPU detection for LLM server (NVIDIA/AMD/Intel/Vulkan + CPU fallback)
- Added start-llama-server.bat with cross-brand GPU auto-detection:
  * Detection 1: nvidia-smi for NVIDIA
  * Detection 2: WMIC for AMD, Intel Arc, Intel HD/Iris/UHD
  * Detection 3: vulkaninfo as final fallback probe
  * Falls back to CPU-only build when no GPU found
- Downloaded llama-server b9947 builds:
  * Vulkan build (91 MB) - supports all GPU brands
  * CPU build (45 MB) - fallback in cpu/ subdir
- Downloaded Qwen2.5-Coder-1.5B Q4_K_M model (1.1 GB)
- Fixed run-hermes.bat polling: replaces fixed 5s timeout with
  curl-based readiness polling (up to 30 attempts, 1s apart)
- All .bat files verified: ASCII text, CRLF line terminators
- Added .gitignore for build artifacts and large binaries
2026-07-10 00:58:56 -04:00

126 lines
3.9 KiB
Batchfile

@echo off
:: ==============================================================================
:: Hermes Portable Rescue - llama-server launcher with GPU detection
:: ==============================================================================
:: Detects GPU brand (NVIDIA, AMD, Intel, integrated) and launches the
:: appropriate llama-server build (Vulkan for GPU, CPU-only fallback).
:: ==============================================================================
setlocal enabledelayedexpansion
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 PORT=11434
set GPU_FOUND=0
echo.
echo ============================================
echo Hermes LLM Server - GPU Detection
echo ============================================
echo.
:: --- Detection 1: nvidia-smi (NVIDIA) --------------------------------------
nvidia-smi >nul 2>&1
if !errorlevel! equ 0 (
for /f "tokens=*" %%a in ('nvidia-smi --query-gpu=name --format=csv,noheader 2^>nul') do (
set GPU_NAME=%%a
)
echo [OK] NVIDIA GPU detected: !GPU_NAME!
set GPU_FOUND=1
)
:: Detection 2: WMIC - check for AMD/Intel GPUs
if !GPU_FOUND! equ 0 (
wmic path win32_videocontroller get name 2>nul | findstr /i "nvidia" >nul
if !errorlevel! equ 0 (
echo [OK] NVIDIA GPU detected via WMI
set GPU_FOUND=1
) else (
wmic path win32_videocontroller get name 2>nul | findstr /i "amd radeon" >nul
if !errorlevel! equ 0 (
echo [OK] AMD GPU detected via WMI
set GPU_FOUND=1
) else (
wmic path win32_videocontroller get name 2>nul | findstr /i "intel arc" >nul
if !errorlevel! equ 0 (
echo [OK] Intel GPU detected via WMI
set GPU_FOUND=1
) else (
wmic path win32_videocontroller get name 2>nul | findstr /i "intel hd intel iris intel uhd" >nul
if !errorlevel! equ 0 (
echo [OK] Intel integrated graphics detected via WMI
set GPU_FOUND=1
)
)
)
)
)
:: Detection 3: vulkaninfo (direct Vulkan probe)
if !GPU_FOUND! equ 0 (
where vulkaninfo >nul 2>&1
if !errorlevel! equ 0 (
vulkaninfo --summary 2>nul | findstr /c:"Vulkan Instance" >nul
if !errorlevel! equ 0 (
echo [OK] Vulkan-capable device detected
set GPU_FOUND=1
)
)
)
:: Check model exists
if not exist "!MODEL!" (
echo [ERROR] Model not found: !MODEL!
echo.
echo Please download a GGUF model and place it at:
echo !MODEL!
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
exit /b 1
)
:: Launch
if !GPU_FOUND! equ 1 (
echo.
echo [*] Starting llama-server with GPU acceleration (Vulkan)...
echo [*] Model: qwen2.5-coder-1.5b-q4_k_m.gguf
echo [*] Server: http://127.0.0.1:!PORT!/v1
echo [*] Flags: --n-gpu-layers 99 --mlock --cont-batching -c 4096
echo.
echo [*] Press Ctrl+C to stop the server.
echo.
"!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! ^
-m "!MODEL!" ^
--mlock ^
--cont-batching ^
-c 4096
)
echo.
echo [*] Server exited with code !errorlevel!
pause