linux編譯gpu_flow
因為需要做雙流,論文裏面推薦到這個GPU版本的TVL1算法,於是開始編譯。
一、下載源碼
git clone https://github.com/feichtenhofer/gpu_flow.git
二、Dependencies
- [OpenCV 2.4] (http://opencv.org/downloads.html)
- [Qt 5.4] (https://www.qt.io/qt5-4/)
- [cmake] (https://cmake.org/)
由於我系統cmake和QT都沒有問題,主要問題出在了opencv上,由於之前已經編譯過一個OPENCV3.X,被同事安裝在了系統路徑下,因此我需要重新編譯opencv2.4,並且進行版本切換。
下載opencv2.4.13.5,解壓後進入源碼目錄,mkdir build-->cd build-->cmake-gui ..在裏面修改install_prefix,並把所有cuda9.0改為cuda8.0,, Configure-->Generate-->make -j28, 然後報錯:
CMake Warning at cmake/OpenCVPackaging.cmake:23 (message): CPACK_PACKAGE_VER
修改opencv的CMakeLists.txt,
403 if(GIT_EXECUTABLE) 404 execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty --match "2.[0-9].[0-9]*" 405 WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}" 406 OUTPUT_VARIABLE OPENCV_VCSVERSION 407 RESULT_VARIABLE GIT_RESULT 408 ERROR_QUIET 409 OUTPUT_STRIP_TRAILING_WHITESPACE 410 ) 411 if(NOT GIT_RESULT EQUAL 0) 412 #set(OPENCV_VCSVERSION "unknown") 413 set(OPENCV_VCSVERSION "2.4.13")414 endif() 415 else() 416 # We don‘t have git: 417 #set(OPENCV_VCSVERSION "unknown") 418 set(OPENCV_VCSVERSION "2.4.13") 419 endif()
修改此處為2.4.13,重新編譯通過,make install,完成。
三、編譯gpu_flow
1.mkdir -p build
2.cd build
3.cmake-gui ..
修改其中cuda9.0為cuda8.0
configure-->generate,報錯,此處由於我兩個OPENCV版本發生沖突,需要進行版本切換。
opencv版本切換:
原opencv3在/usr/local/share/OpenCV中,新的opencv2.4.13.5在我的home下面,執行
export PKG_CONFIG_PATH=/home/ocean1101/Workspace/packages/opencv-2.4.13.5/lib/pkgconfig
export LD_LIBRARY_PATH=/home/ocean1101/Workspace/packages/opencv-2.4.13.5/lib
通過以下命令查看是否切換成功:
pkg-config --modversion opencv
修改gpu_flow的CMakeLists.txt:
在前幾行添加:
1 cmake_minimum_required(VERSION 2.4) 2 set (OpenCV_DIR "/home/ocean1101/Workspace/packages/opencv-2.4.13.5/build/install/") 3 set(CMAKE_PREFIX_PATH "/home/ocean1101/Workspace/packages/opencv-2.4.13.5/build/install") 4 set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
其中,set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)是由於如果不加這句的話,編譯時會靜態鏈接CUDA,如果沒有CUDA靜態庫的話會報錯,加上後則為動態鏈接CUDA,修改完後cmake .. --> make -j24 , OK,大功告成。
linux編譯gpu_flow