Ubuntu16.04编译opencv3.1 CUDA9.0

1.官网下载opencv3.1.0源代码;https://github.com/opencv/opencv/archive/3.1.0.zip

2.修改cmake文件夹中的FindCUDA.cmake文件;

(1)查找“unset(CUDA_nppi_LIBRARY CACHE)”;

替换为:

  unset(CUDA_nppial_LIBRARY CACHE)
  unset(CUDA_nppicc_LIBRARY CACHE)
  unset(CUDA_nppicom_LIBRARY CACHE)
  unset(CUDA_nppidei_LIBRARY CACHE)
  unset(CUDA_nppif_LIBRARY CACHE)
  unset(CUDA_nppig_LIBRARY CACHE)
  unset(CUDA_nppim_LIBRARY CACHE)
  unset(CUDA_nppist_LIBRARY CACHE)
  unset(CUDA_nppisu_LIBRARY CACHE)
  unset(CUDA_nppitc_LIBRARY CACHE)

(2)查找"find_cuda_helper_libs(nppi)";

替换为:

  find_cuda_helper_libs(nppial)
  find_cuda_helper_libs(nppicc)
  find_cuda_helper_libs(nppicom)
  find_cuda_helper_libs(nppidei)
  find_cuda_helper_libs(nppif)
  find_cuda_helper_libs(nppig)
  find_cuda_helper_libs(nppim)
  find_cuda_helper_libs(nppist)
  find_cuda_helper_libs(nppisu)
  find_cuda_helper_libs(nppitc)

3.安装cmake工具;

sudo apt-get install cmake

4.安装依赖库;

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev qtbase5-dev

5.将头文件cuda_fp16.h添加至 opencv\modules\cudev\include\opencv2\cudev\common.hpp;

即在common.hpp中添加:

#include <cuda_fp16.h>

6.修改opencv3.1.0/modules/cudalegacy/src/graphcuts.cpp文件;

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
修改为:
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION>=8000)

7.解压下载的opencv3.1.0源码,进入到opencv3.1.0文件夹,创建release文件夹并进入;

mkdir release && cd release

8.cmake配置编译 ;

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON  -D CUDA_GENERATION=Kepler -D BUILD_PNG=ON ..

9.make编译和安装;

make -j$(nproc)
sudo make install

10.安装完成!

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值