ubuntu14.04 安装caffe

安装matlab2015b

选择产品
MATLAB 8.6
Computer Vision System Toolbox 7.0
Image Acquisition Toolbox 4.10
Image Processing Toolbox 9.3
MATLAB Coder 3.0
MATLAB Compiler 6.1
MATLAB Compiler SDK 6.1
MATLAB Report Generator 4.2
Neural Network Toolbox 8.4
Statistics and Machine Learning Toolbox 10.1

安装caffe

caffe 需要的包

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install - -no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
from http://caffe.berkeleyvision.org/install_apt.html

如果遇到下面的错误

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:

重新编辑源/etc/apt/sources.list,我遇到好几次都是这个被改了,无法自动解决依赖关系
初步推测,可能是镜像站没有保留全部的依赖关系,导致了这个问题,因为我在家里14.04.5上,用163的源就有各种依赖问题,换成清华的就一步搞定了

安装OpenBLAS

参照 www.openblas.net 和 https://github.com/xianyi/OpenBLAS

git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
make
make install

The default directory is /opt/OpenBLAS

cp Makefile.config.example Makefile.config
vim Makefile.config # 编辑 BLAS 和 python 路径
BLAS := open
BLAS_INCLUDE := /opt/OpenBLAS/include
BLAS_LIB := /opt/OpenBLAS/lib

安装python所需

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

安装 CUDA 和 cuDNN

http://blog.csdn.net/Reformatsky/article/details/74637575

配置编译caffe

配置openblas 和 matlab的路径之后,配置
编译pycaffe前,需要修改 PYTHON_INCLUDE

PYTHON_INCLUDE := /usr/include/python2.7 \
        /usr/lib/python2.7/dist-packages/numpy/core/include \ # 这个路径我没有找到,删不删除随意
        /usr/local/lib/python2.7/dist-packages/numpy/core/include # 如果不加这个路径,会发生下面的错误。这个路径用locate arrayobject.h 可以看到

不加会遇到下面的错误

touch python/caffe/proto/__init__.py
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
PROTOC (python) src/caffe/proto/caffe.proto
python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: No such file or directory
 #include <numpy/arrayobject.h>
                               ^
compilation terminated.
make: *** [python/caffe/_caffe.so] Error 1

make runtest如果遇到下面的错误

.build_release/test/test_all.testbin 0 --gtest_shuffle --gtest_filter="-*GPU*"
.build_release/test/test_all.testbin: error while loading shared libraries: libopenblas.so.0: cannot open shared object file: No such file or directory
make: *** [runtest] Error 127

参考
https://groups.google.com/forum/#!topic/caffe-users/J6Sw2eKeshY
解决办法有两个

# 1 在/usr/lib 下创建到/opt/OpenBLAS/lib/libopenblas.so.0 的符号链接
ln -s /opt/OpenBLAS/lib/libopenblas.so.0 /usr/lib/
# 2 export LD\_LIBRARY_PATH with OpenBLAS library path

如果显示 绿色的 PASSED,说明完成了。

Training LeNet on MNIST with Caffe

参考 http://caffe.berkeleyvision.org/gathered/examples/mnist.html

cd $CAFFE_ROOT
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
./examples/mnist/train_lenet.sh

1080ti 花了大概10几秒,比CPU_ONLY 快了非常多

make matcaffe 提示

Warning: You are using gcc version '4.8.4'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
Warning: You are using gcc version '4.8.4-2ubuntu1~14.04.3)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
MEX completed successfully.

想办法安装4.7的gcc,并替换4.8的符号链接

apt install -y gcc-4.7 g++-4.7
cd /usr/bin
mkdir gcc-link-bak
mv gcc g++ gcc-link-bak/
ln -s gcc-4.7 gcc
ln -s g++-4.7 g++

运行demo报错

Error using textscan
'BufSize' is no longer required and has been removed.

Error in read_cell (line 11)
fileLines = textscan(fid,'%s','delimiter',linesep,'BufSize',100000);

Error in matcaffe_batch_feat (line 28)
    list_im = read_cell(filename);

Error in demo (line 30)
[feat_test , list_im] = matcaffe_batch_feat(test_file_list, use_gpu, feat_len, model_def_file,
model_file);

cvprw15这篇文章使用的是matlab2012,而15的接口已经变了
尝试删除 ‘BufSize’,100000 这两个参数后demo,发现找不到libopenblas.so.0,说明前面只能用符号链接这个库到/usr/lib了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Ubuntu 14.04安装方法有多种。首先,你可以从官方网站上下载Ubuntu Kylin 14.04.1的安装文件,并按照官方提供的步骤进行安装。另外,你也可以选择安装Ubuntu Server版本,具体步骤如下: 1. 首先,下载Ubuntu Server 14.04的ISO镜像文件,并制作成系统盘。 2. 将制作好的系统盘插入计算机,并启动计算机。 3. 在Ubuntu界面中选择"Install Ubuntu Server",然后按"Enter"键继续安装。 4. 根据安装向导的提示,选择合适的语言、时区、键盘布局等选项。 5. 在磁盘分区界面,选择你想要安装Ubuntu的磁盘,并根据需要进行分区。你可以选择使用整个磁盘,或者手动设置分区。 6. 设置主机名、用户名和密码,这将是你登录系统时使用的凭据。 7. 在软件选择界面,选择你需要安装的软件包,或者使用默认选项。 8. 等待安装完成,然后重新启动计算机。 这样,你就可以成功安装Ubuntu 14.04了。请记住,安装过程中可能会有一些特定的步骤和配置,具体根据你的需求进行调整。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ubuntu14.04安装方法汇总](https://blog.csdn.net/baobei0112/article/details/43083245)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [ubuntu server 14.04安装手册](https://blog.csdn.net/yugemengjing/article/details/86619066)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值