flann-lib / flann

Fast Library for Approximate Nearest Neighbors
http://people.cs.ubc.ca/~mariusm/flann
Other
2.22k stars 649 forks source link

Can't support cuda10 #407

Open TouchDeeper opened 5 years ago

TouchDeeper commented 5 years ago

Hi, I want to build the Flann from source with Cuda on. Version of Cuda is 10.

error have been solved:

  1. nvcc fatal : Value 'sm_13' is not defined for option 'gpu-architecture' solve according this issue.
  2. flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(764): error: namespace "thrust" has no member "gather" solve according this issue

new error:

/media/wang/My Passport/UbuntuBackup/flann-1.8.4-src/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(324): error: calling a __device__ function("SingleResultSet") from a __host__ function("knnSearchGpu") is not allowed
          detected during instantiation of "void flann::KDTreeCuda3dIndex<Distance>::knnSearchGpu(const flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::ElementType> &, flann::Matrix<int> &, flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::DistanceType> &, size_t, const flann::SearchParams &) const [with Distance=flann::L2<float>]" 
(797): here

/media/wang/My Passport/UbuntuBackup/flann-1.8.4-src/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(347): error: calling a __device__ function("KnnResultSet") from a __host__ function("knnSearchGpu") is not allowed
          detected during instantiation of "void flann::KDTreeCuda3dIndex<Distance>::knnSearchGpu(const flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::ElementType> &, flann::Matrix<int> &, flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::DistanceType> &, size_t, const flann::SearchParams &) const [with Distance=flann::L2<float>]" 
(797): here

/media/wang/My Passport/UbuntuBackup/flann-1.8.4-src/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(362): error: calling a __device__ function("KnnResultSet") from a __host__ function("knnSearchGpu") is not allowed
          detected during instantiation of "void flann::KDTreeCuda3dIndex<Distance>::knnSearchGpu(const flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::ElementType> &, flann::Matrix<int> &, flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::DistanceType> &, size_t, const flann::SearchParams &) const [with Distance=flann::L2<float>]" 
(797): here

/media/wang/My Passport/UbuntuBackup/flann-1.8.4-src/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(390): error: calling a __device__ function("SingleResultSet") from a __host__ function("knnSearchGpu") is not allowed
          detected during instantiation of "void flann::KDTreeCuda3dIndex<Distance>::knnSearchGpu(const flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::ElementType> &, flann::Matrix<int> &, flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::DistanceType> &, size_t, const flann::SearchParams &) const [with Distance=flann::L2<float>]" 
(797): here

/media/wang/My Passport/UbuntuBackup/flann-1.8.4-src/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(413): error: calling a __device__ function("KnnResultSet") from a __host__ function("knnSearchGpu") is not allowed
          detected during instantiation of "void flann::KDTreeCuda3dIndex<Distance>::knnSearchGpu(const flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::ElementType> &, flann::Matrix<int> &, flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::DistanceType> &, size_t, const flann::SearchParams &) const [with Distance=flann::L2<float>]" 
(797): here

……

/media/wang/My Passport/UbuntuBackup/flann-1.8.4-src/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu(545): error: calling a __device__ function("RadiusKnnResultSet") from a __host__ function("radiusSearchGpu") is not allowed
          detected during instantiation of "int flann::KDTreeCuda3dIndex<Distance>::radiusSearchGpu(const flann::Matrix<flann::KDTreeCuda3dIndex<Distance>::ElementType> &, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>> &, std::vector<std::vector<flann::KDTreeCuda3dIndex<Distance>::DistanceType, std::allocator<flann::KDTreeCuda3dIndex<Distance>::DistanceType>>, std::allocator<std::vector<flann::KDTreeCuda3dIndex<Distance>::DistanceType, std::allocator<flann::KDTreeCuda3dIndex<Distance>::DistanceType>>>> &, float, const flann::SearchParams &) const [with Distance=flann::L1<float>]" 
(841): here

48 errors detected in the compilation of "/tmp/tmpxft_000030cf_00000000-4_kdtree_cuda_3d_index.cpp4.ii".
CMake Error at flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o.cmake:266 (message):
  Error generating file /media/wang/My
  Passport/UbuntuBackup/flann-1.8.4-src/build/src/cpp/CMakeFiles/flann_cuda_s.dir/flann/algorithms/./flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o

src/cpp/CMakeFiles/flann_cuda_s.dir/build.make:842: recipe for target 'src/cpp/CMakeFiles/flann_cuda_s.dir/flann/algorithms/flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o' failed
make[2]: *** [src/cpp/CMakeFiles/flann_cuda_s.dir/flann/algorithms/flann_cuda_s_generated_kdtree_cuda_3d_index.cu.o] Error 1
CMakeFiles/Makefile2:243: recipe for target 'src/cpp/CMakeFiles/flann_cuda_s.dir/all' failed
make[1]: *** [src/cpp/CMakeFiles/flann_cuda_s.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Looking forward to the update for cuda10!

akhalili commented 5 years ago

Add "#include <thrust/gather.h> header to on top of the file:

/flann/src/cpp/flann/algorithms/kdtree_cuda_3d_index.cu

TouchDeeper commented 5 years ago

@akhalili I'm sorry for the late reply.

I have added the "#include <thrust/gather.h>" when I solved the problem2.

The error I can't fix occurred after I solve the problem2/

scottfuX commented 4 years ago

I have also encountered this problem.Have you solved the second problem?

TouchDeeper commented 4 years ago

@909452726 Sorry, I don't solve the second problem.

scottfuX commented 4 years ago

@TouchDeeper So sad, how did you compile it?

TouchDeeper commented 4 years ago

@909452726 I didn't compile it. I use PCL to do cluster instead.

newten82 commented 4 years ago

It's probably not ideal. But I was able to get things to compile by adding __host__ to each of the places that were failing in flann/util/cuda/result_set.h. There are several that will need to be changed.

for example change: __device__ RadiusKnnResultSet(DistanceType radius, int knn, int* segment_starts, bool sortResults) : foundNeighbors(0),largestHeapDist(radius),k(knn), sorted(sortResults), radius_sq_(radius),segment_starts_(segment_starts) { } to: __device__ __host__ RadiusKnnResultSet(DistanceType radius, int knn, int* segment_starts, bool sortResults) : foundNeighbors(0),largestHeapDist(radius),k(knn), sorted(sortResults), radius_sq_(radius),segment_starts_(segment_starts) { }