小白安装caffe、py-faster-rcnn艰难历程

来源:互联网 发布:windows redis集群搭建 编辑:程序博客网 时间:2024/05/21 20:20

安装anaconda:

  • 下载:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

      bash anaconda.....sh  enteryes..
  • 测试 :anaconda是否配置好可以通过在终端输入如下代码的方式:

      conda list
  • 如果提示错误,则说明没有配置好,需要进行下面的步骤:

     sudogedit ~/.bashrc 打开文件后在末尾输入 :export PATH="/home/***/anaconda2/bin:$PATH" 此处anaconda2的路径根据你自己的做相应的修改即可。 输入后打开一个新终端,输入python

安装caffeCPU版本:

  • 参考:http://blog.csdn.net/u012619146/article/details/50547352

安装无显卡驱动的cuda

  • 参考:http://blog.csdn.net/hjl240/article/details/51460884

1. makeall

  • 问题:各种未定义的引用

    解决

cd caffecp Makefile.config.example Makefile.configmkdir buildcd buildcmake .../configure make all
  • 问题:nvccfatal : Unsupported gpu architecture ‘compute_60’

CMakeError at cuda_compile_generated_nesterov_solver.cu.o.cmake:206(message):

Errorgenerating

/home/kuang/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_nesterov_solver.cu.o

make[2]:*[src/caffe/CMakeFiles/cuda_compile.dir/solvers/./cuda_compile_generated_nesterov_solver.cu.o]错误1

make[1]:* [src/caffe/CMakeFiles/caffe.dir/all]错误2

make:* [all]错误2

解决

make cleanrm-rf ./build/*make all

准备好了.执行

      make pycaffe      make all      make test      make runtest
  • 问题:import caffe失败:ImportError:No module named caffe

    解决

in caffe root dirmake allmake pycaffemake distribute#make dir for custom python modules, install caffemkdir ~/pythonmv  distribute/python/caffe ~/python #添加环境变量sudo gedit  ~/.bashrc将 export PYTHONPATH=/home/×××/caffe/python:$PYTHONPATH 添加到文件中。source~/.bashrc 使更改生效。#这样,在其他地方打开python,也可以 import caffe了。
  • 问题:Impor tError:No module named google.protobuf.internal

    解决:是在其中安装protobuf最新版本

sudo chmod 777 -R anaconda2conda install protobuf
  • 问题:之后测试 faster 的demo:错误原因已放弃(核心已转储)

解决:在运行程序时赋予管理员权限,也就是添加sudo

 缺少模块: sudo pip install easydict  sudo apt-get install python-opencv
  • 问题:找不到caffe:

make:*没有规则可以创建目标“pycaffe”。停止

faster下caffe编译不成功:make-j8 && make pycaffe
出错:errorThis file was generated by a newer version of protoc which is.build_release/src/caffe/proto/caffe.pb.h:13:2:error: #error incompatible with your Protocol Buffer headers. Pleaseupdate errorincompatible with your Protocol Buffer headers. Please update
.build_release/src/caffe/proto/caffe.pb.h:14:2:error: #error your headers.erroryour headers.
Infile included from ./include/caffe/blob.hpp:9:0,
from./include/caffe/layers/input_layer.hpp:6,
fromsrc/caffe/layers/input_layer.cpp:3:
.build_release/src/caffe/proto/caffe.pb.h:23:35:fatal error: google/protobuf/arena.h:没有那个文件或目录

include

sudo pip install --upgrade protobuf

安装protobuf:http://blog.csdn.net/yl204/article/details/50478279

查看boost版本:

dpkg -S /usr/include/boost/version.hpp 
  • 问题:boost版本为1,54不搭要求:
    解决安装1.55 http://blog.csdn.net/big_bit/article/details/51258895

安装opencv3: http://blog.csdn.net/forest_world/article/details/51372703

  • 问题:sudo make时出现问题:nvccfatal : Unsupported gpu architecture’compute_11’

解决:原因是CUDA7.5不支持较为古老的显卡版本,因此1.1,2.0,2.1,之类的显卡选项是多余的。
需要更改CmakeGUI对工程的配置,去掉对compute_11的支持

sudo cmake-D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DCUDA_GENERATION=Kepler ./ sudo cmake-D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DCUDA_GENERATION=Kepler ./

然后再次sudo make:

  • 问题:astorage class is not allowed in an explicit specialization

    解决:/opencv-3.0.0-alpha\modules\cudalegacy\src\cuda\NCVPixelOperations.hpp

    第51行到68行119到131出现错误的行的staticinline修改成inline就可以了

然后到测试是否成功安装:

http://www.tuicool.com/articles/nYJrYra

  • 问题:

OpenCV

Error: Unspecified error (The function is not implemented. Rebuildthe library with Windows, GTK+ 2.x or Carbon support. If you are onUbuntu or Debian, install libgtk2.0-dev and pkg-config, then re-runcmake or configure script) in cvNamedWindow, file/home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp,line 598
terminate called after throwing an instance of’cv::Exception’
what(): /home/aborn/software/OpenCV-2.4.1/modules/highgui/src/window.cpp:598:error: (-2) The function is not implemented. Rebuild the library withWindows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian,install libgtk2.0-dev and pkg-config, then re-run cmake or configurescript in function cvNamedWindow

简单的解释就是你的GTK+2.x要先于OpenCV安装,所以它给的解决方法是Youshould remove the current installation of opencv from your system;rebuild your opencv lib after installinggtk dev lib in the correct path; and reinstall the compiled opencvlib.

解决

在ubuntu下删除OpenCV的步骤如下:

1)进入opencv的源代码文件夹下的release(这是你在安装opencv时候自己命名的,cmake时候所在的目录)

2)依次执行下面的代码

make uninstallcd ..sudo rm -r releasesudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv/usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv/usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV/usr/local/bin/opencv* /usr/local/lib/libopencv

正确的:::::

一定要先装!!!!

安装gtk:http://blog.csdn.net/qq_33259138/article/details/52129732

再装:http://blog.csdn.net/xukai871105/article/details/40988101

中间 删掉static

/opencv-3.0.0-alpha\modules\cudalegacy\src\cuda\NCVPixelOperations.hpp (第51行到68行119到131)

opencv-3.0.0-alpha/modules/cudastereo/src/cuda/stereocsbp.cu(62,66,74)

make

sudo make install

下面配置library,打开/etc/ld.so.conf.d/opencv.conf,在末尾加入/usr/local/lib (有可能是个空文件,没关系)

然后 sudoldconfig

然后编辑/etc/bash.bashrc

加入

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfigexportPKG_CONFIG_PATH

至此,opencv安装配置完毕

下面开始测试

  • 问题:在rcnn的caffe里make不成功:

.build_release/lib/libcaffe.so:对‘cv::imread(cv::Stringconst&, int)’未定义的引用

解决:http://blog.csdn.net/xiaxiazls/article/details/52039473

  • 问题:.build_release/lib/libcaffe.so:对‘cv::imread(cv::Stringconst&, int)’未定义的引用

解决:执行要加cpu demo.py–cpu

继续在pyfaste的caffe master 下
sudo make pycaffe:

LD
-o .build_release/lib/libcaffe.so.1.0.0-rc3

/usr/bin/ld:
找不到 -l
-llmdb

/usr/bin/ld:
找不到 -l
-lopencv_core

collect2:
error: ld returned 1 exit status

make:
* [.build_release/lib/libcaffe.so.1.0.0-rc3] 错误 1

.build_release/lib/libcaffe.so:对‘cv::imread(cv::Stringconst&, int)’未定义的引用

lableimg安装:

由于Ubuntu系统自带python,这款软件在Ubuntu环境下的安装是最方便的。软件要求python版本在2.6以上,同时需要PyQt和lxml的支持。

sudo apt-get install pyqt4-dev-tools #安装PyQt4sudo pip install lxml #安装lxml,如果报错,可以试试下面语句sudo apt-get install python-lxmlgit clone https://github.com/tzutalin/labelImg.gitcd labelImgmake all./labelImg.py

使用方法

修改默认的XML文件保存位置,使用快捷键“Ctrl+R”,改为自定义位置,这里的路径一定不能包含中文,否则无法保存。源码文件夹中使用notepad++打开data/predefined_classes.txt,修改默认类别,比如改成person、car、motorcycle三个类别。“OpenDir”打开图片文件夹,选择第一张图片开始进行标注,使用“CreateRectBox”或者“Ctrl+N”开始画框,单击结束画框,再双击选择类别。完成一张图片后点击“Save”保存,此时XML文件已经保存到本地了。点击“NextImage”转到下一张图片。标注过程中可随时返回进行修改,后保存的文件会覆盖之前的。完成标注后打开XML文件,发现确实和PASCALVOC所用格式一样。

×

原创粉丝点击