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.

Jetson / Rosetta follow-ups: an explicit GPU index beats the Jetson CPU record, JetPack 7 off the CPU note (#14494)

Daniel Hance27c36a2968
diff --git a/install.sh b/install.sh
index 0d70687bcac..ddaac1ae5f0 100755
--- a/install.sh
+++ b/install.sh
@@ -7701,11 +7701,19 @@ case "$TORCH_INDEX_URL" in
substep "CPU-only PyTorch (index pinned via UNSLOTH_TORCH_INDEX_URL / _FAMILY)."
elif { [ -e /etc/nv_tegra_release ] || grep -qa 'nvidia,tegra' /proc/device-tree/compatible 2>/dev/null; } && \
_tegra_note_cuda=$(_nvidia_driver_cuda_version 2>/dev/null || true) && \
- { [ -z "$_tegra_note_cuda" ] || [ "${_tegra_note_cuda%%.*}" -lt 13 ]; }; then
+ if [ -n "$_tegra_note_cuda" ]; then [ "${_tegra_note_cuda%%.*}" -lt 13 ]
+ else
+ # No driver answer (GPU-less container): L4T R38+ or Thor (tegra264) is JetPack 7, as utils/tegra.py.
+ case "$(head -n 1 /etc/nv_tegra_release 2>/dev/null)" in
+ "# R"[1-9][0-9][0-9]* | "# R"[4-9][0-9]* | "# R3"[89]*) false ;;
+ "# R"[0-9]*) true ;;
+ *) ! grep -qa 'nvidia,tegra264' /proc/device-tree/compatible 2>/dev/null ;;
+ esac
+ fi; then
# Re-detected: get_torch_index_url ran in a subshell. Thor (CUDA 13) is not on this route.
_tegra_cpu_route=true
substep "NVIDIA Jetson detected -- CPU-only PyTorch: the generic aarch64 CUDA wheels do not run on Tegra." "$C_WARN"
- substep "Training runs on the CPU. A JetPack PyTorch build for this venv's Python is kept if you install one;" "$C_WARN"
+ substep "Training runs on the CPU. A JetPack PyTorch build for this venv's Python, if you install one, is kept by updates;" "$C_WARN"
substep " NVIDIA's own wheels target JetPack's system Python: https://docs.nvidia.com/deeplearning/frameworks/install-pytorch-jetson-platform/" "$C_WARN"
elif _has_amd_rocm_gpu; then
# A generation ROCm never covered is not a missing SDK (#8529). Unlike the arm in get_torch_index_url, this one runs even when the arch read fine, so it needs its own peer guard: an RX 5700 beside an RX 7900 lands here whenever the 7900's ROCm is too old, and blaming the 5700 would replace the upgrade advice with advice that is false for the card that caused the fallback. _infer_linux_amd_gfx_arch scans every display adapter, so a covered answer clears this one.
diff --git a/studio/backend/tests/test_chat_only_reason.py b/studio/backend/tests/test_chat_only_reason.py
index fa919ff46ef..af02645173c 100644
--- a/studio/backend/tests/test_chat_only_reason.py
+++ b/studio/backend/tests/test_chat_only_reason.py
@@ -268,6 +268,25 @@ def test_an_automatic_cpu_record_counts_as_chosen_only_on_a_jetson(monkeypatch,
assert hw._expected_cpu_flavor_was_chosen() is True
+ "var, value",
+ [
+ ("UNSLOTH_TORCH_INDEX_FAMILY", "cu126"),
+ ("UNSLOTH_TORCH_INDEX_URL", "https://example.test/whl/cu126"),
+ ],
+)
+def test_a_stated_gpu_index_beats_the_jetson_cpu_record(monkeypatch, var, value):
+ # An explicit GPU pin wins over the automatic cpu history: the CPU build is reported as before.
+ from utils import tegra as tegra_mod
+
+ monkeypatch.delenv("UNSLOTH_TORCH_INDEX_URL", raising = False)
+ monkeypatch.delenv("UNSLOTH_TORCH_INDEX_FAMILY", raising = False)
+ monkeypatch.setenv(var, value)
+ monkeypatch.setattr(hw, "_recorded_install_flavor", lambda: ("cpu", False))
+ monkeypatch.setattr(tegra_mod, "tegra_before_cuda13", lambda: True)
+ assert hw._expected_cpu_flavor_was_chosen() is False
+
+
@pytest.mark.parametrize(
"release, compatible, expected",
[
diff --git a/studio/backend/tests/test_torch_cpu_build_on_nvidia_host.py b/studio/backend/tests/test_torch_cpu_build_on_nvidia_host.py
index 028a8b73ff3..c49caf360b4 100644
--- a/studio/backend/tests/test_torch_cpu_build_on_nvidia_host.py
+++ b/studio/backend/tests/test_torch_cpu_build_on_nvidia_host.py
@@ -147,6 +147,14 @@ def _no_inherited_visibility_mask(monkeypatch):
monkeypatch.delenv(var, raising = False)
[email protected](autouse = True)
+def _not_a_jetson(monkeypatch):
+ """A pre-CUDA-13 Jetson treats an automatic cpu record as chosen, so running the suite on one would
+ flip every unpinned-cpu assertion here. The Jetson cells live in test_chat_only_reason.py."""
+ from utils import tegra as tegra_mod
+ monkeypatch.setattr(tegra_mod, "tegra_before_cuda13", lambda: False)
+
+
@pytest.fixture(autouse = True)
def _no_carried_over_torch_measurement(monkeypatch):
"""The torch snapshot is cached with a TTL, so one test's fake host would answer
diff --git a/studio/backend/tests/test_video_cpu_developer_mode.py b/studio/backend/tests/test_video_cpu_developer_mode.py
index 18aa0f4d356..c33e30ce97e 100644
--- a/studio/backend/tests/test_video_cpu_developer_mode.py
+++ b/studio/backend/tests/test_video_cpu_developer_mode.py
@@ -73,6 +73,8 @@ def _host(
monkeypatch.setattr(hw, "current_chat_only_verdict", lambda: (chat_only_reason, None))
monkeypatch.setattr(hw, "_torch_mps_available", lambda: torch if mps is None else mps)
monkeypatch.setattr(hw.platform, "system", lambda: system)
+ # Independent of the interpreter running the suite (an x86_64 Python on Apple Silicon is Rosetta).
+ monkeypatch.setattr(hw, "_running_under_rosetta", lambda: False)
def _opt_in(store, value):
diff --git a/studio/backend/utils/hardware/hardware.py b/studio/backend/utils/hardware/hardware.py
index e5d6235955d..a7d63467d93 100644
--- a/studio/backend/utils/hardware/hardware.py
+++ b/studio/backend/utils/hardware/hardware.py
@@ -881,7 +881,9 @@ def _expected_cpu_flavor_was_chosen() -> bool:
recorded, pinned = _recorded_install_flavor()
if recorded == "cpu" and not pinned:
# A pre-CUDA-13 Jetson always resolves to cpu (the generic aarch64 CUDA wheels see no GPU there), so a
- # repair would land on cpu again. Thor (CUDA 13) installs cu130 and keeps the repair.
+ # repair would land on cpu again. Thor (CUDA 13) installs cu130 and keeps the repair. A stated GPU index wins.
+ if _stated_torch_index_source():
+ return False
from utils.tegra import tegra_before_cuda13
return tegra_before_cuda13()
return recorded == "cpu" and pinned
diff --git a/tests/studio/install/test_jetson_tegra_torch_route_4856.py b/tests/studio/install/test_jetson_tegra_torch_route_4856.py
index 30586fc07d6..d97dc5e395b 100644
--- a/tests/studio/install/test_jetson_tegra_torch_route_4856.py
+++ b/tests/studio/install/test_jetson_tegra_torch_route_4856.py
@@ -196,9 +196,10 @@ def _run_cpu_note(
tegra: str,
pinned: bool = False,
cuda: str = "",
+ root: "Path | None" = None,
) -> str:
"""install.sh's "PyTorch wheel index note" block for a CPU index, on a fake root."""
- root = _host(tmp_path, tegra = tegra, gpu = False)
+ root = root or _host(tmp_path, tegra = tegra, gpu = False)
src = INSTALL_SH.read_text(encoding = "utf-8")
start = src.index("# ── PyTorch wheel index note ──")
block = src[start : src.index("\nesac\n", start) + 6]
@@ -240,6 +241,32 @@ def test_install_sh_cpu_note_leaves_thor_off_the_jetson_diagnosis(tmp_path):
assert "NVIDIA Jetson detected" in _run_cpu_note(tmp_path / "jp6", "release", cuda = "12.6")
+@_POSIX
+ "release, compatible, jetson",
+ [
+ (None, b"nvidia,tegra264\0", False), # Thor, GPU-less container
+ ("# R38 (release), REVISION: 2.0\n", b"nvidia,tegra264\0", False),
+ ("# R39 (release), REVISION: 0.0\n", b"nvidia,tegra234\0", False), # JetPack 7.2 Orin
+ ("# R36 (release), REVISION: 4.3\n", b"nvidia,tegra234\0", True),
+ (None, b"nvidia,tegra234\0", True),
+ ],
+)
+def test_install_sh_cpu_note_without_a_driver_answer_follows_the_l4t_release(
+ tmp_path, release, compatible, jetson
+):
+ # No CUDA version (GPU-less container): JetPack 7 is not told the generic wheels do not run on it.
+ root = tmp_path / "host"
+ (root / "etc").mkdir(parents = True)
+ (root / "dt").mkdir()
+ if release is not None:
+ (root / "etc" / "nv_tegra_release").write_text(release)
+ (root / "dt" / "compatible").write_bytes(compatible)
+ out = _run_cpu_note(tmp_path, "", root = root)
+ assert ("NVIDIA Jetson detected" in out) is jetson
+ assert ("No GPU detected" in out) is not jetson
+
+
@_POSIX
@pytest.mark.parametrize("tegra, pinned", [("", False), ("dt-other", False), ("release", True)])
def test_install_sh_cpu_note_unchanged_off_the_jetson_route(tmp_path, tegra, pinned):
diff --git a/tests/studio/test_mlx_context_platform_matrix.py b/tests/studio/test_mlx_context_platform_matrix.py
index c13243454e4..9b84d74197f 100644
--- a/tests/studio/test_mlx_context_platform_matrix.py
+++ b/tests/studio/test_mlx_context_platform_matrix.py
@@ -215,7 +215,10 @@ def spoof_cell(monkeypatch, spoof_hardware):
# An inherited ZE_AFFINITY_MASK plus a CPU-only torch would route the cell to XPU.
for var in ("ZE_AFFINITY_MASK", "UNSLOTH_FORCE_XPU", "CUDA_VISIBLE_DEVICES"):
monkeypatch.delenv(var, raising = False)
- return _DISPATCH._import_studio_hardware_module()
+ hw = _DISPATCH._import_studio_hardware_module()
+ # The real sysctl answers hw.optional.arm64=1 on an Apple Silicon runner, turning a spoofed Intel Mac into Rosetta.
+ monkeypatch.setattr(hw, "_running_under_rosetta", lambda: False)
+ return hw
return _apply