关闭

Ubuntu14.04 安装Caffe(仅CPU)

6822人阅读 评论(2) 收藏 举报
分类:

前言:


GPU版本


正文:

安装依赖库(一):

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ sudo apt<span class="hljs-attribute" style="box-sizing: border-box;">-get</span> install libprotobuf<span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> libleveldb<span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> libsnappy<span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> libopencv<span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> libhdf5<span class="hljs-attribute" style="box-sizing: border-box;">-serial</span><span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> protobuf<span class="hljs-attribute" style="box-sizing: border-box;">-compiler</span>
$ sudo apt<span class="hljs-attribute" style="box-sizing: border-box;">-get</span> install <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>no<span class="hljs-attribute" style="box-sizing: border-box;">-install</span><span class="hljs-attribute" style="box-sizing: border-box;">-recommends</span> libboost<span class="hljs-attribute" style="box-sizing: border-box;">-all</span><span class="hljs-attribute" style="box-sizing: border-box;">-dev</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

安装BLAS:

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ sudo apt<span class="hljs-attribute" style="box-sizing: border-box;">-get</span> install libatlas<span class="hljs-attribute" style="box-sizing: border-box;">-base</span><span class="hljs-attribute" style="box-sizing: border-box;">-dev</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
  • 可以安装OpenBLAS 或 MKL,以提升CPU性能,但是要修改caffe中Makefile文件…

安装python

  • 我的Ubuntu14.04自带
  • 可使用pycaffe接口

安装matlab


安装opencv


安装依赖库(二):

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ sudo apt<span class="hljs-attribute" style="box-sizing: border-box;">-get</span> install libgflags<span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> libgoogle<span class="hljs-attribute" style="box-sizing: border-box;">-glog</span><span class="hljs-attribute" style="box-sizing: border-box;">-dev</span> liblmdb<span class="hljs-attribute" style="box-sizing: border-box;">-dev</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

下载Caffe:

<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cd ~
<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>git clone <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">git:</span>/<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/github.com/</span><span class="hljs-constant" style="box-sizing: border-box;">BVLC</span>/caffe.git</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

如果安装的是opencv3.0:

a、修改Makefile,在

<code class="hljs tex has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">LIBRARIES += glog gflags protobuf leveldb snappy <span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\
</span>lmdb boost_system hdf5_hl hdf5 m <span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\
</span>opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

处加入后面的opencv_imgcodecs,因为opencv3.0.0把imread相关函数放到imgcodecs.lib中了(原来是imgproc.lib)

b、修改caffe/examples/cpp_classification/classification.cpp文件,加入:

<code class="hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#include <opencv2/imgproc/types_c.h></span>
<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#include <opencv2/objdetect/objdetect_c.h></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

否则会出现”CV_BGR2GRAY”的错误


编译Caffe:

<code class="hljs smalltalk has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-char" style="box-sizing: border-box;">$ </span>cd ~/caffe
<span class="hljs-char" style="box-sizing: border-box;">$ </span>cp <span class="hljs-class" style="box-sizing: border-box; color: rgb(102, 0, 102);">Makefile</span>.config.example <span class="hljs-class" style="box-sizing: border-box; color: rgb(102, 0, 102);">Makefile</span>.config
# 修改<span class="hljs-class" style="box-sizing: border-box; color: rgb(102, 0, 102);">Makefile</span>.config文件:去掉<span class="hljs-class" style="box-sizing: border-box; color: rgb(102, 0, 102);">CPU_ONLY</span>:= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>的注释
<span class="hljs-char" style="box-sizing: border-box;">$ </span>make all
<span class="hljs-char" style="box-sizing: border-box;">$ </span>make test
<span class="hljs-char" style="box-sizing: border-box;">$ </span>make runtest</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>

配置pycaffe:

a、安装依赖库:

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ sudo apt<span class="hljs-attribute" style="box-sizing: border-box;">-get</span> install python<span class="hljs-attribute" style="box-sizing: border-box;">-numpy</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-scipy</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-matplotlib</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-sklearn</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-skimage</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-h5py</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-protobuf</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-leveldb</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-networkx</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-nose</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-pandas</span> python<span class="hljs-attribute" style="box-sizing: border-box;">-gflags</span> Cython ipython
$ sudo apt<span class="hljs-attribute" style="box-sizing: border-box;">-get</span> install protobuf<span class="hljs-attribute" style="box-sizing: border-box;">-c</span><span class="hljs-attribute" style="box-sizing: border-box;">-compiler</span> protobuf<span class="hljs-attribute" style="box-sizing: border-box;">-compiler</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

b、编译:

<code class="hljs smalltalk has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-char" style="box-sizing: border-box;">$ </span>cd ~/caffe
<span class="hljs-char" style="box-sizing: border-box;">$ </span>make pycaffe</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

c、添加~/caffe/python到$PYTHONPATH:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> gedit /etc/profile
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 末尾添加: export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 用完整路径,不要用~</span>
$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">source</span> /etc/profile <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 使之生效</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>

d、测试是否可以引用:

<code class="hljs python has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ python
Python <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.7</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.6</span> (default, Jun <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">22</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span>, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">58</span>:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>) 
[GCC <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4.8</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.2</span>] on linux2
Type <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"help"</span>, <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"copyright"</span>, <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"credits"</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">or</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"license"</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> more information.
<span class="hljs-prompt" style="color: rgb(0, 102, 102); box-sizing: border-box;">>>> </span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">import</span> caffe
<span class="hljs-prompt" style="color: rgb(0, 102, 102); box-sizing: border-box;">>>> </span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>

配置matcaffe:

a、gcc降级(Ubuntu14.04自带的gcc版本是4.8,MATLAB2014a支持的最高版本为4.7x。因此,需要安装gcc4.7,并给gcc降级): 
详见Ubuntu中update-alternatives命令(版本切换)

<code class="hljs brainfuck has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">apt</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">get</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">gcc</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">multilib</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">gcc</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">multilib</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">alternatives</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">100</span> 
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">alternatives</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/g</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">+</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">8</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">50</span> 
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">alternatives</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/gcc</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">gcc</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/gcc</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">100</span> 
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">alternatives</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/gcc</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">gcc</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/gcc</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">8</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">50</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">alternatives</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/cpp</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">cpp</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">bin</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/cpp</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">7</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">100</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">sudo</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">update</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">alternatives</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">install</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/cpp</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">cpp</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">bin</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">/usr/bin/cpp</span><span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">4</span><span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">.</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">8</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">50</span>

<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">验证gcc默认版本:</span>
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">$</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">gcc</span> <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">-</span><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">v</span> </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li></ul>

b、编译:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">$ <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cd</span> ~/caffe
<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 修改Makefile.config文件,MATLAB_DIR := /usr/local/MATLAB/R2014a</span>
$ make matcaffe</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

c、添加工作空间:

<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>sudo matlab -nodesktop -nosplash
>>> addpath ~<span class="hljs-regexp" style="color: rgb(0, 136, 0); box-sizing: border-box;">/caffe/matlab</span>
>>> savepath</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

即可

0
2

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1780954次
    • 积分:19055
    • 等级:
    • 排名:第491名
    • 原创:285篇
    • 转载:157篇
    • 译文:19篇
    • 评论:257条
    最新评论