Thinklab-SJTU / pygmtools

A Python Graph Matching Toolkit.
https://pygmtools.readthedocs.io/
Other
275 stars 19 forks source link

[BUG] : No module named 'pygmtools.c_astar' #92

Closed chowkamlee81 closed 6 months ago

chowkamlee81 commented 6 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Code to reproduce the behavior:

python plot_deep_image_matching_pytorch.ipynb

Expected behavior Successfully run image matching algorithm

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

Additional context Add any other context about the problem here. image

@rogerwwww kindly help

heatingma commented 6 months ago

Hello! I'm glad to answer your question.

We ran the file "plot_deep_image_matching_pytorch.py" in the environment you provided and didn't encounter any bug.

The bug you're experiencing is because the dynamic link library for c_astar cannot be found. Could you check if you can find a file similar to c_astar.cpython-38-x86_64-linux-gnu.so in the directory /data/pygm_env/lib/python3.8/site-packages/pygmtools/?

If you cannot find the file, you can try reinstalling pygmtools. Additionally, we provide the source code for astar, which is located in the c_astar subfolder of pygmtools. You can navigate to that subfolder and use the following command to generate the .so file.

python c_astar_setup.py build_ext --inplace

If you're still unable to resolve the issue, please let us know, and we'll be happy to continue assisting you.

chowkamlee81 commented 6 months ago

@heatingma iam getting now error below ImportError: cannot import name 'c_astar' from 'pygmtools.c_astar' (unknown location) image

ImportError Traceback (most recent call last) Cell In[13], line 3 1 n1 = params[0] 2 n2 = params[1] ----> 3 X = pygm.sm(K, n1, n2)

File /data/pygmtools/pygmtools/classic_solvers.py:370, in sm(K, n1, n2, n1max, n2max, x0, max_iter, backend) 368 if backend is None: 369 backend = pygmtools.BACKEND --> 370 _check_data_type(K, 'K', backend) 371 if _check_shape(K, 2, backend): 372 K = _unsqueeze(K, 0, backend)

File /data/pygmtools/pygmtools/utils.py:1125, in _check_data_type(input, *args) 1123 args = (input, var_name, raise_err) 1124 try: -> 1125 mod = importlib.import_module(f'pygmtools.{backend}_backend') 1126 fn = mod._check_data_type 1127 except (ModuleNotFoundError, AttributeError):

File /usr/lib/python3.8/importlib/init.py:127, in import_module(name, package) 125 break 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level)

File :1014, in _gcd_import(name, package, level)

File :991, in _find_andload(name, import)

File :975, in _find_and_loadunlocked(name, import)

File :671, in _load_unlocked(spec)

File :848, in exec_module(self, module)

File :219, in _call_with_frames_removed(f, *args, **kwds)

File /data/pygmtools/pygmtools/pytorch_backend.py:23 20 from .pytorch_astar_modules import GCNConv, AttentionModule, TensorNetworkModule, GraphPair, \ 21 VERY_LARGE_INT, to_dense_adj, to_dense_batch, default_parameter, check_layer_parameter, node_metric 22 from torch import Tensor ---> 23 from pygmtools.c_astar import c_astar 25 ############################################# 26 # Linear Assignment Problem Solvers # 27 ############################################# 29 from pygmtools.numpy_backend import _hung_kernel

ImportError: cannot import name 'c_astar' from 'pygmtools.c_astar' (unknown location)

chowkamlee81 commented 6 months ago

@heatingma after using your suggested command python c_astar_setup.py build_ext --inplace i reinstalled pygmtools again using python -m pip install -e .. Iam able to solve the issue. Hence closing now