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.

Auto-add CUDA DLLs to PATH when launching llama-server on Windows

Roland Tannous12867f701b87
diff --git a/setup.ps1 b/setup.ps1
index 49e7ebba0d8..fae0ce75290 100644
--- a/setup.ps1
+++ b/setup.ps1
@@ -820,18 +820,16 @@ Write-Host "[OK] Batch launchers created in $BatDir (works from cmd.exe when ven
# Done
# ============================================
Write-Host ""
-Write-Host "+==============================================+" -ForegroundColor Green
-Write-Host "| Setup Complete! |" -ForegroundColor Green
-Write-Host "| |" -ForegroundColor Green
-if ($AliasAdded) {
- Write-Host "| PowerShell: run '. `$PROFILE' |" -ForegroundColor Green
- Write-Host "| or open a new terminal, then: |" -ForegroundColor Green
-} else {
- Write-Host "| Launch with: |" -ForegroundColor Green
-}
-Write-Host "| |" -ForegroundColor Green
-Write-Host "| unsloth-studio -H 0.0.0.0 -p 8000 |" -ForegroundColor Green
-Write-Host "| |" -ForegroundColor Green
-Write-Host "| cmd.exe: .venv\Scripts\activate.bat |" -ForegroundColor Green
-Write-Host "| unsloth-studio -H 0.0.0.0 -p 8000 |" -ForegroundColor Green
-Write-Host "+==============================================+" -ForegroundColor Green
\ No newline at end of file
+Write-Host "+===============================================+" -ForegroundColor Green
+Write-Host "| Setup Complete! |" -ForegroundColor Green
+Write-Host "| |" -ForegroundColor Green
+Write-Host "| IMPORTANT: Open a NEW terminal, then: |" -ForegroundColor Yellow
+Write-Host "| |" -ForegroundColor Green
+Write-Host "| cmd.exe: |" -ForegroundColor Green
+Write-Host "| .venv\Scripts\activate.bat |" -ForegroundColor Green
+Write-Host "| unsloth-studio -H 0.0.0.0 -p 8000 |" -ForegroundColor Green
+Write-Host "| |" -ForegroundColor Green
+Write-Host "| PowerShell: |" -ForegroundColor Green
+Write-Host "| .venv\Scripts\Activate.ps1 |" -ForegroundColor Green
+Write-Host "| unsloth-studio -H 0.0.0.0 -p 8000 |" -ForegroundColor Green
+Write-Host "+===============================================+" -ForegroundColor Green
\ No newline at end of file
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index 7ae9bd142a1..023edb959b7 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -235,13 +235,31 @@ class LlamaCppBackend:
logger.info(f"Starting llama-server: {' '.join(cmd)}")
- # Set LD_LIBRARY_PATH so llama-server can find its shared libs
- # (libmtmd.so, libllama.so, etc.) which live next to the binary
+ # Set library paths so llama-server can find its shared libs and CUDA DLLs
import os
+ import sys
env = os.environ.copy()
binary_dir = str(Path(binary).parent)
- existing_ld = env.get("LD_LIBRARY_PATH", "")
- env["LD_LIBRARY_PATH"] = f"{binary_dir}:{existing_ld}" if existing_ld else binary_dir
+
+ if sys.platform == "win32":
+ # On Windows, CUDA DLLs (cublas64_12.dll, cudart64_12.dll, etc.)
+ # must be on PATH. Add CUDA_PATH\bin if available.
+ path_dirs = [binary_dir]
+ cuda_path = os.environ.get("CUDA_PATH", "")
+ if cuda_path:
+ cuda_bin = os.path.join(cuda_path, "bin")
+ if os.path.isdir(cuda_bin):
+ path_dirs.append(cuda_bin)
+ # Some CUDA installs put DLLs in bin\x64
+ cuda_bin_x64 = os.path.join(cuda_path, "bin", "x64")
+ if os.path.isdir(cuda_bin_x64):
+ path_dirs.append(cuda_bin_x64)
+ existing_path = env.get("PATH", "")
+ env["PATH"] = ";".join(path_dirs) + ";" + existing_path
+ else:
+ # Linux: set LD_LIBRARY_PATH for shared libs next to the binary
+ existing_ld = env.get("LD_LIBRARY_PATH", "")
+ env["LD_LIBRARY_PATH"] = f"{binary_dir}:{existing_ld}" if existing_ld else binary_dir
self._stdout_lines = []
self._process = subprocess.Popen(