Ubuntu安装opencv with cuda
为了运行dense flow真是折腾啊,下面网址是教程
http://blog.aicry.com/ubuntu-14-04-install-opencv-with-cuda/
http://rolflussi.blogspot.com/2015/09/opencv-with-cuda-on-ubuntu-1404.html
建议不要安装3.0以上版本,但是2.4.10版本又不支持gpu,真TM坑爹,应该可以用2.4.12版本。
1、首先下载opencv2.4.12版本
http://opencv.org/downloads.html
2、安装依赖包
sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils
3、build opencv
cd opencv
mkdir release
cd release
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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 ..
4、检查cmake输出,确保CUDA and CUBLAS 选项开启
-- Use Cuda: YES (ver 6.5)
-- Use OpenCL: YES
--
-- NVIDIA CUDA
-- Use CUFFT: YES
-- Use CUBLAS: YES
-- USE NVCUVID: NO
-- NVIDIA GPU arch: 11 12 13 20 21 30 35
-- NVIDIA PTX archs: 30
-- Use fast math: YES
5、如果有,开始安装opencv
make -j8 //建议多线程编译.单线程超慢
sudo make install
6、配置环境变量
echo '/usr/local/lib' | sudo tee -a /etc/ld.so.conf.d/opencv.conf
sudo ldconfig
printf '# OpenCV\nPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig\nexport PKG_CONFIG_PATH\n' >> ~/.bashrc
source ~/.bashrc
如果要删除opencv,可以直接在此目录下执行
sudo make uninstall
查看opencv版本
pkg-config --modversion opencv