Huelse / SEAL-Python

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

ImportError in SEALPython #67

Closed tusharcsebd closed 2 years ago

tusharcsebd commented 3 years ago

After Installation of SEAL-Python library in Ubuntu in Windows10, I tried to run the file as follows: python3 seal_helper.py

But I got the following error: Traceback (most recent call last): File "seal_helper.py", line 1, in from seal import scheme_type ImportError: /home/tushar/SEAL-Python/examples/seal.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN4seal9Evaluator11add_inplaceERNS10CiphertextERKS1

I was working for the last 5 hours to install all the things and stuck here. Can you please help me @DreamingRaven or @Huelse ?

Huelse commented 3 years ago

What's your version of your compiler? like gcc, python, and so on.

tusharcsebd commented 3 years ago

What's your version of your compiler? like gcc, python, and so on. Many thanks for your reply @Huelse . Here is the required information.

  • gcc (Ubuntu 9.3.0-17 ubuntu1~20.04) 9.3.0
  • Python 3.8.10
  • clang version 10.0.0-4 ubuntu1
  • g++ (Ubuntu 9.3.0-17 ubuntu1~20.04) 9.3.0
  • cmake version 3.16.3
Huelse commented 3 years ago

try to rebuild SEAL lib with -DBUILD_SHARED_LIBS=ON

and change the file name in setup.py line 14, may be like this './SEAL/build/lib/libseal.so'

tusharcsebd commented 3 years ago

try to rebuild SEAL lib with -DBUILD_SHARED_LIBS=ON

and change the file name in setup.py line 14, may be like this './SEAL/build/lib/libseal.so' After following the above instructions, I tried to rebuild using python3 setup.py build_ext -i

I have followed your instruction. But I have got the following error. Can not find the seal lib, Compile the seal lib first or check the path. Then I checked my /SEAL/build/lib/ directory and got the files libseal-3.6.a libseal-3.7.a, That means libseal.so not exist in the above directory and python3 setup.py build_ext -i not working. How can I get libseal.so file? @Huelse

If I change the library name using the above filename such as './SEAL/build/lib/libseal-3.7.a' then python3 setup.py build_ext -i working and showing the message. running build_ext copying build/lib.linux-x86_64-3.8/seal.cpython-38-x86_64-linux-gnu.so -> After this when I tried again to run the seal_helper.py and got the same error.

Huelse commented 3 years ago

build the SEAL lib like this:

cd SEAL
cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build
tusharcsebd commented 3 years ago

cmake -S . -B build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF -DBUILD_SHARED_LIBS=ON

Thanks. Now setup does not show any error. Thanks. But python3 seal_helper.py command is showing the following error again.

Traceback (most recent call last): File "seal_helper.py", line 1, in from seal import scheme_type ImportError: /home/tushar/SEAL-Python/seal.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN4seal9Evaluator11add_inplaceERNS10CiphertextERKS1

If you don't mind, what is the actual problem @Huelse? I am unable to trace.

Huelse commented 3 years ago

There are many possibilities, basically, we can consider this may be caused by the compiler or system environment, as you can see, ZN4seal9Evaluator11add_inplaceERNS_10CiphertextERKS1 is refer to src/wrapper.cpp - Evaluator.add_inplace.... the python interpreter cant' recognize it, a little like encoding problem.

Are you using WSL? we haven't tested it in WSL environment, What about a virtual machine like in VMware?

tusharcsebd commented 3 years ago

Are you using WSL? we haven't tested it in WSL environment, What about a virtual machine like in VMware?

Thanks for your observations. Yes, I am using WSL. That is, I have installed Ubuntu from the Microsoft store after turning on WSL from Turn windows features on or off. Earlier, I have also tried to install this within Cygwin but failed. What is environment are you actually using? @Huelse I want to use that environment to avoid errors. Can you pelase specify elaborately?

Huelse commented 3 years ago

We have tested it on Windows 10 with the Visual Studio 2019, macOS 11.6, Ubuntu 20.04/18.04 in VMware, and so on.

tusharcsebd commented 3 years ago

We have tested it on Windows 10 with the Visual Studio 2019, macOS 11.6, Ubuntu 20.04/18.04 in VMware, and so on.

Many thanks for your information. Finally, I have installed using Ubuntu 20.04 in VMware. Now I was trying to execute the examples python3 matrix_operations.py

and got the following error.

n: 4 ------------------Matrix Transpose:------------------ / | Encryption parameters | scheme: ckks | poly_modulus_degree: 8192 | coeff_modulus size: 200(60 + 40 + 40 + 60) bits \ Number of slots: 4096 stack smashing detected : terminated Aborted (core dumped)

Why does the error happen, @Huelse? Can you suggest a simple tutorial or example in SEAL-Python?

Huelse commented 3 years ago

Sorry for replying late, I will test it later.

Huelse commented 3 years ago

I have tested the example in ubuntu20.04 just now, it's working fine in my environment. what about you? or there are some tests in version 3.3.2, which you can find here, and ​don't forget to build the lib in this version.

tusharcsebd commented 3 years ago

I have tested the example in ubuntu20.04 just now, it's working fine in my environment. what about you? or there are some tests in version 3.3.2, which you can find here, and ​don't forget to build the lib in this version.

Many thanks for sharing the new version. Should I install this version and replace the earlier installation with this one? Can you please tell me how to build the new version exactly? @Huelse

Huelse commented 3 years ago

download from release and refer to here