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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Move llama.cpp clone/build from in-tree to ~/.unsloth/llama.cpp
Roland Tannouse280e457d169
diff --git a/setup.ps1 b/setup.ps1index fd5447b124c..8a2ec560331 100644--- a/setup.ps1+++ b/setup.ps1@@ -739,13 +739,16 @@ if ($OpenSslRoot) {# ==========================================================================# PHASE 4: Build llama.cpp with CUDA for GGUF inference + export# ==========================================================================-# Builds in-tree at $REPO/llama.cpp/ (same as setup.sh on Linux).-# This directory is already in .gitignore.+# Builds at ~/.unsloth/llama.cpp — a single shared location under the user's+# home directory. This is used by both the inference server and the GGUF+# export pipeline (unsloth-zoo).# We build:-# - llama-server: for GGUF model inference (with HTTPS if vcpkg/curl available)+# - llama-server: for GGUF model inference (with HTTPS if OpenSSL available)# - llama-quantize: for GGUF export quantization# Prerequisites (git, cmake, VS Build Tools, CUDA Toolkit) already installed in Phase 1.-$LlamaCppDir = Join-Path $PSScriptRoot "llama.cpp"+$UnslothHome = Join-Path $env:USERPROFILE ".unsloth"+if (-not (Test-Path $UnslothHome)) { New-Item -ItemType Directory -Force $UnslothHome | Out-Null }+$LlamaCppDir = Join-Path $UnslothHome "llama.cpp"$BuildDir = Join-Path $LlamaCppDir "build"$LlamaServerBin = Join-Path $BuildDir "bin\Release\llama-server.exe"diff --git a/setup.sh b/setup.shindex 409df0b798d..07ea131125b 100755--- a/setup.sh+++ b/setup.sh@@ -197,11 +197,14 @@ elsefi# ── 8. Build llama.cpp binaries for GGUF inference + export ──-# Builds in-tree at $REPO/llama.cpp/. This directory is shared with-# unsloth-zoo's GGUF export pipeline. We build:+# Builds at ~/.unsloth/llama.cpp — a single shared location under the user's+# home directory. This is used by both the inference server and the GGUF+# export pipeline (unsloth-zoo).# - llama-server: for GGUF model inference# - llama-quantize: for GGUF export quantization (symlinked to root for check_llama_cpp())-LLAMA_CPP_DIR="$SCRIPT_DIR/llama.cpp"+UNSLOTH_HOME="$HOME/.unsloth"+mkdir -p "$UNSLOTH_HOME"+LLAMA_CPP_DIR="$UNSLOTH_HOME/llama.cpp"LLAMA_SERVER_BIN="$LLAMA_CPP_DIR/build/bin/llama-server"rm -rf "$LLAMA_CPP_DIR"{diff --git a/studio/backend/core/export/export.py b/studio/backend/core/export/export.pyindex bc4e267f75d..3d3db2d560a 100644--- a/studio/backend/core/export/export.py+++ b/studio/backend/core/export/export.py@@ -418,9 +418,8 @@ class ExportBackend:pre_existing_ggufs = set(glob.glob(os.path.join(cwd, "*.gguf")))# Pass absolute path — no os.chdir needed.- # unsloth saves intermediate HF model files into model_save_path,- # while check_llama_cpp("llama.cpp") resolves against cwd (repo root)- # where setup.sh already built llama.cpp with quantizer.+ # unsloth saves intermediate HF model files into model_save_path.+ # unsloth-zoo's check_llama_cpp() uses ~/.unsloth/llama.cpp by default.model_save_path = os.path.join(abs_save_dir, "model")self.current_model.save_pretrained_gguf(model_save_path,diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex e0e2eebcf21..09f8a2fcc97 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -77,10 +77,11 @@ class LlamaCppBackend:Search order:1. LLAMA_SERVER_PATH environment variable- 2. ./llama.cpp/build/bin/llama-server (built by setup.sh in-tree)- 3. ~/.unsloth/llama.cpp/build/bin/Release/llama-server (built by setup.ps1 on Windows)- 4. llama-server on PATH (system install)- 5. ./bin/llama-server (legacy: extracted binary)+ 2. ~/.unsloth/llama.cpp/build/bin/llama-server (Linux, built by setup.sh)+ 3. ~/.unsloth/llama.cpp/build/bin/Release/llama-server.exe (Windows, built by setup.ps1)+ 4. ./llama.cpp/build/bin/llama-server (legacy: in-tree build)+ 5. llama-server on PATH (system install)+ 6. ./bin/llama-server (legacy: extracted binary)"""import osimport sys@@ -92,31 +93,34 @@ class LlamaCppBackend:if env_path and Path(env_path).is_file():return env_path- # Project root: llama_cpp.py → inference/ → core/ → backend/ → studio/ → root- project_root = Path(__file__).resolve().parents[4]+ # 2. ~/.unsloth/llama.cpp (primary — setup.sh / setup.ps1 build here)+ unsloth_home = Path.home() / ".unsloth" / "llama.cpp"+ home_linux = unsloth_home / "build" / "bin" / binary_name+ if home_linux.is_file():+ return str(home_linux)++ # 3. Windows MSVC build has Release subdir+ if sys.platform == "win32":+ home_win = unsloth_home / "build" / "bin" / "Release" / binary_name+ if home_win.is_file():+ return str(home_win)- # 2. In-tree llama.cpp build (setup.sh builds here on Linux)+ # 4. Legacy: in-tree build (older setup.sh / setup.ps1 versions)+ project_root = Path(__file__).resolve().parents[4]build_path = project_root / "llama.cpp" / "build" / "bin" / binary_nameif build_path.is_file():return str(build_path)-- # 3. Windows MSVC build (Release config, in-tree — matches setup.ps1)if sys.platform == "win32":- # In-tree (primary — setup.ps1 now builds here)win_path = project_root / "llama.cpp" / "build" / "bin" / "Release" / binary_nameif win_path.is_file():return str(win_path)- # 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)- # 4. System PATH+ # 5. System PATHsystem_path = shutil.which("llama-server")if system_path:return system_path- # 5. Legacy: extracted to bin/+ # 6. Legacy: extracted to bin/bin_path = project_root / "bin" / binary_nameif bin_path.is_file():return str(bin_path)