opencv3 与cuda8不兼容,不启动支持cuda 真的是历经千辛啊
安装依赖库sudo apt-get install cmake git pkg-config libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-openCV python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-devbuildmkdir buildcd buildcmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..cmake成功后,会出现如下结果,提示配置和生成成功: – Configuring done – Generating done 由于CUDA 8.0不支持OpenCV的 GraphCut 算法,可能出现以下错误:
~/opencv3.1.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: 'NppiGraphcutState' has not been declaredtypedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppStat^/home/usrname/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:135:18: error: 'NppiGraphcutState' does not name a typeOperator NppiGraphcutState*()^【解决办法】进入opencv-3.1.0/modules/cudalegacy/src/目录,修改graphcuts.cpp文件,将:
#include "precomp.hpp"#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)改为
#include "precomp.hpp"#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)然后make编译就可以了
make -j8sudo make installhttps://github.com/BVLC/caffe 下载caffe-master.zip
在 caffe-master/python,如果是python2运行
for req in $(cat requirements.txt); do sudo pipinstall $req; done如果是python3,则把pip改为pip3
for req in $(cat requirements.txt); do pip3 install $req; done下面是我用 diff Makefile.config Makefile.config.example
比较出来的结果
runtest可能会遇到错误 libcudart.so.6.5: cannot open shared object file: No such file or directory. 执行以下操作
sudo cp /usr/local/cuda-8.0/lib64/libcudart.so.8.0 /usr/local/lib/libcudart.so.8.0 && sudo ldconfigsudo cp /usr/local/cuda-8.0/lib64/libcublas.so.8.0 /usr/local/lib/libcublas.so.8.0 && sudo ldconfigsudo cp /usr/local/cuda-8.0/lib64/libcurand.so.8.0 /usr/local/lib/libcurand.so.8.0 && sudo ldconfigsudo cp /usr/local/cuda-8.0/lib64/libcudnn.so.5 /usr/local/lib/libcudnn.so.5 && sudo ldconfigmake pycaffemake pycaffe如果遇到错误 /usr/bin/ld: cannot find -lboost_python3
执行
cd /usr/lib/x86_64-linux-gnu/sudo ln -s libboost_python-py35.so libboost_python3.sopython3.5的datautil/rrule.py里的raiseError有语法错误,要自己手动修改,把raiseError后面的语句用括号括起来
设置python caffe的路径
cd caffe-master/python
pwd
sudo gedit ~/.bashrc
添加 export PYTHONPATH=/home/chuny/caffe-master/python:$PYTHONPATH
保存后 source ~/.bashrc
【注意】 编译一次caffe,只能支持python2或python3 安装python的时候,用sudo pip install
是安装在根目录下,直接用pip安装的是在当前用户的home里面,其他用户用不了
新闻热点
疑难解答