Closed OniasC closed 3 years ago
An update:
By adding
link_directories(${PROJECT_SOURCE_DIR}/Thirdparty/cuda-bundle-adjustment/lib)
above cuda_add_library(...) I receive several compilation problems regarding conversion between libraries. They can be summarized in two big groups of errors:
relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZN6thrust8cuda_cub3cub11EmptyKernelIvEEvv' which may bind externally can not be used when making a shared object; recompile with -fPIC
I tried to fix that by adding target_compile_definitions(mono_euroc PRIVATE -fPIC)
after each cuda_add_executable(..) but with no success.
The second type of error is
/home/xxxx/ORB_SLAM2_CUDA/Thirdparty/cuda-bundle-adjustment/lib/libcuda_bundle_adjustment.a(cuda_bundle_adjustment_generated_cuda_block_solver.cu.o): In function `void thrust::cuda_cub::parallel_for<thrust::cuda_cub::tag, thrust::cuda_cub::__transform::unary_transform_f<thrust::permutation_iterator<thrust::device_ptr<float const>, thrust::device_ptr<int const> >, thrust::device_ptr<float>, thrust::cuda_cub::__transform::no_stencil_tag, thrust::cuda_cub::identity, thrust::cuda_cub::__transform::always_true_predicate>, long>(thrust::cuda_cub::execution_policy<thrust::cuda_cub::tag>&, thrust::cuda_cub::__transform::unary_transform_f<thrust::permutation_iterator<thrust::device_ptr<float const>, thrust::device_ptr<int const> >, thrust::device_ptr<float>, thrust::cuda_cub::__transform::no_stencil_tag, thrust::cuda_cub::identity, thrust::cuda_cub::__transform::always_true_predicate>, long)':
/usr/local/cuda/include/thrust/system/cuda/detail/util.h:213:(.text._ZN6thrust8cuda_cub12parallel_forINS0_3tagENS0_11__transform17unary_transform_fINS_20permutation_iteratorINS_10device_ptrIKfEENS6_IKiEEEENS6_IfEENS3_14no_stencil_tagENS0_8identityENS3_21always_true_predicateEEElEEvRNS0_16execution_policyIT_EET0_T1_[_ZN6thrust8cuda_cub12parallel_forINS0_3tagENS0_11__transform17unary_transform_fINS_20permutation_iteratorINS_10device_ptrIKfEENS6_IKiEEEENS6_IfEENS3_14no_stencil_tagENS0_8identityENS3_21always_true_predicateEEElEEvRNS0_16execution_policyIT_EET0_T1_]+0x1b4): dangerous relocation: unsupported relocation
Don't know if it helps, but I'm trying to build this project in the jetson nano
Hi, @OniasC
I'm sorry to have troubled you. It seems ORB_SLAM2 needs to link with shared libraries.
Try to fix CMakeLists.txt as follows, and build and install.
-cuda_add_library(cuda_bundle_adjustment ${srcs})
+cuda_add_library(cuda_bundle_adjustment SHARED ${srcs})
Regards,
Hi, @atakagi-fixstars
Thank you for answering, and your suggestion did eliminate that error, thank you very much for that! But that didnt eliminate all the errors, unfortunately. When, building I get this error:
Built target cuda_bundle_adjustment
[ 60%] Built target ORB_SLAM2_CUDA
[ 63%] Linking CXX executable mono_euroc_savemap
../lib/libORB_SLAM2_CUDA.so: undefined reference to `cuba::CudaBundleAdjustment::create()'
collect2: error: ld returned 1 exit status
My cmakelists is as follows:
[...]
cuda_include_directories(
${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc
)
link_directories(${PROJECT_SOURCE_DIR}/Thirdparty/cuda-bundle-adjustment/lib)
cuda_add_library(${PROJECT_NAME} SHARED
src/System.cc
src/Tracking.cc
src/LocalMapping.cc
src/LoopClosing.cc
src/ORBextractor.cc
src/ORBmatcher.cc
src/FrameDrawer.cc
src/Converter.cc
src/MapPoint.cc
src/KeyFrame.cc
src/Map.cc
src/MapDrawer.cc
src/Optimizer.cc
src/PnPsolver.cc
src/Frame.cc
src/KeyFrameDatabase.cc
src/Sim3Solver.cc
src/Initializer.cc
src/Viewer.cc
src/cuda/Allocator_gpu.cu
src/cuda/Fast_gpu.cu
src/cuda/Orb_gpu.cu
src/cuda/Cuda.cu
)
cuda_add_library(cuda_bundle_adjustment SHARED ${srcs})
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so
cuda_bundle_adjustment
${CUDA_cusparse_LIBRARY}
${CUDA_cusolver_LIBRARY}
nvToolsExt
)
[...]
edit: tried deleting the whole build folder and starting over but had the same behavior.
Hi, @OniasC
You need to edit cuda-bundle-adjustment/src/CMakeLists.txt
, not ORB_SLAM2/CMakeLists.txt
.
Add SHARED
to this line
https://github.com/fixstars/cuda-bundle-adjustment/blob/master/src/CMakeLists.txt#L38
Then, build and install.
$ cd cuda-bundle-adjustment
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX={YOUR_ORB_SLAM2_DIR}/Thirdparty/cuda-bundle-adjustment
$ make -j 4
$ make install
Regards,
Hi @atakagi-fixstars
It worked! Thank you for the support! I'll mark this issue as closed.
Regards,
Hello,
I am trying to run orb-slam with cuba (and possibly later add the LocalBundleAdjustmentCuba) by following the wiki (https://github.com/fixstars/cuda-bundle-adjustment/wiki/Use-cuda-bundle-adjustment-in-ORB-SLAM2). Aside from the steps mentioned I also had to comment the line
if(pbStopFlag) optimizer.setForceStopFlag(pbStopFlag)
as the new optimizer doesn't have that parameter.I compiled the cuba repo in the thirdparty folder as mentioned on the wiki and when I build orb-slam from their buid script it doesn't flag any errors when compiling Optimizer.cc. But when it is in building past vier.cc.o it accuses an error
If it helps, in my cmakelist this is the order of added libraries (I am trying to build this solution together with another one that runs orb in cuda):
Could some one point me in the right direction? Thanks in advance!