Ubuntu14.04 安装Caffe(仅CPU)

转载 2016年01月08日 14:40:26

前言:


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>

即可

Ubuntu14.04下配置caffe(仅使用CPU)

在网上的一些教程的基础上,加上自己调试了一个下午终于成功安装了,可能大部分与网上的相同,但是加了一些我在安装时遇到的小问题。 这几天因为要参加一个比赛,所以急着给电脑装caffe,不多说了,进入正题...
  • qq_31541621
  • qq_31541621
  • 2016年05月30日 15:23
  • 678

Ubuntu14.04 安装Caffe(仅CPU)

Ubuntu14.04 安装Caffe(仅CPU)
  • u011762313
  • u011762313
  • 2015年08月04日 18:47
  • 22670

caffe安装指南

其实caffe上的安装已经介绍的很清楚,而且也不乏介绍caffe的文章,之所以写这篇是因为这是一个中文版本的,再就是我在实验室服务器安装时遇到了很多问题,我觉得后来人可能会遇到,所以贴出来 Li...
  • kuaitoukid
  • kuaitoukid
  • 2014年10月23日 13:38
  • 54960

Ubuntu16.04-x64安装caffe(仅CPU)并测试

Ubuntu16.04-x64安装caffe(仅CPU)并测试 Caffe作为深度学习中框架之一,在图像处理,机器视觉方面受到广泛的应用。但是在caffe的安装过程中遇到诸多问题。在此,我们将基本流程...
  • ch15717502064
  • ch15717502064
  • 2017年09月16日 20:43
  • 569

Ubuntu16.04下配置caffe(仅CPU)

第二次配置caffe环境,依旧把之前犯过的错误重新走了一遍,不会配置的地方还是忘了,所以打算通过博客记录下来,方便以后学习使用。 1.安装依赖包 $ sudo apt-get install li...
  • zt_1995
  • zt_1995
  • 2017年02月22日 12:29
  • 1734

ubuntu14.04安装CPU版caffe以及py-faster-rcnn

本文转自博主,地址如下,仅为学习收藏用,在此谢过博主 http://blog.csdn.net/zyb19931130/article/details/53842791 第一部分:ubuntu...
  • gaohuazhao
  • gaohuazhao
  • 2017年03月03日 16:04
  • 1403

深度学习 caffe windows cpu matlab安装

折腾了很久,在研究了传统机器学习理论与应用后,着手进入到深度学习领域。虽然说,深度学习还是来源于人工智能的一个学派:连接学派,而且很高大尚的是,名字起的好,居然叫深度学习,和一般的学习不一样。但是这个...
  • Nicholas_Liu2017
  • Nicholas_Liu2017
  • 2017年04月30日 18:34
  • 865

ubuntu14.04 + caffe + python2.7 + CPU安装指南

本文基于ubuntu14.04 安装cpu版caffe,并安装pycaffe, 方便python调用caffe。 首先安装必须的依赖包:sudo apt-get install libprotobu...
  • zhang_shuai12
  • zhang_shuai12
  • 2016年08月23日 12:26
  • 4192

Ubuntu 14.04 + Caffe配置记录(CPU模式,无GPU,无Cuda)

对于使用深度学习进行图像处理,Caffe是一个不错的框架选择。但是安装起来,并不是如想象中容易,稍不注意就会出错。 网上关于Ubuntu14.04下配置Caffe的资料很多,但是总是要自己亲自配置才能...
  • Ying_Xu
  • Ying_Xu
  • 2016年07月01日 20:13
  • 76780

Windows Caffe 学习笔记 caffe-windows(CPU)配置与利用mnist数据集训练第一个caffemodel

版权声明:欢迎大家一起交流,有错误谢谢指正~~~多句嘴,不要复制代码,因为CSDN排版问题,有些东西会自动加入乱糟糟的字符,最好是自己手写代码。格外注意被“踩”的博客,可能有很大问题,请自行查找大牛们...
  • nantongcjq
  • nantongcjq
  • 2017年09月24日 14:00
  • 148
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Ubuntu14.04 安装Caffe(仅CPU)
举报原因:
原因补充:

(最多只允许输入30个字)