Repository navigation
Description
Environment
- OS: Windows 11 (simplified Chinese, system ANSI codepage 936 / GBK)
- Unsloth Studio: 2026.8.22 (pip
unsloth) - Python: 3.13, UTF-8 mode enabled (
sys.flags.utf8_mode == 1,locale.getencoding() == 'cp936') - GPU: 2× NVIDIA GeForce RTX 3090 (SM 8.6), driver 591.86, CUDA 13.1
- llama.cpp: stuck at
b10639-mix-f6f92fe, targetb10715-mix-86bd2d3
Symptom
unsloth studio update reports:
llama.cpp update failed: installer exited 2
and dumps a large diagnostic blob ending with lines like:
driver_cuda_version=None
compute_caps=86
chosen_asset=none
asset_source=none
nvidia-smi error: unsupported operand type(s) for +: 'NoneType' and 'str'
The update then falls back to a source build and the runtime stays on the old version. whisper.cpp
dictation is also disabled as a knock-on effect (no compatible prebuilt).
Root cause
studio/install_llama_prebuilt.py reads the driver CUDA version by running nvidia-smi and regexing
CUDA(?: UMD)? Version: (\d+)\.(\d+) (around L2526). The call goes through run_capture() (L2347):
result = subprocess.run(
command,
capture_output = True,
text = True, # <-- no encoding / errors specified
timeout = timeout,
env = env,
**windows_hidden_subprocess_kwargs(),
)On a non-English Windows box, nvidia-smi prints a localized banner in the system ANSI codepage
(GBK), e.g. (保留所有权利。). Under Python UTF-8 mode the pipe is decoded as UTF-8, so the read
raises inside subprocess.py's _readerthread:
Exception in thread Thread-N (_readerthread):
File "...\subprocess.py", line 1612, in _readerthread
buffer.append(fh.read())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 2702: invalid continuation byte
Two things make this hard to spot:
- The exception happens on a reader thread, so the outer
tryat L2525 does not see the
UnicodeDecodeErroritself — it only seesresult.stdout is None. It is then swallowed by
except Exception: pass(L2540), leavingdriver_cuda_version = None. - With
driver_cuda_version = None, asset selection bails out (chosen_asset=none), the published
checksum comparison trivially fails, and the installer falls back to a source build that reports
llama.cpp already built— so the prebuilt update silently no-ops.
Note the -L and --query-gpu=... invocations succeed (their output is pure ASCII), which is why
compute_caps=86 is detected correctly and only the CUDA version is missing.
The secondary nvidia-smi error: unsupported operand type(s) for +: 'NoneType' and 'str' comes from
the diagnostic dump at L6037, which does smi.stdout + smi.stderr with stdout is None.
Minimal reproduction
import subprocess
subprocess.run(["nvidia-smi"], capture_output=True, text=True, encoding="utf-8", timeout=20)
# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 2702
subprocess.run(["nvidia-smi"], capture_output=True, text=True, encoding="mbcs", timeout=20)
# worksSuggested fix
One line in run_capture():
result = subprocess.run(
command,
capture_output = True,
text = True,
errors = "replace", # <-- add this
timeout = timeout,
env = env,
**windows_hidden_subprocess_kwargs(),
)The GBK bytes become U+FFFD, but the ASCII line CUDA Version: 13.1 still matches the regex.
Optionally, the two secondary issues are worth fixing while you are in there:
- L2540 (
except Exception: pass) hides real failures — consider logging the exception. - L6037
smi.stdout + smi.stderrbreaks whenstdoutisNone; use
"\n".join(p for p in (smi.stdout, smi.stderr) if p)as the main parse path already does (L2527).
Workaround
Manually download the matching app-<tag>-windows-x64-cuda13-older.zip from
unslothai/llama.cpp releases, verify the sha256 from llama-prebuilt-sha256.json, replace
build/bin/Release/, and write a valid UNSLOTH_PREBUILT_INFO.json (the
install_fingerprint is sha256(json.dumps(payload, sort_keys=True, separators=(",", ":")))).
This works, but has to be redone after every Studio self-update.
Activity
Stop a localized Windows console from losing a child's whole output s…