PointNeXt icon indicating copy to clipboard operation
PointNeXt copied to clipboard

Enable OpenPoints to be installed as a package

Open clee-ai opened this issue 3 years ago • 4 comments

Hi,

I want to use OpenPoints as a library within my project. It would be nice if OpenPoints was able to be installed in its entirety as a package. This would entail:

  • Defining all non-cuda requirements in setup.py or setup.cfg
  • Installing all c++ extension modules from setup.py
  • Adding OpenPoints to pip (and in the future, Anaconda) to be installed by downstream libraries

Let me know your thoughts, thanks!

clee-ai avatar Nov 10 '22 22:11 clee-ai

Thanks for this suggestion. But I have no experience in this. Could you kindly direct me to an example?

guochengqian avatar Nov 12 '22 03:11 guochengqian

Hi!

I recommend taking a look at the following libraries for examples on setting up setup.py:

https://github.com/torch-points3d/torch-points-kernels/blob/master/setup.py https://github.com/mit-han-lab/torchsparse/blob/master/setup.py

Let me know if you have any questions, I am happy to help. I am one of the core contributors on torch-points3d and I'm looking to use OpenPoints as a basis for the next version of the framework. Feel free to reach out!

clee-ai avatar Nov 16 '22 21:11 clee-ai

I would maybe recommend following the format of torch-points-kernels, where the cuda c++ code is in a "cuda" folder and then you can setup all of the extensions under the global setup.py, like so:

# /setup.py
setup(
    name='openpoints',
    ext_modules=[
        CUDAExtension('openpoints.pointnet2_cuda', [
			'cuda/pointnet2/pointnet2_api.cpp',
			'cuda/pointnet2/ball_query.cpp',
			'cuda/pointnet2/ball_query_gpu.cu',
			'cuda/pointnet2/group_points.cpp',
			'cuda/pointnet2/group_points_gpu.cu',
			'cuda/pointnet2/interpolate.cpp',
			'cuda/pointnet2/interpolate_gpu.cu',
			'cuda/pointnet2/sampling.cpp',
			'cuda/pointnet2/sampling_gpu.cu',
		],
		CUDAExtension('openpoints.chamfer_cuda', [
              'cuda/chamfer/chamfer_cuda.cpp',
              'cuda/chamfer/chamfer.cu',
          ])
    ],
    cmdclass={'build_ext': BuildExtension}
)

And then, the convention is to have all of the python code under a folder same as the name of the package.

Project folder Structure:

+ cuda
+ openpoints
	+ dataset
	+ loss
	+ models
	+ optim
	+ scheduler
	+ transforms
	+ utils
- setup.py
- README.md

This way, the code can be imported into a downstream dependency after being installed by doing something like:

import openpoints.dataset

clee-ai avatar Nov 16 '22 22:11 clee-ai

@CCInc hi thanks for the input. I will do that in spare time.

guochengqian avatar Nov 22 '22 22:11 guochengqian