caffe-ssd

1.安装依赖

1 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
2 sudo apt-get install --no-install-recommends libboost-all-dev
3 sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
4 sudo apt-get install libatlas-base-dev
5 sudo apt-get install python-dev

2、下载caffe 

https://github.com/BVLC/caffe

3.编译Caffe 
(1)切换到Caffe所在目录

cp Makefile.config.example Makefile.config

(2)修改配置文件Makefile.config

  • CPU_ONLY := 1
  • 配置引用文件(解决新版本下,HDF5的路径问题)
INCLUDE_DIRS := $(PYTHON_INCLUDE)  /usr/local/include  /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB)  /usr/local/lib   /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
BLAS := atlas
 

(3)编译 Caffe

make all -j8
make test -j8
make runtest -j8

4.编译Python接口 
Caffe拥有python\C++\shell接口,在Caffe使用python特别方便,在实例中都有接口的说明。

sudo apt-get install python-pip
  • 执行安装依赖
cd ~/caffe
sudo apt-get install gfortran
cd ./python for req in $(cat requirements.txt); do pip install $req; done

安装完成以后,再次回到caffe根目录我们可以执行:

sudo pip install -r python/requirements.txt

就会看到,安装成功的,都会显示Requirement already satisfied, 没有安装成功的,会继续安装。

  • 编译python接口
make pycaffe -j8

--结果显示ALL TESTS PASSED就安装好了!

  • 运行python结构
复制代码
$ python2.7
Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>> 
复制代码

如果没有报错,说明caffe安装全部完成(注意:要进入caffe/python再执行python命令,否则import caffe会提示找不到caffe)!

5.在Mnist运行Lenet

  • 获取数据源
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
  • 因为是CPU运行,所以修改在examples文件下的Mnist下的lenet_solver.prototxt中的solver_mode:CPU
solver_mode: CPU
  • 训练模型
./examples/mnist/train_lenet.sh

添加python目录

vi ~/.bashrc
export PYTHONPATH=/home/username/caffe/python:PYTHONPATH
source ~/.profile

猜你喜欢

转载自www.cnblogs.com/crazybird123/p/9123055.html