dvlab-research/PointGroup

Cannot import PG_OP

fuy34 opened this issue · 1 comments

fuy34 commented

Hi,

Thank you for sharing the code.
I followed the instruction to setup the environment and successfully compile the files. However, I met the following error, when I try to import PG_OP.

 import PG_OP
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home//PointGroup/lib/pointgroup_ops/PG_OP.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail36_typeMetaDataInstance_preallocated_7E

I am using CUDA 10.2, PyTorch 1.1.0 and python3.7.
Thank you in advance.

fuy34 commented

OK, after struggling for more than 10 hours, I finally figured out the way to set up the environment. For anyone who may get stuck in the future,

Test Environment:  CUDA 10.2 + PyTorch 1.5.0 (conda installed)+ python 3.7 
1. conda create -n pnt_group python=3.7
2. conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.2 -c pytorch
3. pip install all the pkgs in the requrement.txt except for torch 
4. conda install all the dependencies on the instruction until spconv compiling 

I recommend to compile pointgroup_ops first, as it is likely to fail in the first trial due to the extremely less reference. Issue #4 is very helpful.

5. export INCLUDE_PATH=/path/to/conda/envs/pnt_group/include:$INCLUDE_PATH
6. python setup.py build_ext --include-dirs=$INCLUDE_PATH$
7. python setup.py develop

Now test the installation

python 
>> import PG_OP

In my case, I first got a error saying ImportError: libcudart.so.10. This is due to the missing of cudatoolkit. It should not happen if we follow step 2. Then, I got another error saying

ImportError: libc10.so: cannot open shared object file: No such file or directory

I still do not know why it happens, but we can temporally fix it by

export LD_LIBRARY_PATH=/path/to/conda/envs/envs/pnt_group2/lib/python3.7/site-packages/torch/lib/:LD_LIBRARY_PATH

I did not source it just in case it will mess up with other environments.

Next, we need to install spconv 1.2 for Pytorch 1.5. The one contained in this repo. is not compatible!

8. git clone https://github.com/traveller59/spconv.git --recursive 
9. edit the spconv/functional.py as Li did in this commit https://github.com/llijiang/spconv/commit/740a5b717fc576b222abc169ae6047ff1e95363f 
10. remove the '-Wall' line in /path/to/conda/envs/pnt_group2/lib/python3.7/site-packages/torch/share/cmake/Caffe2/Caffe2Targets.cmake
11. python setup.py bdist_wheel

This step will throw out tons of warnings, but it seems fine to ignore them.

12. cd ~/spconv/dist/
13. pip install *.whl (that we just generated in step 11)

The code works fine for me after all of these installation.