loicland / cut-pursuit

C++ implementation for the cut pursuit algorithm, with Matlab interfaces
MIT License
76 stars 24 forks source link

python interface doesn't work #15

Open cslxiao opened 5 years ago

cslxiao commented 5 years ago

I build python interface and generate libcp.so following the guide, but it cannot be imported in python:

import libcp malloc(): memory corruption Aborted (core dumped)

version information: python: 3.6 boost: 1.65 os: ubuntu 18.04 g++: 6.4

loicland commented 5 years ago

Hi,

can you try to run the troubleshooting section in the README of this repo?

cslxiao commented 5 years ago

I didn't use conda to install boost and eigen. Instead, I use the library in the system path and cmake find them well.

cmake . -- The C compiler identification is GNU 6.4.0 -- The CXX compiler identification is GNU 6.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Boost version: 1.65.1 -- Found the following Boost libraries: -- graph -- numpy -- python -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.6m.so (found version "3.6.6") PYTHON LIBRARIES ARE /usr/lib/x86_64-linux-gnu/libpython3.6m.so -- Configuring done -- Generating done -- Build files have been written to: /home/XXX/superpoint_graph/partition/cut-pursuit/src

XBingQian commented 5 years ago

Hello, I have met a same problem. The cmake and make progress works well with log as follows: ------------ply_c------------- -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Boost version: 1.67.0 -- Found the following Boost libraries: -- python -- numpy Boost includes ARE /usr/local/include Boost LIBRARIES ARE /usr/lib -- Found PythonLibs: /home/xbq/anaconda2/envs/py3/lib/libpython3.6m.so (found version "3.6.6") PYTHON LIBRARIES ARE /home/xbq/anaconda2/envs/py3/lib/libpython3.6m.so -- Configuring done -- Generating done -- Build files have been written to: /home/xbq/git/superpoint_graph/partition/ply_c -------------cut-pursuit-------------- -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Boost version: 1.67.0 -- Found the following Boost libraries: -- graph -- numpy -- Found PythonLibs: /home/xbq/anaconda2/envs/py3/lib/libpython3.6m.so (found version "3.6.6") PYTHON LIBRARIES ARE /home/xbq/anaconda2/envs/py3/lib/libpython3.6m.so -- Configuring done -- Generating done -- Build files have been written to: /home/xbq/git/superpoint_graph/partition/cut-pursuit/src

The libply_c.so and libcp.so files were successfully generated. But, when I try to run the partition module in superpoint_graph with partition.py, there are errors in"import libcp"(1) and "import libply_c"(2). And the out message are seperately: (1) ImportError: ./partition/cut-pursuit/src/libcp.so: undefined symbol: _ZTIN5boost6python7objects21py_function_impl_baseE (2) ImportError: /usr/lib/libboost_python.so.1.66.0: undefined symbol: PyClass_Type There are anaconda2 and anaconda3 in my PC environment. And I have change it to python3.6 while compile the module. Could you help to find where the problem is? Thanks.

loicland commented 5 years ago

Hi,

There are many issues on this subject on the superpoint graph repo. Check out thr followings to see if that helps you: https://github.com/loicland/superpoint_graph/issues/59

https://github.com/loicland/superpoint_graph/issues/56

https://github.com/loicland/superpoint_graph/issues/13

Let me know if you're still stuck after that.

Also im noticing in your build files that you have a mix of anaconda2 and pupython3.6. What value did you give to $CONDAENV?

cslxiao commented 5 years ago

still not work

loicland commented 5 years ago

What value did you give to $CONDAENV?

Are you sure you have libboost_python.so in your LD_LIBRARY_PATH?

Not-IITian commented 5 years ago

Hi Loic,

Could you perhaps post the desired output of test.py file after libcp is built? I was able to compile libcp fine and get this output after running test.py:

L0-CUT PURSUIT WITH L2 FIDELITY PARAMETERIZATION = FAST Graph 5 vertices and 14 edges and observation of dimension 1 Iteration 1 - 3 components - Saturation 0.0 % - Quadratic Energy 0.000 % - Timer 0.204649 Iteration 2 - 3 components - Saturation 100.0 % - Quadratic Energy 0.000 % - Timer 0.204701 All components are saturated

Not-IITian commented 5 years ago

My bad: these results I obtain after with python 2.7 which is not suggested anyways.

zeroAska commented 5 years ago

@XBingQian Have you figured out? I ran into exactly the same error as you, libcp.so: undefined symbol: _ZTIN5boost6python7objects21py_function_impl_baseE