天天看點

ubuntu16.04配置Kintinuous

主要配置流程參考這篇部落格Ubuntu16.04下Kintinuous的配置

這裡主要講遇到的問題和解決方法:

1.nvcc fatal   : Unsupported gpu architecture 'compute_20'

解決方法:

cuda9.0/9.1 don't support compute_20

use the following options when you type cmake comand.

-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0 -D CUDA_ARCH_BIN=6.1 -D CUDA_ARCH_PTX=6.1

just like this when you run cmake.

cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0 -D CUDA_ARCH_BIN=6.1 -D CUDA_ARCH_PTX=6.1 ../src

(ps:在caffe配置中也會有類似問題但解決方法不同,在caffe中是

# CUDA architecture setting: going with all of them.  

# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.  

# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.  

# For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.  

CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \  

                -gencode arch=compute_20,code=sm_21 \  

                -gencode arch=compute_30,code=sm_30 \  

                -gencode arch=compute_35,code=sm_35 \  

                -gencode arch=compute_50,code=sm_50 \  

                -gencode arch=compute_52,code=sm_52 \  

                -gencode arch=compute_60,code=sm_60 \  

                -gencode arch=compute_61,code=sm_61 \  

                -gencode arch=compute_61,code=compute_61)

2./home/raven/workspace/Kintinuous/src/backend/DeformationGraph.cpp:1054:1:   required from here

/usr/include/flann/util/serialization.h:18:9: error: ‘class std::unordered_map<unsigned int, std::vector<unsigned int> >’ has no member named ‘serialize’

         type.serialize(ar);

問題原因:

We had a mysterious error in the serialization code if we included the flann headers after some opencv headers and used 

g++ -std=c++11

. Changing the include order fixed the issue (including flann headers before any opencv headers). It seems that opencv headers leak 

#define USE_UNORDERED_MAP 1

 in case of std ≥ C++11. This then gets picked up by the 

#if

 in lsh_table.h in the original flann library.

解決方法:

The solution is to include flann before OpenCV.

即找到/Kintinuous/src/backend/DeformationGraph.h,将其中和flann相關的include全部提到opencv之前。

3./usr/local/include/opencv2/nonfree/features2d.hpp:73:21: error: ‘vector’ has not been declared

                     vector<KeyPoint>& keypoints) const;

/usr/local/include/opencv2/nonfree/features2d.hpp:73:27: error: expected ‘,’ or ‘...’ before ‘<’ token

                     vector<KeyPoint>& keypoints) const;

問題原因:

有說原因是安裝了多版本opencv的,我進行徹底解除安裝再重新安裝opencv後還是有這個錯誤,目前還待解決中

安裝opencv過程中cmake遇到問題,

CMake Warning at cmake/OpenCVPackaging.cmake:23 (message):

  CPACK_PACKAGE_VERSION does not match version provided by version.hpp

  header!

解決方法為CMake Warning at cmake/OpenCVPackaging.cmake:23 (message): CPACK_PACKAGE_VER 問題處理

其中在cmakelist中修改:

if(NOT GIT_RESULT EQUAL 0)
    set(OPENCV_VCSVERSION "2.4.13")
  endif()
else()
  # We don't have git:
  set(OPENCV_VCSVERSION "2.4.13")

endif()
           

4.發現了新的問題,是在安裝DLib,DBoW2,DLoopDetector時,cmake資訊中沒有注意到他預設找到的opencv版本是kinetic中的share檔案夾下的opencv3.3.1-dev,重新選擇usr/local/share/opencv後configure,generate,再make和install。

還要注意這三個依賴的版本号,在檔案夾下運作指令

git reset --hard 版本号
           

在對kintinuous進行cmake時,檢查opencv路徑也有同樣問題

綜上,問題3實際上是由問題4導緻的,解決以後編譯成功,這告訴我細心檢查CMakeCache.txt是多麼重要。。。卡了我好久才弄明白怎麼回事啊哭遼