openfheorg / openfhe-python

Official Python wrapper for OpenFHE. Current release is v0.8.9 (released on September 10, 2024).
https://openfheorg.github.io/openfhe-python/html/index.html
BSD 2-Clause "Simplified" License
73 stars 21 forks source link

Install issue on Linux Ubuntu #71

Closed IanQS closed 11 months ago

IanQS commented 11 months ago

Hi all! These are the exact commands I'm running:

Installation

Installing Openfhe-dev

git clone git@github.com:openfheorg/openfhe-development.git
cd openfhe-development
mkdir build
cd build
make -j N  # number of processors - 26 in my case
sudo make install

I then verify that it is installed by running

cd bin/examples/pke
./simple-real-numbers

Installing OpenFHE-python (within a conda env)

git clone git@github.com:openfheorg/openfhe-python.git
cd openfhe-python
mkdir build
cd build
cmake .. -DPYTHON_EXECUTABLE_PATH=$CONDA_PREFIX/bin/python
make -j 26
sudo make install

then, within build, I run

mkdir lib
mv *.so lib
conda develop lib

I have verified that Openfhe-python's SO files have been "linked"

import sys
for p in sys.path:
    print(p)

which outputs

/home/iq/anaconda3/lib/python311.zip
/home/iq/anaconda3/lib/python3.11
/home/iq/anaconda3/lib/python3.11/lib-dynload
/home/iq/anaconda3/lib/python3.11/site-packages
/home/iq/openfhe-python/build/lib

The issue

When I run something like python function-evaluation.py I see

File "/home/iq/openfhe-python/examples/pke/function-evaluation.py", line 1, in <module>
    from openfhe import *
ImportError: libOPENFHEpke.so.1: cannot open shared object file: No such file or directory

It's not clear to me what the issue is and if it is an issue on the OpenFHE-dev end. I don't think it is, just because I managed to run an example specifically a PKE example


Additional Information

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
reneroliveira commented 11 months ago

Have you tried to check the command which python to see if it matches with the anaconda python paths?

IanQS commented 11 months ago

Yeap! Verified

yspolyakov commented 11 months ago

PYTHONPATH should include the path to OpenFHE .so files for Python to work. In other words, @IanQS, you need to add

export PYTHONPATH = (path_to_OpenFHE_so_files):$PYTHONPATH

The documentation should be updated to mention both PYTHONPATH and LD_LIBRARY_PATH.

IanQS commented 11 months ago

Amazing! Confirmed that the solution works for the system-level install. I haven't tested the conda approach yet, but I'm confused why conda develop didn't work.... AFAIK it does the same thing(?) Rener, keep me honest here

Also, the original error made me think it was a C++/ OpenFHE installation-path issue, how strange

reneroliveira commented 11 months ago

Actually, I don't understand exactly what conda develop does. That was your suggestion to the documentation. In my machine I never need to run that, everything works fine with sudo make install and specifying the python conda path to cmake

IanQS commented 11 months ago

Ahh, my bad. I'll figure out how to make it work with conda later on and open a new PR to correct this. I'm closing this issue now - if there's any follow ups feel free to reopen