yuxng / PoseCNN

A Convolutional Neural Network for 6D Object Pose Estimation in Cluttered Scenes
https://rse-lab.cs.washington.edu/projects/posecnn/
MIT License
763 stars 245 forks source link

Compile Error #7

Closed kuonangzhe closed 6 years ago

kuonangzhe commented 6 years ago

Since it said that '-lkfusion' is not found when compiling 'lib/syntheize', I compile the 'lib/kinect_fusion' with following command:

cd kinect_fusion
mkdir build && cd build && cmake ..
make

Then it comes out with cuda error:

/usr/local/cuda-8.0/include/cuda_runtime.h(546): warning: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __host__ __device__ function("") is not allowed

/usr/local/cuda-8.0/include/cuda_runtime.h(546): warning: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __host__ __device__ function("") is not allowed

PoseCNN/lib/kinect_fusion/./src/transform/nonrigid.cu(758): error: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __global__ function("df::initializeNewBaseLevelVertexTransformsKernel<float, (int)4> ") is not allowed

PoseCNN/lib/kinect_fusion/./src/transform/nonrigid.cu(758): error: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __global__ function("df::initializeNewBaseLevelVertexTransformsKernel<float, (int)4> ") is not allowed

PoseCNN/lib/kinect_fusion/./src/transform/nonrigid.cu(97): error: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __global__ function("df::warpMeshKernel<float, (int)4, (int)1, (int)3> ") is not allowed

PoseCNN/lib/kinect_fusion/./src/transform/nonrigid.cu(97): error: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __global__ function("df::warpMeshKernel<float, (int)4, (int)1, (int)3> ") is not allowed

PoseCNN/lib/kinect_fusion/./src/transform/nonrigid.cu(97): error: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __global__ function("df::warpMeshKernel<float, (int)4, (int)2, (int)4> ") is not allowed

PoseCNN/lib/kinect_fusion/./src/transform/nonrigid.cu(97): error: calling a __host__ function("Eigen::Quaternion<float, (int)2> ::Quaternion") from a __global__ function("df::warpMeshKernel<float, (int)4, (int)2, (int)4> ") is not allowed

6 errors detected in the compilation of "/tmp/tmpxft_0000d886_00000000-7_nonrigid.cpp1.ii".
# --error 0x2 --
CMake Error at kfusion_generated_nonrigid.cu.o.cmake:266 (message):
  Error generating file
PoseCNN/lib/kinect_fusion/build/CMakeFiles/kfusion.dir/src/transform/./kfusion_generated_nonrigid.cu.o

CMakeFiles/kinectFusion.dir/build.make:91: recipe for target 'CMakeFiles/kfusion.dir/src/transform/kfusion_generated_nonrigid.cu.o' failed
make[2]: *** [CMakeFiles/kfusion.dir/src/transform/kfusion_generated_nonrigid.cu.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/kinectFusion.dir/all' failed
make[1]: *** [CMakeFiles/kinectFusion.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I read several issues in DA-RNN, tried but still not solved. Is there any suggestions? The system is Ubuntu16.04, and Python 3.5. Thanks a lot!

haudren commented 6 years ago

I fixed the compile issue with the following patch:

diff --git a/lib/kinect_fusion/CMakeLists.txt b/lib/kinect_fusion/CMakeLists.txt
index a866277..3bae311 100644
--- a/lib/kinect_fusion/CMakeLists.txt
+++ b/lib/kinect_fusion/CMakeLists.txt
@@ -8,7 +8,6 @@ endif()
 add_definitions(-std=c++11)
 add_definitions(-Wall)
 add_definitions(-fPIC)
-#add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

 # supply compile-time directory to code
 set(compileDirectory \"${PROJECT_SOURCE_DIR}\")
@@ -74,9 +73,10 @@ file( GLOB SHADER_SOURCES

 #set(CUDA_SEPARABLE_COMPILATION ON)
 set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-std=c++11;--expt-relaxed-constexpr;-O3;-arch=sm_61;--expt-extended-lambda;--verbose;-Xcompiler -fPIC;")
+#set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-std=c++11;--expt-relaxed-constexpr;-O3;-D_MWAITXINTRIN_H_INCLUDED;--expt-extended-lambda;--verbose;-Xcompiler -fPIC;")
 #set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-std=c++11;--expt-relaxed-constexpr;-O3;-gencode arch=compute_61,code=sm_61;--expt-extended-lambda;--verbose;")

-message(STATUS "pangolin: ${Pangolin_INCLUDE_DIRS}")
+message(STATUS "pangolin: ${Pangolin_INCLUDE_DIRS} ${Pangolin_LIBRARIES}")

 cuda_add_library(
   kfusion
@@ -88,6 +88,8 @@ cuda_add_library(
   ${SHADER_SOURCES}
 )

+target_link_libraries(kfusion ${Pangolin_LIBRARIES})
+
 cuda_add_executable(
   kinectFusion
   kinect_fusion.cpp
@@ -96,3 +98,5 @@ cuda_add_executable(
   ${DF_CUDA_SOURCES}
   ${SHADER_SOURCES}
 )
+
+target_link_libraries(kinectFusion kfusion ${Pangolin_LIBRARIES})
diff --git a/lib/kinect_fusion/src/transform/nonrigid.cu b/lib/kinect_fusion/src/transform/nonrigid.cu
index e15fcfe..5d29a29 100644
--- a/lib/kinect_fusion/src/transform/nonrigid.cu
+++ b/lib/kinect_fusion/src/transform/nonrigid.cu
@@ -94,7 +94,7 @@ __global__ void warpMeshKernel(DeviceTensor<DTensor, Eigen::UnalignedVec3<Scalar

 //            const NNVec nearestNeighborIndices = nearestNeighborGrid(nearestNeighborVoxel);

-            DualQuaternion blendedTransform;
+            DualQuaternion blendedTransform(deformationGraphTransforms(0));

             const bool initialized = blendDualQuaternions(blendedTransform, unwarpedVertexGridCoords,
                                                           unwarpedVertexWorldCoords, deformationGraphVertices,
@@ -755,9 +755,10 @@ __global__ void initializeNewBaseLevelVertexTransformsKernel(const DeviceTensor1

         const Vec3 newVertexInGridCoords = nearestNeighborGrid.worldToGrid(newVertexInWorldCoords);

-        DualQuaternion<Scalar,Eigen::DontAlign> blendedTransform;
+        //DualQuaternion<Scalar,Eigen::DontAlign> blendedTransform;

-        const bool initialized = blendDualQuaternions(blendedTransform,newVertexInGridCoords,newVertexInWorldCoords,
+        const bool initialized = blendDualQuaternions(baseLevelTransforms(index),
+                                                      newVertexInGridCoords,newVertexInWorldCoords,
                                                       baseLevelVertices, baseLevelTransforms, nearestNeighborGrid,
                                                       oneOverBlendingSigmaSquared);

@@ -765,9 +766,7 @@ __global__ void initializeNewBaseLevelVertexTransformsKernel(const DeviceTensor1

             printf("initialized %d\n",index);

-            blendedTransform.normalize();
-
-            baseLevelTransforms(index) = blendedTransform;
+            baseLevelTransforms(index).normalize();

         }
kuonangzhe commented 6 years ago

@haudren Thank you so much, it works!