Symbol not found: _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.
Did you install with pip?
@awni : Yes with pip.
I will try installing on 14.2.1 to see if I can reproduce this..
I am on M3 Max if it is of any help. I submitted the same issue here. https://github.com/ggerganov/llama.cpp/issues/4440 I updated to 14.2.1 this morning hoping it would resolve the issue linked here.
What's the output of:
xcrun -sdk macosx --show-sdk-version
PS I'm looking at this issue which seems related: https://github.com/numpy/numpy/issues/25026
command : xcrun -sdk macosx --show-sdk-version
output : 14.2
Edit : more info
command : sw_vers -productVersion output : 14.2.1
A bit of a shot in the dark:
- Maybe try reinstalling mlx:
pip install --U mlx - Try this: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
If neither of those helps we'll need to investigate further...
Tried both of these steps. Still getting the same error.
I encountered a similar problem. My Apple system version is 13.3 and the chip is M1 max.
@kkxwz try upgrading your OS (MLX support >=13.5 )
I had a similar issue, after uninstalling mlx and updating to the latest version (0.3) it was fixed.