Describe the bug
After building from source on an M1 Pro Macbook Pro, with parameters --cpu_only --blas=openblas, importing MinkowskiEngine fails with the error mentioned above.
To Reproduce
Steps to reproduce the behavior. If the code is not attached and cannot be reproduced easily, the bug report will be closed without any comments.
Expected behavior
For MinkowskiEngine to get imported properly.
Desktop (please complete the following information):
OS: MacOS Ventura
Python version: Python 3.8.13
Pytorch version: 1.13.0
CUDA version: NONE
NVIDIA Driver version: NONE
Minkowski Engine version 0.5.4
Output of the following command. (If you installed the latest MinkowskiEngine, paste the output of python -c "import MinkowskiEngine as ME; ME.print_diagnostics()".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/kghandour/MinkowskiEngine/MinkowskiEngine/__init__.py", line 53, in <module>
from MinkowskiEngineBackend._C import (
ImportError: dlopen(/opt/anaconda3/envs/perfception/lib/python3.8/site-packages/MinkowskiEngine-0.5.4-py3.8-macosx-11.1-arm64.egg/MinkowskiEngineBackend/_C.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '___kmpc_for_static_fini'
Additional context
From my research I have found that the issue involves libomp not being linked properly, so I have done the following:
I am using LLVM installed from brew, exported CC to LLVM clang,
I am using openblas installed from brew
I am using libomp installed from brew
I am using gcc installed from brew
additionally have these set in my ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/openblas/lib -L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include -I/opt/homebrew/opt/openblas/include -I/opt/homebrew/opt/libomp/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig"
export BLAS=/opt/homebrew/opt/openblas/lib/libopenblasp-r0.3.21.dylib
alias clang='/opt/homebrew/opt/llvm/bin/clang'
alias gcc='/opt/homebrew/Cellar/gcc/12.2.0/bin/gcc-12'
alias g++='/opt/homebrew/Cellar/gcc/12.2.0/bin/g++-12'
export DYLD_LIBRARY_PATH="/opt/homebrew/opt/libomp/lib:$DYLD_LIBRARY_PATH"
export CC="/opt/homebrew/opt/llvm/bin/clang"
I have tried to modify the setup.py script even with the following changes:
Installed /opt/anaconda3/envs/perfception/lib/python3.8/site-packages/MinkowskiEngine-0.5.4-py3.8-macosx-11.1-arm64.egg
.
.
.
Finished processing dependencies for MinkowskiEngine==0.5.4
Please note that I am trying different things, and once I zone in on the issue, I can clean up.
I have also found https://github.com/NVIDIA/MinkowskiEngine/pull/438, that talks about a similar issue with building on darwin, however, from my research I cannot use mkl on an M1 Mac so I am using openblas.
Describe the bug After building from source on an M1 Pro Macbook Pro, with parameters
--cpu_only --blas=openblas
, importing MinkowskiEngine fails with the error mentioned above.To Reproduce Steps to reproduce the behavior. If the code is not attached and cannot be reproduced easily, the bug report will be closed without any comments.
Expected behavior For MinkowskiEngine to get imported properly.
Desktop (please complete the following information):
python -c "import MinkowskiEngine as ME; ME.print_diagnostics()"
.Additional context From my research I have found that the issue involves libomp not being linked properly, so I have done the following:
additionally have these set in my ~/.zshrc
Build successful, but the import fails.
Please note that I am trying different things, and once I zone in on the issue, I can clean up. I have also found https://github.com/NVIDIA/MinkowskiEngine/pull/438, that talks about a similar issue with building on darwin, however, from my research I cannot use mkl on an M1 Mac so I am using openblas.
Thank you for any help you can provide.