@echo off title Hermes Portable - Offline LLM Server with GPU Detection :: ============================================================================== :: Hermes Portable Rescue - llama-server launcher with multi-brand 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 OLLAMA_DIR=%~dp0bin\ollama set MODEL=%OLLAMA_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. 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) 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) 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