ethnhe / PVN3D

Code for "PVN3D: A Deep Point-wise 3D Keypoints Hough Voting Network for 6DoF Pose Estimation", CVPR 2020
MIT License
493 stars 105 forks source link

Cannot import name '_ext' && Pcl install on 18.04 Buntu #79

Open Theopetitjean opened 3 years ago

Theopetitjean commented 3 years ago

Hello,

First of all, thank you for your work.

In the context of a concrete application for my thesis subject I would like to test your PVN3D code. However, I encounter a problem that I can't correct. Indeed, when using demo_linemod.sh I encounter the following problem :

ImportError: cannot import name '_ext' from 'lib.pointnet2_utils' (/home/tpetitjean/PhD_Thesis/T1Pvn3D/PVN3D/pvn3d/lib/pointnet2_utils/__init__.py)

I'm sure I installed PointNet properly, and built it as indicated. I can see PointNet installed in my Conda env and using the python3 setup.py command build_ext has created a build file inside the PointNet tree.

Do you have any idea what I can do to correct this problem? Is there a file to move by hand after the build? Or is it the build that did not work as expected?

I thank you in advance for your clarification and wish you a very pleasant continuation. Sincerely, Theo

Theopetitjean commented 3 years ago

Ok here is a update of my issue :

after running python3 setup.py build_ext

The code now build apparently well. It create Build File and also the _ext file inside the pointnet2_utils, with a form like : _ext.cpython-36m-x84_64-linux-gnu.so

But still I encounter 2 kind of error such as :

Error 1 : ( with the build exit made with pytorch torch==1.0.1.post2 / torchvision==0.2.0)

It keep returning me mistake such as :

from lib.pointnet2_utils import _ext ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory

Error 2 : (build ext with torch 1.4)

Most of the time fail to import PCL, but when it does it return such kind of mistake :

ImportError: /home/tpetitjean/PhD_Thesis/T1Pvn3D/PVN3D/pvn3d/lib/pointnet2_utils/_ext.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN3c106Device8validateEv

What ever i do to try to fix that i always reach this specific point.

The only warning i got while doing the build is the folowing :

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++

but still it finish by returning message like :

creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/pointnet2_utils

So it seems to work as wanted

Do you guys have any idea how to fix this ? or maybe smtg i am doing wrong ?

aiai84 commented 3 years ago

For error1. It seems that you don't have the libcudart.so.10.0, you can download it. For error2: torch 1.4 is not suitable for this task, you can use torch 1.0.1 as a substitute.

Theopetitjean commented 3 years ago

For error1. It seems that you don't have the libcudart.so.10.0, you can download it. For error2: torch 1.4 is not suitable for this task, you can use torch 1.0.1 as a substitute.

Hello! Tanks for the suggestion, it can lookstrange but, I fixed the both issue in a kinda weird way. So here and update of what I did (it can be useful for someone one day).

For the first err, it appears that to install the PointNet properly I had to first run the installation of it (require.txt) in a suitable version of torch (1.4), then to build the code PVN3D by using back the 1.0.1 torch re-installed by :

pip -r req.txt

Then for error 2 (which is basically the following of the previous steps) it appear that activating the cuda env outside of the file create a sort of localization issue for the file. So I simply Run:

bash

Then cd /path of the PVN3D then conda activate my env and the problem didn't show ever again. Those first to problem come from the fact that I don't run everything on my personal laptop but on a external working server. (I suppose, like I said, I fix it, but it remain kinda obscure to me.).

Then I encountered a brand-new problem linked to PCL. Since I saw online that the problem was evilly reported, here an update of what I've done to fix it. On the server I actually have Unbuntu 18.04 installed. Running the classical command of:

sudo apt-get install libpcl-dev -y
pip install python-pcl

Will probably return a Error such as: /usr/lib/x86_64-linux-gnu/libpcl_keypoints.so.

This issue come from the fact that the command ran before will automatically instal the higher version of libpcl and not the 1.7 wich is an old one.

It turns out that you need to apt install libpcl-dev of version 1.7.x . But the default version of libpcl-dev on Ubuntu 18.04 is (you can run apt-cache policy libpcl-dev to check it out.).

In order to fix that issue you will have to first include inside the source of unbuntu the xenial link for instalation (by default it will be Bionic and we want to add the xenial part.). In my cases I just added those two lines:

deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe

Then we have to run sudo apt update. After that you can run apt-cache madison libpcl-dev to check the available version of libpcl-dev. it should return smtg like :

apt-cache madison libpcl-dev
libpcl-dev | 1.8.1+dfsg1-2ubuntu2.18.04.1 | http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
libpcl-dev | 1.8.1+dfsg1-2ubuntu2 | http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
libpcl-dev | 1.7.2-14build1 | http://dk.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages

If you don't see any 1.7.2 lib available it simply mean that it still misses some xenial source, here is a more complete source list for xenial https://gist.github.com/rohitrawat/60a04e6ebe4a9ec1203eac3a11d4afc1 just add it to your source file and try again.

Then you can run in order to install the 1.7 lib. You will encounter some dependency problems, be patient and fix them on by one. Once the 1.7 lib is installed you will be able to install all the missing part from the 1.7 such as keypoints1.7 or surface1.7.

To do so you just has to check whats part is missing when you try to. If libpcl-keypoints1.7 is missing just run, then try to import pcl again, and install package by package according to the error printed. (here some example) :

sudo apt-get install libpcl-outofcore1.7
apt-get install libpcl-segmentation1.7
apt-get install libpcl-surface1.7

According to this topic : https://ask.csdn.net/questions/1705497 it is possible to face some more issue after these steps. Please refer to this and try the proposed fix.

After all of this you should be able to correctly install PCL on the 18.04 unbuntu and of course using this amaizing PVN3D work !

aiai84 commented 3 years ago

I saw your words and i think the main problem is the installation of the PCL on Ubuntu 18.04. I install it in two computer, ubuntu 16.04 and 20.04, IN 16.04, it is more easier, It seems that through sudo apt-get install libpcl-all can install . For 18.04 and higher, must through the git method
sudo apt install libpcl-dev libvtk6-dev clone fork with fix for Ubuntu 18.04 git clone https://github.com/Tuebel/python-pcl cd python-pcl python3 setup.py install ` pcl 1.7 is not suitable for 18.04, hope this will help you!

liupenglei commented 3 years ago

Hello,

First of all, thank you for your work.

In the context of a concrete application for my thesis subject I would like to test your PVN3D code. However, I encounter a problem that I can't correct. Indeed, when using _demolinemod.sh I encounter the following problem :

ImportError: cannot import name '_ext' from 'lib.pointnet2_utils' (/home/tpetitjean/PhD_Thesis/T1Pvn3D/PVN3D/pvn3d/lib/pointnet2_utils/__init__.py)

I'm sure I installed PointNet properly, and built it as indicated. I can see PointNet installed in my Conda env and using the _python3 setup.py command buildext has created a build file inside the PointNet tree.

Do you have any idea what I can do to correct this problem? Is there a file to move by hand after the build? Or is it the build that did not work as expected?

I thank you in advance for your clarification and wish you a very pleasant continuation. Sincerely, Theo

I have the same problem, did you manage to solve this issue ?

Theopetitjean commented 3 years ago

I have the same problem, did you manage to solve this issue ?

Hi, yes i did, some point are explained here, if you can't fix it with my previous answer, be sure to notify me, and i'll do my possible to make the solution bit more clear in order to help there ;)

liupenglei commented 3 years ago

I have the same problem, did you manage to solve this issue ?

Hi, yes i did, some point are explained here, if you can't fix it with my previous answer, be sure to notify me, and i'll do my possible to make the solution bit more clear in order to help there ;)

I solved this problem in a strange way, I installed the tutorial installation, and then Cannot import name'_ext' appears; the solution: Change from. Import _ext to:

try: from lib.pointnet2_utils import _ext except ImportError: from torch.utils.cpp_extension import load import glob import os.path as osp import os