因为需要做双流,论文里面推荐到这个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,大功告成。