lxxue / frnn Goto Github PK
View Code? Open in Web Editor NEWFixed Radius Nearest Neighbor Search on GPU
Fixed Radius Nearest Neighbor Search on GPU
Hello Ixxue,
Thank you very much for this work! I just have a question about your code.
I noticed that when I use your code in a for loop, the GPU memory allocated keeps increasing until it reaches an OOM error.
Have you noticed this too?
Do you know where this could come from?
Example of code:
dists, idxs, nn, grid = frnn.frnn_grid_points(
points1, points2, lengths1, lengths2, K, r, grid=None, return_nn=False, return_sorted=True
)
for i in range(n):
## Some operations that do not allocate GPU memory
dists, idxs, nn, grid = frnn.frnn_grid_points(
points_i, points2, lengths_i, lengths2, K, r, grid=grid, return_nn=False, return_sorted=True
)
## Some operations that do not allocate GPU memory
Where points_i is a new pointcloud at each iteration
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
.
I got the following error:
FRNN/frnn/csrc/grid/counting_sort.cu:92: void CountingSortNDKernel(const float *, const long *, const int *, const int *, const int *, float *, int *, int, int, int) [with D = 3]: block: [195,0,0], thread: [191,0,0] Assertion `cell_idx < G` failed
The input point cloud is at this link: .https://drive.google.com/file/d/1_Bh3qahg-zSMOG_ATeJhLwiEG8jGK7VF/view?usp=sharing. I use a K = 50 and search radius is 0.1.
gcc/g++ version 6.5.0
nvcc version 10.0
Python 3.6.8
on centos 7.9
trying to build prefix_sum and got the following. Any suggestion is appreciated!
prefix_sum.cu(80): error: a pointer to a bound function may only be used to call the function
prefix_sum.cu(80): error: type name is not allowed
prefix_sum.cu(80): error: expected an expression
prefix_sum.cu(81): error: a pointer to a bound function may only be used to call the function
prefix_sum.cu(81): error: type name is not allowed
prefix_sum.cu(81): error: expected an expression
prefix_sum.cu(95): error: a pointer to a bound function may only be used to call the function
prefix_sum.cu(95): error: type name is not allowed
prefix_sum.cu(95): error: expected an expression
prefix_sum.cu(96): error: a pointer to a bound function may only be used to call the function
prefix_sum.cu(96): error: type name is not allowed
prefix_sum.cu(96): error: expected an expression
Hi,
Thank you for the great work!
Currently I need to find the k nearest neighbor for a point cloud, then I need to downsample the point cloud in a voxel downsample way, can the grid output be use for the downsampling?
hi,
Thanks for providing this awesome toolbox. I encounter OOM error when using it. Here is the minimal example:
data: https://drive.google.com/file/d/1X_8xmTvGwzv8FxXif2VaqtT_oO07_WwT/view?usp=sharing
Code snippet:
import frnn
import torch
if __name__=='__main__':
device = torch.device('cuda')
points = torch.load('dump/pts.pth')[None,:,:].to(device).float()
n_points = torch.tensor([points.size(1)]).to(device).long()
K=10
radius = 0.05
print(points.size(), n_points)
_, idxs, _,_ = frnn.frnn_grid_points(points, points, n_points, n_points, K, radius, grid=None, return_nn=False, return_sorted=False)
Errror message:
$ python minimal_sample.py
torch.Size([1, 156424, 3]) tensor([156424], device='cuda:0')
Traceback (most recent call last):
File "minimal_sample.py", line 11, in <module>
_, idxs, _,_ = frnn.frnn_grid_points(points, points, n_points, n_points, K, radius, grid=None, return_nn=False, return_sorted=False)
File "/scratch2/shengyu/spv/lib/python3.8/site-packages/frnn-0.0.0-py3.8-linux-x86_64.egg/frnn/frnn.py", line 331, in frnn_grid_points
idxs, dists, sorted_points2, pc2_grid_off, sorted_points2_idxs, grid_params_cuda = _frnn_grid_points.apply(
File "/scratch2/shengyu/spv/lib/python3.8/site-packages/frnn-0.0.0-py3.8-linux-x86_64.egg/frnn/frnn.py", line 137, in forward
pc1_grid_cnt = torch.zeros((N, G),
RuntimeError: CUDA out of memory. Tried to allocate 7.51 GiB (GPU 0; 23.70 GiB total capacity; 15.03 GiB already allocated; 7.00 GiB free; 15.04 GiB reserved in total by PyTorch)
Is this because you are using dense grids? I think with sparse hash, I can still handle such point clouds. I'd really appreciate if you can provide some hints.
Best,
Shengyu
i am using 10M points and have a GPU memory of 11GB. The search works fine, but in points2_nn = frnn_gather(points2, idxs, lengths2)
I got an OOM error.
Traceback (most recent call last):
File "nd.py", line 131, in <module>
validator.launch()
File "nd.py", line 120, in launch
dists_frnn, idxs_frnn, nn_frnn = self.frnn_grid()
File "nd.py", line 74, in frnn_grid
return_sorted=True)
File "/home/vax10/u4/xx/venv/lib64/python3.6/site-packages/frnn-0.0.0-py3.6-linux-x86_64.egg/frnn/frnn.py", line 377, in frnn_grid_points
points2_nn = frnn_gather(points2, idxs, lengths2)
File "/home/vax10/u4/xx/venv/lib64/python3.6/site-packages/frnn-0.0.0-py3.6-linux-x86_64.egg/frnn/frnn.py", line 419, in frnn_gather
tmp_idxs = idxs.clone().detach()
RuntimeError: CUDA out of memory. Tried to allocate 4.64 GiB (GPU 1; 10.76 GiB total capacity; 7.77 GiB already allocated; 1.84 GiB free; 7.80 GiB reserved in total by PyTorch)
The Grid parameters are different...
2020-10-26 17:56:37.645472, frnn/frnn.py, frnn_grid_points, 272, r: tensor([0.1000, 0.1000], device='cuda:0')
2020-10-26 17:56:37.646062, frnn/frnn.py, forward, 62, r[i].item(): 0.10000000149011612, radius_cell_ratio: 2.0
2020-10-26 17:56:37.646082, frnn/frnn.py, forward, 63, cell_size: 0.05000000074505806
2020-10-26 17:56:37.646639, frnn/frnn.py, forward, 64, grid_params_cuda[i, 4:7]: tensor([20., 21., 20.], device='cuda:0')
2020-10-26 17:56:37.647305, frnn/frnn.py, forward, 62, r[i].item(): 0.10000000149011612, radius_cell_ratio: 2.0
2020-10-26 17:56:37.647324, frnn/frnn.py, forward, 63, cell_size: 0.05000000074505806
2020-10-26 17:56:37.648046, frnn/frnn.py, forward, 64, grid_params_cuda[i, 4:7]: tensor([20., 21., 20.], device='cuda:0')
According to DispatchKernel1D
(line 119) in frnn/csrc/utils/dispatch.h
, in V1 K should be within 2 and 8, but when I pass D=16 and K=5, I still get an error saying that K should be in this range [2, 8].
Also, frnn/frnn.py
says that "for now only point clouds of dimension 2-16 is supported"
, but in frnn/csrc/grid/grid.h
seems like to trigger V2 D should be between 1 and 8 and K should be between 1 and 32. So which one is correct?
I guess I can dig into the code a bit to figure out the exact limits on D and K, but would you mind telling me, for now, what the supported D and K ranges are?
seems like changes made to frnn/frnn.py
doesn't take place, even after running python setup.py install
. any idea why this might be the case?
Hi, lixin Xue:
I have some problems installing frnn, can you give me some advice to solve these problems? thanks for your help!
`
Processing /media/shi/projects/FRNN/external/prefix_sum
Preparing metadata (setup.py) ... done
Building wheels for collected packages: prefix-sum
Building wheel for prefix-sum (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
running bdist_wheel
running build
running build_ext
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/media/shi/projects/FRNN/external/prefix_sum/setup.py", line 9, in
setup(
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/init.py", line 107, in setup
return distutils.core.setup(**attrs)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/dist.py", line 1234, in run_command
super().run_command(command)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 325, in run
self.run_command("build")
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/dist.py", line 1234, in run_command
super().run_command(command)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/command/build.py", line 131, in run
self.run_command(cmd_name)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/dist.py", line 1234, in run_command
super().run_command(command)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
self.build_extensions()
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 390, in build_extensions
self._check_abi()
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 761, in _check_abi
check_compiler_abi_compatibility(compiler)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 294, in check_compiler_abi_compatibility
if not check_compiler_ok_for_platform(compiler):
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 254, in check_compiler_ok_for_platform
which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/home/shi/anaconda3/envs/frnn/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['which', 'g++']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for prefix-sum
Running setup.py clean for prefix-sum
Failed to build prefix-sum
ERROR: Could not build wheels for prefix-sum, which is required to install pyproject.toml-based projects
`
My environment configuration is as follows:
gcc/g++ version 7.5.0
cuda version 11.1
pytoch 1.10.1 and 2.0.1
Python 3.8
Ubuntu 18.04
Hi,
There is a problem in the FRNN installing. Could you give me some advice for this problem? Thank you
'''
cd ../../
pip install -e .
D:\Anaconda\envs\SPT\lib\site-packages\torch\utils\cpp_extension.py:359: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\link.exe' failed with exit code 1120
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
'''
My environment is as follows:
Python 3.8
CUDA 11.8
Pytorch 2.0.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.