From 4fadb05c50b5de5ad299ec82c324d6743acde5fb Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Thu, 2 Apr 2026 15:49:18 +0000 Subject: [PATCH] fix: detect Apple Silicon under Rosetta and use arm64 binaries install.sh previously set MAC_INTEL=true unconditionally when uname reported x86_64 on macOS, even after detecting Apple Silicon via sysctl. This caused ARM Mac users running under Rosetta to get the Intel llama.cpp prebuilt, skip PyTorch, and use Python 3.12. Now when Rosetta is detected, _ARCH is overridden to arm64 so the rest of the installer (Python version, torch, llama.cpp prebuilt) picks the correct architecture. Also adds matching Rosetta detection in install_llama_prebuilt.py's detect_host() so the prebuilt resolver works correctly even when invoked independently under Rosetta. --- install.sh | 9 +++++---- studio/install_llama_prebuilt.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 2d9a368555..efabe15a70 100755 --- a/install.sh +++ b/install.sh @@ -729,12 +729,13 @@ if [ "$OS" = "macos" ] && [ "$_ARCH" = "x86_64" ]; then # sysctl hw.optional.arm64 returns "1" on Apple Silicon even in Rosetta. if [ "$(sysctl -in hw.optional.arm64 2>/dev/null || echo 0)" = "1" ]; then echo "" - echo " WARNING: Apple Silicon detected, but this shell is running under Rosetta (x86_64)." - echo " Re-run install.sh from a native arm64 terminal for full PyTorch support." - echo " Continuing in GGUF-only mode for now." + echo " NOTE: Apple Silicon detected under Rosetta (x86_64 shell)." + echo " Overriding to arm64 for correct binaries." echo "" + _ARCH="arm64" + else + MAC_INTEL=true fi - MAC_INTEL=true fi if [ -n "$_USER_PYTHON" ]; then diff --git a/studio/install_llama_prebuilt.py b/studio/install_llama_prebuilt.py index 76d22984d7..7924afb205 100755 --- a/studio/install_llama_prebuilt.py +++ b/studio/install_llama_prebuilt.py @@ -1993,6 +1993,18 @@ def run_capture( def detect_host() -> HostInfo: system = platform.system() machine = platform.machine().lower() + # macOS Rosetta: platform.machine() reports x86_64 on Apple Silicon. + # Detect the real hardware via sysctl so we download arm64 binaries. + if system == "Darwin" and machine in {"x86_64", "amd64"}: + try: + r = subprocess.run( + ["sysctl", "-in", "hw.optional.arm64"], + capture_output=True, text=True, timeout=5, + ) + if r.stdout.strip() == "1": + machine = "arm64" + except Exception: + pass is_windows = system == "Windows" is_linux = system == "Linux" is_macos = system == "Darwin"