Build llama.cpp in-tree, auto-detect driver CUDA version for compatible toolkit

This commit is contained in:
Roland Tannous 2026-02-28 07:45:40 +00:00
commit 3521de7040
3 changed files with 7 additions and 7 deletions

View file

@ -556,12 +556,13 @@ $ErrorActionPreference = $prevEAP
# ==========================================================================
# PHASE 4: Build llama.cpp with CUDA for GGUF inference + export
# ==========================================================================
# Builds at ~/.unsloth/llama.cpp/ (persistent across pip upgrades).
# Builds in-tree at $REPO/llama.cpp/ (same as setup.sh on Linux).
# This directory is already in .gitignore.
# We build:
# - llama-server: for GGUF model inference
# - llama-quantize: for GGUF export quantization
# Prerequisites (git, cmake, VS Build Tools, CUDA Toolkit) already installed in Phase 1.
$LlamaCppDir = Join-Path $env:USERPROFILE ".unsloth\llama.cpp"
$LlamaCppDir = Join-Path $PSScriptRoot "llama.cpp"
$BuildDir = Join-Path $LlamaCppDir "build"
$LlamaServerBin = Join-Path $BuildDir "bin\Release\llama-server.exe"
@ -588,8 +589,6 @@ if (Test-Path $LlamaServerBin) {
$FailedStep = ""
# -- Step A: Clone or pull llama.cpp --
$UnslothDir = Join-Path $env:USERPROFILE ".unsloth"
if (-not (Test-Path $UnslothDir)) { New-Item -ItemType Directory -Path $UnslothDir -Force | Out-Null }
if (Test-Path (Join-Path $LlamaCppDir ".git")) {
Write-Host " llama.cpp repo already cloned, pulling latest..." -ForegroundColor Gray

View file

@ -100,13 +100,13 @@ class LlamaCppBackend:
if build_path.is_file():
return str(build_path)
# 3. Windows MSVC build (setup.ps1 builds here — Release config)
# 3. Windows MSVC build (Release config, in-tree — matches setup.ps1)
if sys.platform == "win32":
# In-tree
# In-tree (primary — setup.ps1 now builds here)
win_path = project_root / "llama.cpp" / "build" / "bin" / "Release" / binary_name
if win_path.is_file():
return str(win_path)
# ~/.unsloth (setup.ps1 default location)
# Legacy: ~/.unsloth (older setup.ps1 versions built here)
home_path = Path.home() / ".unsloth" / "llama.cpp" / "build" / "bin" / "Release" / binary_name
if home_path.is_file():
return str(home_path)

View file

@ -32,6 +32,7 @@ if ($BinaryPath) {
$RepoRoot = $PSScriptRoot
$SearchPaths += Join-Path $RepoRoot "llama.cpp\build\bin\Release\llama-server.exe"
$SearchPaths += Join-Path $RepoRoot "llama.cpp\build\bin\llama-server.exe"
# Legacy: older setup.ps1 built under ~/.unsloth
$SearchPaths += Join-Path $env:USERPROFILE ".unsloth\llama.cpp\build\bin\Release\llama-server.exe"
# Check LLAMA_SERVER_PATH env var