ollama - 💡(How to fix) Fix MLX runner fails on Apple M5 Max — empty libdirs in Metal GPU detection [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15642Fetched 2026-04-18 05:52:07
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
labeled ×1

Error Message

Error: failed to load model: 500 Internal Server Error: mlx runner failed: Error: failed to initialize MLX: time=2026-04-17T01:53:16.411-04:00 level=WARN source=server.go:164 msg=mlx-runner msg="time=2026-04-17T01:53:16.411-04:00 level=ERROR msg="unable to initialize MLX" error="failed to initialize MLX:

Fix Action

Fix / Workaround

Workarounds attempted (all unsuccessful)

RAW_BUFFERClick to expand / collapse

What is the issue?

Description

The MLX runner cannot initialize on an Apple M5 Max system. The server log shows that Metal GPU detection succeeds and correctly identifies the chip as "Apple M5 Max", but the libdirs field is populated as an empty string. This empty path is then passed to the MLX runner subprocess, which fails to locate libmlxc.dylib even though the library is physically present in the app bundle.

The issue appears to be that Ollama's Metal GPU family detection does not yet recognize the M5 Max's Metal GPU family, so it cannot select between the bundled mlx_metal_v3 and mlx_metal_v4 variants.

Steps to reproduce

  1. On an Apple M5 Max Mac running macOS 26.4.1
  2. Install Ollama 0.20.7 from the official DMG (https://ollama.com/download/mac)
  3. Run: ollama run x/z-image-turbo

Expected behavior

Model loads and runs successfully using the bundled MLX runtime.

Actual behavior

Error: failed to load model: 500 Internal Server Error: mlx runner failed: Error: failed to initialize MLX: libmlxc.dylib not found (exit: exit status 1)

Relevant server log excerpt

time=2026-04-17T01:53:04.277-04:00 level=INFO source=types.go:42 msg="inference compute" id=0 filter_id=0 library=Metal compute=0.0 name=Metal description="Apple M5 Max" libdirs="" driver=0.0 pci_id="" type=discrete
total="107.5 GiB" available="107.5 GiB" ... time=2026-04-17T01:53:16.398-04:00 level=INFO source=server.go:171 msg="starting mlx runner subprocess"
model=x/z-image-turbo:latest port=53004
time=2026-04-17T01:53:16.411-04:00 level=WARN source=server.go:164 msg=mlx-runner
msg="time=2026-04-17T01:53:16.411-04:00 level=ERROR msg="unable to initialize MLX" error="failed to initialize MLX: libmlxc.dylib not found""

Key line: description="Apple M5 Max" libdirs=""

Confirmation that the dylibs are present

$ find /Applications/Ollama.app -iname "mlx" /Applications/Ollama.app/Contents/Resources/mlx_metal_v3
/Applications/Ollama.app/Contents/Resources/mlx_metal_v3/libmlx.dylib /Applications/Ollama.app/Contents/Resources/mlx_metal_v3/mlx.metallib
/Applications/Ollama.app/Contents/Resources/mlx_metal_v3/libmlxc.dylib
/Applications/Ollama.app/Contents/Resources/mlx_metal_v4 /Applications/Ollama.app/Contents/Resources/mlx_metal_v4/libmlx.dylib
/Applications/Ollama.app/Contents/Resources/mlx_metal_v4/mlx.metallib
/Applications/Ollama.app/Contents/Resources/mlx_metal_v4/libmlxc.dylib

Workarounds attempted (all unsuccessful)

  • Symlinked libmlx.dylib and libmlxc.dylib into /usr/local/lib/ — no effect (runner ignores dyld search path)
  • Set DYLD_FALLBACK_LIBRARY_PATH via launchctl setenv — no effect
  • Attempted to copy dylibs alongside the ollama binary in Contents/Resources/ — blocked by SIP on the signed app bundle

Environment

  • Hardware: Apple MacBook Pro, M5 Max, 128 GB unified memory
  • macOS: 26.4.1 (Build 25E253)
  • Ollama version: 0.20.7 (from https://ollama.com/download/mac)
  • Install path: /Applications/Ollama.app

Suggested fix

Add M5 Max to the Metal GPU family detection in the runner, and populate libdirs with the appropriate path (likely
mlx_metal_v4).

Relevant log output

OS

macOS

GPU

Apple

CPU

Apple

Ollama version

0.20.7

extent analysis

TL;DR

The most likely fix is to update Ollama's Metal GPU family detection to recognize the M5 Max's Metal GPU family and populate the libdirs field with the correct path to the MLX runtime library.

Guidance

  • The issue is caused by Ollama's inability to detect the M5 Max's Metal GPU family, resulting in an empty libdirs field being passed to the MLX runner subprocess.
  • To fix this, the Metal GPU family detection in the runner needs to be updated to recognize the M5 Max's Metal GPU family.
  • The libdirs field should be populated with the path to the appropriate MLX runtime library, likely mlx_metal_v4.
  • Verify that the MLX runner can initialize successfully by checking the server log for the presence of the libmlxc.dylib library.

Example

No code example is provided as the issue is related to the Ollama application's configuration and detection of the M5 Max's Metal GPU family.

Notes

The suggested fix requires updating the Ollama application's code to recognize the M5 Max's Metal GPU family and populate the libdirs field correctly. This may require modifications to the Ollama application's source code.

Recommendation

Apply the suggested fix by updating the Ollama application's Metal GPU family detection to recognize the M5 Max's Metal GPU family and populate the libdirs field with the correct path to the MLX runtime library. This will allow the MLX runner to initialize successfully and resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix MLX runner fails on Apple M5 Max — empty libdirs in Metal GPU detection [1 participants]