Ubuntu 14.04安装 Caffe

来源:互联网 发布:淘宝市场行情有什么用 编辑:程序博客网 时间:2024/04/28 04:00

安装Caffe的过程,是在前几篇博客先安装CUDA 6.5然后再安装openCV, MATLAB,Python成功基础上安装成功,

因此,最终Caffe安装的成功,也需要参考前几篇博客!可参考序号步骤进行安装!


7. 安装Caffe
7.1 先装git: sudo apt-get install git
7.2 初始化远程服务器地址: git init
7.3 添加远程服务器地址: git remote add mycaffe https://github.com/BVLC/caffe/
7.4 克隆远程服务器caffe文件到本地硬盘/home/wangchuan/ caffe_install文件夹中: git clone https://github.com/BVLC/caffe/ caffe_install
7.5 在caffe_install文件夹下,复制Makefile.config.example然后修改Makefile.config中的设置:
sudo cp Makefile.config.example Makefile.config
7.6 修改Makefile.config中的参数设置: sudo gedit Makefile.config
   修改参数包括: CPU_PNLY是否只用CPU模式,没有安装GPU的可以取消注释这个选项
BLAS:使用Intel MKL还是 OpenBLAS
 MATLAB_DIR需要指定matlab安装路径,比如本机路径为/usr/local/MATLAB/R2013a(注意该目录下需要包含bin文件夹,

bin下包含mex二进制程序)
DEBUG 是否使用debug模式
        7.7 保存退出,在/home/wangchuan/caffe_install 目录下开始编译:
make all -j4   如果是8核cpu, -j8

PS:
7.7.1 在make编译时,可能会出现/usr/lib/x86_64-linux-gnu/libx264.so.142: undefined reference to `__powf_finite@GLIBC_2.15'
collect2: error: ld returned 1 exit status
或者bc:symbol lookup error
               等编译错误时,一般删除anaconda/lib下的动态链接库: sudo rm ~/anaconda/libm.*
               然后再编译make
7.7.2 在make编译时出现libopencv_highgui.so:undefined reference to 'TIFFIsTiled@LIBTIFF_4.0'
在openCV_install文件夹下,修改install.sh中添加cmake -D BUILD_TIFF=ON


7.8 安装最新的libhdf5, http://www.hdfgroup.org/HDF5/release/obtain5.html下载


7.9 将解压的目录拷贝到/usr下的对应路径:
sudo cp -r ./bin /usr
sudo cp -r ./include /usr
sudo cp -r ./lib /usr
sudo cp -r ./share /usr

7.10 执行: make test

7.11 执行: make runtest

出现信息: YOU HAVE 2 DISABLED TESTS 说明Caffe runtest 成功!



8. 测试Caffe
8.1 在/home/wangchuan/caffe_install目录下执行编译MATLAB接口: make matcaffe
8.2 在/home/wangchuan/caffe_install目录下执行编译Python接口: make pycaffe
8.3 更新Matlab使用的c++库:
   必须在/usr/local/R2013a/sys/os/glnxa64/ 运行
   sudo ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 libstdc++.so.6
8.4 下载测试模型bvlc_reference_caffenet.caffemodel,

网址https://github.com/BVLC/caffe/tree/master/models/bvlc_reference_caffenet
8.5 拷贝到/home/wangchuan/caffe_install/models/bvlc_reference_caffenet/路径下,并执行权限:
   sudo chmod 777 bvlc_reference_caffenet.caffemodel
8.6 打开Matlab找到/home/wangchuan/caffe_install/matlab/caffe路径,输入指令:
>> im = imread('/home/wangchuan/caffe_install/examples/images/cat.jpg');
>> scores = matcaffe_demo(im, 1);
8.7 运行返回一组数组,说明Caffe运行demo成功!


0 0
原创粉丝点击