_cblas_sgemm$NEWLAPACK while running mlx mistral example

System details :

Sonoma 14.2.1

xcode-select version 2405

I am trying to run the default example provided by mlx-examples directory.

python mistral.py --model_path Mistral-7B-Instruct-v0.2/ --prompt "My name is"

I am getting the following error :

ImportError: dlopen(/opt/homebrew/anaconda3/envs/language_models_env/lib/python3.10/site-packages/mlx/core.cpython-310-darwin.so, 0x0002): Symbol not found: _cblas_sgemm$NEWLAPACK
  Referenced from: <F6C66D71-1323-3E71-9C97-70DC2D75278D> /opt/homebrew/anaconda3/envs/language_models_env/lib/python3.10/site-packages/mlx/lib/libmlx.dylib
  Expected in:     <70C4EEC6-ACCF-3E75-804C-659DD8DA930F> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate

It is looking for Accelerate library at a wrong location.

Output of the command :

ls -al /System/Library/Frameworks/Accelerate.framework/Versions/A/

is below

total 0
drwxr-xr-x  5 root  wheel  160 Dec 15 20:13 ./
drwxr-xr-x  4 root  wheel  128 Dec 15 20:13 ../
drwxr-xr-x  4 root  wheel  128 Dec 15 20:13 Frameworks/
drwxr-xr-x  7 root  wheel  224 Dec 15 20:13 Resources/
drwxr-xr-x  3 root  wheel   96 Dec 15 20:13 _CodeSignature/

While output of command :

ls -al /System/Library/Frameworks/Accelerate.framework/

is as below :

total 0
drwxr-xr-x    6 root  wheel   192 Dec 15 20:13 ./
drwxr-xr-x  255 root  wheel  8160 Dec 15 20:13 ../
lrwxr-xr-x    1 root  wheel    27 Dec 15 20:13 Accelerate@ -> Versions/Current/Accelerate
lrwxr-xr-x    1 root  wheel    27 Dec 15 20:13 Frameworks@ -> Versions/Current/Frameworks
lrwxr-xr-x    1 root  wheel    26 Dec 15 20:13 Resources@ -> Versions/Current/Resources
drwxr-xr-x    4 root  wheel   128 Dec 15 20:13 Versions/

I found something relevant :

https://stackoverflow.com/a/70550565/3238085

The reason is explained here: https://developer.apple.com/forums/thread/655588 Since Big Sur, it somehow all became virtual. I still don’t understand how it works though, but it works…

That release note says: As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache

I don’t care how Apple internally handles these things. But as it stands currently it is not working for me.
Any debugging steps that will help resolve this for me are welcome.

Leave a Comment