Hi,
I am struggling to setup openfhe-python (in both the system-wide install option, as well as the docker option). I’ve tried it for a while already, but I can’t seem to get it work, therefore I would be very grateful for some pointers! (I hope this is the right place to ask!)
1. System-wide installation (which I would prefer)
I am on MacOS Ventura with an ARM chip. The README states only instructions for a Linux System-wide installation, but I didn’t see anything obvious (to me) Linux specific in the installation and read somewhere that there are some active MacOS users of openfhe-python, so I decided to just give it a try. (Maybe that was the mistake already?)
- I successfully installed openfhe-dev (via their instructions, test run through) and pybind11 via home-brew.
- I followed the system-wide installation steps here: GitHub - openfheorg/openfhe-python: Official Python wrapper for OpenFHE. Current release is v0.8.8 (released on June 25, 2024).
- Running
cmake ..
works when I set both-DOpenFHE_DIR
and-DPYTHON_EXECUTABLE
- Running
make
fails with the error and stack trace in the screenshot
In file included from /Users/tam/Documents/02_Master/08_masterarbeit/01_Code/openfhe-python/src/lib/bindings.cpp:1:
In file included from /opt/homebrew/include/pybind11/pybind11.h:13:
In file included from /opt/homebrew/include/pybind11/detail/class.h:12:
In file included from /opt/homebrew/include/pybind11/attr.h:13:
In file included from /opt/homebrew/include/pybind11/detail/common.h:317:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/forward_list:198:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__memory/unique_ptr.h:65:5: error: delete called on non-final 'lbcrypto::CCParams<CryptoContextCKKSRNS>' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-abstract-non-virtual-dtor]
delete __ptr;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__memory/unique_ptr.h:297:7: note: in instantiation of member function 'std::default_delete<lbcrypto::CCParams<CryptoContextCKKSRNS>>::operator()' requested here
__ptr_.second()(__tmp);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__memory/unique_ptr.h:263:75: note: in instantiation of member function 'std::unique_ptr<lbcrypto::CCParams<CryptoContextCKKSRNS>>::reset' requested here
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
^
/opt/homebrew/include/pybind11/pybind11.h:1974:40: note: in instantiation of member function 'std::unique_ptr<lbcrypto::CCParams<CryptoContextCKKSRNS>>::~unique_ptr' requested here
v_h.holder<holder_type>().~holder_type();
^
/opt/homebrew/include/pybind11/pybind11.h:1634:26: note: in instantiation of member function 'pybind11::class_<lbcrypto::CCParams<CryptoContextCKKSRNS>>::dealloc' requested here
record.dealloc = dealloc;
^
/Users/tam/Documents/02_Master/08_masterarbeit/01_Code/openfhe-python/src/lib/bindings.cpp:28:5: note: in instantiation of function template specialization 'pybind11::class_<lbcrypto::CCParams<CryptoContextCKKSRNS>>::class_<>' requested here
py::class_<CCParams<T>>(m, name.c_str())
^
/Users/tam/Documents/02_Master/08_masterarbeit/01_Code/openfhe-python/src/lib/bindings.cpp:1191:5: note: in instantiation of function template specialization 'bind_parameters<lbcrypto::CryptoContextCKKSRNS>' requested here
bind_parameters<CryptoContextCKKSRNS>(m,"CCParamsCKKSRNS");
^
3 errors generated.
make[2]: *** [CMakeFiles/openfhe.dir/src/lib/bindings.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/openfhe.dir/all] Error 2
make: *** [all] Error 2
- this appears like it might be a compiler issue, I am using Clang provided by Xcode tools as specified in the openfhe-dev build instructions
clang -v
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Any ideas what might go wrong here?
2. Docker installation
Building the docker image works well, however I cannot import the openfhe
library neither in the Jupyter lab notebook provided/started in the docker container nor at other locations in the docker container.
The import fails with “No module named openfhe”
The import works well when testing it in the openfhe-python/build directory in the container and I can successfully run example files in the build directory. (But only there)
So I assume that something went wrong with the system-wide installation?
Make install returns success and the following location for the .so files:
root@bd567e42dd78:/openfhe-python/build# make install
[100%] Built target openfhe
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/openfhe.cpython-310-aarch64-linux-gnu.so
Regarding env variables I set both:
LD_LIBRARY_PATH=/usr/local/lib:
and
PYTHONPATH=/usr/openfhe.cpython-310-aarch64-linux-gnu.so:
3. Installation with pip:
I also tried installing openfhe via pip3 install openfhe
because I saw that there was a package (even though it wasn’t mentioned in the GitHub Repo, but I figured - why not).
The install succeeds, but trying to import openfhe fails with:
root@bd567e42dd78:~# python3
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import openfhe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/openfhe/__init__.py", line 1, in <module>
from .openfhe import *
ImportError: /usr/local/lib/python3.10/dist-packages/openfhe/openfhe.so: cannot open shared object file: No such file or directory
I am a bit stumped at this point and would really appreciate some help! I am pretty hyped to start programming with openfhe and am looking forward to be able to start once the setup issues are sorted out!
Thank you in advance!