Huelse / SEAL-Python

Microsoft SEAL 4.X For Python
MIT License
312 stars 66 forks source link

undefined symbol: deflateInit_ #14

Closed DreamingRaven closed 4 years ago

DreamingRaven commented 4 years ago

Hey Huelse, Sorry to take more of your time. I have found on a more up to date system (archlinux rather than ubuntu) through the recent update to 3.4.5:

archer@azuran ~ (master)> sudo pacman -Q cmake gcc clang python
cmake 3.17.0-1
gcc 9.3.0-1
clang 9.0.1-1
python 3.8.2-1

That while compilation is successfull attempting to use the seal package by calling any one of the examples results in:

archer@azuran ~ (3.4.5)> sudo docker run --gpus all -it archer/py-seal-arch python3 /seal-python/tests/4_ckks_basics.py
Traceback (most recent call last):
  File "/seal-python/tests/4_ckks_basics.py", line 2, in <module>
    from seal import *
ImportError: /usr/lib/python3.8/site-packages/seal.cpython-38-x86_64-linux-gnu.so: undefined symbol: deflateInit_

reproduce

I have a branch prepared with the issue with all of your latest commits and my dockerfiles to make reproducing easy:

https://github.com/DreamingRaven/SEAL-Python/tree/3.4.5

Build the archlinux docker, and seal-python with up-to-date packages:

sudo docker build -t archer/py-seal-arch . -f Dockerfile_archlinux

Run the archlinux docker to encounter the error:

sudo docker run -it archer/py-seal-arch python3 /seal-python/tests/4_ckks_basics.py

This does not occur and works if using older packages and build system from ubuntu:

sudo docker build -t archer/py-seal-ubuntu . -f Dockerfile
sudo docker run -it archer/py-seal-ubuntu python3 /seal-python/tests/4_ckks_basics.py

Notes

This worked on both ubuntu and archlinux prior to updating to seal v3.4.5 (as can be verified in https://github.com/DreamingRaven/SEAL-Python/tree/dev). Im wondering if you have any input into what could be causing this recent undefined symbol?

Huelse commented 4 years ago

em, have you tried in python3.7? I got it, it's a problem

DreamingRaven commented 4 years ago

I will try it with python3.7 although I expect the result to be the same as this used to work with python3.8 before the ms-seal update to 3.4.5. I expect this may be an issue with ms-seal itself or some quirk we aren't aware of as im not too familiar with binding c++ to python so learning as I go.

DreamingRaven commented 4 years ago

em, have you tried in python3.7? I got it, it's a problem

How did you reproduce it? was it on an ubuntu system with more up to date packages or inside an arch docker container as above?

Huelse commented 4 years ago

you can try to build with the cmake, so there is a ImportError, etc I remain the CMakeLists.txt in the src folder, change the path before use it. I'm dealing with it now if you have any idea, please tell me.

DreamingRaven commented 4 years ago

I will try this in a moment, once I have had lunch. I have no cause in mind as yet, but I will look into it too.

Huelse commented 4 years ago

OK, Here is a solution. Before you compile the SEAL lib, change the SEAL/native/src/CMakeLists.txt line 101 Static_PIC to Shared. then you will get the SEAL/native/lib/libseal.so then change the lib path in setup.py or src/CMakeLists.txt. But do attention, the path is sensitive now.

DreamingRaven commented 4 years ago

ok will try it now and let you know if it works on my end too.

DreamingRaven commented 4 years ago

Hmm not sure I have done this right as im getting

ImportError: libseal.so.3.4: cannot open shared object file: No such file or directory

So I must not have installed it properly.

To confirm the changes I need to make are: change this to Shared from Static_PIC which Is very specific i'm sure I haven't messed that up: https://github.com/Huelse/SEAL-Python/blob/d8395a54d15a94ee25f6e33d78250aa5cf1a3c0b/SEAL/native/src/CMakeLists.txt#L101 becomes: https://github.com/DreamingRaven/SEAL-Python/blob/3eb9654540bdf887376167c22ca8f92da52f7477/SEAL/native/src/CMakeLists.txt#L101

but then for the next one so that it finds seal from https://github.com/Huelse/SEAL-Python/blob/d8395a54d15a94ee25f6e33d78250aa5cf1a3c0b/setup.py#L15 to https://github.com/DreamingRaven/SEAL-Python/blob/3eb9654540bdf887376167c22ca8f92da52f7477/setup.py#L15 but after building everything this now does not find seal, instead giving me:

archer@azuran ~/g/seal-python (3.4.5)> sudo docker run --gpus all -it archer/py-seal-arch bash
[root@09e1c8d7edd2 /]# python
Python 3.8.2 (default, Feb 26 2020, 22:21:03) 
[GCC 9.2.1 20200130] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import seal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libseal.so.3.4: cannot open shared object file: No such file or directory
DreamingRaven commented 4 years ago

Hmm thats interesting if I run the exact same source in the ubuntu docker it works fine again ... Hmm not sure what is going on with the differences here but I will look into it. It just seems so bizarre to be acting so differently given the exact same installation steps.

If I find out what is causing this problem between ubuntu and arch I will let you know. Thanks for all your work thus far.

Huelse commented 4 years ago

add /usr/local/lib or the SEAL/native/lib to /etc/ld.so.conf and refresh it sudo ldconfig it's your interpreter does not find the dynamic link library caused.

DreamingRaven commented 4 years ago

add /usr/local/lib or the SEAL/native/lib to /etc/ld.so.conf and refresh it sudo ldconfig it's your interpreter does not find the dynamic link library caused.

Ok trying that now

DreamingRaven commented 4 years ago

Yep that worked, ah yes of course! Archlinux puts its shared objects in /usr/lib wheras other distros store theirs in /usr/local/lib And I have confirmed the tests work fine. and you solved the undefined symbol error in the process. Thanks @Huelse