lxxue / FRNN

Fixed Radius Nearest Neighbor Search on GPU
180 stars 24 forks source link

Import _C error #9

Closed ShaoxiongYao closed 1 year ago

ShaoxiongYao commented 2 years ago

First, thank you for providing this library!

Python 3.8.12, CUDA 11.4, torch version 1.9.0, Ubuntu 22.04.

Installed using python setup.py install, when run import frnn in python,

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/motion/FRNN/frnn/__init__.py", line 2, in <module> from .frnn import frnn_grid_points, frnn_gather, frnn_bf_points#, _C File "/home/motion/FRNN/frnn/frnn.py", line 7, in <module> from frnn import _C ImportError: cannot import name '_C' from partially initialized module 'frnn' (most likely due to a circular import) (/home/motion/FRNN/frnn/__init__.py)

The problem can be fixed using python setup.py develop.

lxxue commented 2 years ago

Thanks for the issue. Unfortunately, I cannot reproduce it on my ubuntu 20.04 with python 3.8.13. It is also weird that develop mode can fix it.

Anyway, since direct invocations of setup.py are deprecated I will change them to pip install ..

prclibo commented 2 years ago

Met simliar issue and solved by exiting and re-entering the bash.

pserg1 commented 1 year ago

Have a similar problem when importing module.

ImportError: cannot import name '_C' from partially initialized module 'frnn' (most likely due to a circular import) (/content/FRNN/frnn/frnn.py)

Tried using in google colab with Python 3.9.16, CUDA 11.8, Ubuntu 20.04.

Plz advise how to solve

lxxue commented 1 year ago

I cannot reproduce this with python 3.9.16 / PyTorch 2.0 / CUDA 11.8 / Ubuntu 20.04 locally on my machine. How did you install the library? Maybe you can try to install it with pip install -e . and check again?

pserg1 commented 1 year ago

It helped, thank you! Had to restart runtime afterwards

RuihanGao commented 11 months ago

Same issue for me, with cuda 11.7, python 3.8.16, pytorch '2.0.1+cu117' on Ubuntu 20.04. I tried pip install -e . and python setup.py develop as suggested above, but unfortunately the problem is not solved. Any help/suggestion is appreciated.

  File "/data/ruihan/projects/NeRF-Texture/tools/map.py", line 3, in <module>
    import frnn
  File "/data/ruihan/projects/NeRF-Texture/thirdparty/FRNN/frnn/__init__.py", line 2, in <module>
    from .frnn import frnn_grid_points, frnn_gather, frnn_bf_points, _C
  File "/data/ruihan/projects/NeRF-Texture/thirdparty/FRNN/frnn/frnn.py", line 7, in <module>
    from frnn import _C
lxxue commented 11 months ago

Did you restart the bash after installation? This seems to help for some people.

RuihanGao commented 11 months ago

Did you restart the bash after installation? This seems to help for some people.

Yes, I do. I also rebooted the machine, just in case. Unfortunately, the problem persists.

lxxue commented 11 months ago

I did a quick search and this might related to the circular import caused by the same name of the package and the python file. I will do a PR this weekend and see if renaming the files can fix it.