Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

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

Roland Tannous3521de704057
diff --git a/setup.ps1 b/setup.ps1
index c213dcbf50a..1269467368f 100644
--- a/setup.ps1
+++ b/setup.ps1
@@ -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
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index cf4494df303..7ae9bd142a1 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -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)
diff --git a/test_llama_cpp.ps1 b/test_llama_cpp.ps1
index 6e160576400..b98177eac6a 100644
--- a/test_llama_cpp.ps1
+++ b/test_llama_cpp.ps1
@@ -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