Caffe(1)-安装

来源:互联网 发布:yii框架连接数据库 编辑:程序博客网 时间:2024/06/05 02:29

Caffe安装

@[Deep Learning]
系统环境ubuntu14.04

1. 依赖

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compilersudo apt-get install --no-install-recommends libboost-all-devsudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

2.CUDA 这里不作详细结束,详见CUDA官网

3. BLAS 根据自己需要选择安装ATLAS、OpenBlas、MKL等,我这里用的是ATLAS

4. python

安装一些python依赖库

cd caffe/pythonfor req in $(cat requirements.txt); do pip install $req; done

5.cuDNN我的显卡不支持,这里没有安装

6.opencv 详见opencv安装向导

7.编译

(1) 使用make

cd caffecp Makefile.config.example Makefile.config# Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)make all -j2make testmake runtest

这里遇到了一些错误

CXX/LD -o .build_release/tools/convert_imageset.bin.build_release/lib/libcaffe.so: undefined reference to cv::imread(cv::String const&, int)' .build_release/lib/libcaffe.so: undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)'.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'collect2: error: ld returned 1 exit statusmake: *** [.build_release/tools/convert_imageset.bin] Error 1

解决办法:
第一种:

gedit Makefile

找到

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5

改为

LIBRARIES += glog gflags protobuf leveldb snappy \lmdb boost_system hdf5_hl hdf5 m \opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

第二种:
使用(2)
(2) 使用cmake

mkdir buildcd buildcmake ..make all -j2make installmake runtest
  1. 使用pycaffe
make pycaffe

设置环境变量

gedit ~/.bashrc

在文件末尾添加

export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH

然后关闭并保存文件,执行以下语句

source ~/.bashrc

好了,这里pycaffe就配置好了
可以进入python shell执行

import caffe

如果没有错误说明安装成功了

0 0