MLX - dynamic loading of mlx-c (#13735)

* MLX - dynamic loading of mlx-c

Create a wrapper layer to indirect the dependency on mlx-c so
the main ollama binary does not have a load-time dependency on mlx-c, mlx, and on linux, cuda.  Lazy load the library via dlopen
so we can adjust the path to ensure the dependencies are found
and fail gracefully if not present.

* review comments

* fix broken tests
This commit is contained in:
Daniel Hiltgen
2026-01-16 16:34:22 -08:00
committed by GitHub
parent a077d996e3
commit 12719b6e87
24 changed files with 9043 additions and 228 deletions

View File

@@ -270,10 +270,10 @@ cmake --build --preset MLX --parallel
cmake --install build --component MLX
```
Next, build the `ollama-mlx` binary, which is a separate build of the Ollama runtime with MLX support enabled (needs to be in the same directory as `ollama`):
When building with the `-tags mlx` flag, the main `ollama` binary includes MLX support for experimental features like image generation:
```shell
go build -tags mlx -o ollama-mlx .
go build -tags mlx .
```
Finally, start the server: