【Caffe】Linux配置Pycaffe

使用git命令将github上caffe最新的代码下载下来。
(1)安装git:

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
    
    
  • 1
  • 2
  • 3

查看版本信息:

git --version
    
    
  • 1

(2)下载源代码:

git clone https://github.com/BVLC/caffe.git
    
    
  • 1

2. caffe配置

在源码的第一层目录中,有一个文件Makefile.config.example。首先进行文件拷贝:

cp Makefile.config.example Makefile.config
    
    
  • 1

然后对Makefile.config进行修改:

# 如果使用CUDNN的话,需要改为下面的形式
USE_CUDNN := 1
# 如果是在CPU上进行开发,需要改为下面的形式
CPU_ONLY := 1
# 根据系统安装好的OpenCV版本进行设置
OPENCV_VERSION := 3
# 根据实际的Python环境进行配置
PYTHON_INCLUDE := /usr/include/python2.7 \
                /usr/lib/python3.5/dist-packages/numpy/core/include
    
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

3.caffe编译

j代表多线程编译。

make all -j8
make alltest -j8
    
    
  • 1
  • 2

编译python版本的caffe

make pycaffe
    
    
  • 1

然后配置一下环境变量:

$sudo gedit ~/.bashrc

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

$sudo source ~/.bashrc
    
    
  • 1
  • 2
  • 3
  • 4
  • 5

4.问题

1.error: hdf5.h: No such file or directory
解决方案:将/usr/include/hdf5/serial添加到文件Makefile.config的INCLUDE_DIRS

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
    
    
  • 1
  • 2

修改为:

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
    
    
  • 1
  • 2

但是待会会出现一个新的错误,找不到-lhdf5-lhdf5_hl文件。

修改Makefile文件:

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
    
    
  • 1

修改为:

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

    
    
  • 1
  • 2

2.如果是虚拟环境的话,如何配置python?

修改Makefile.config:

PYTHON_INCLUDE := /usr/include/python2.7 \
                /usr/lib/python3.5/dist-packages/numpy/core/include
    
    
  • 1
  • 2

修改为:

PYTHON_INCLUDE := .env/versions/env270/include/python2.7 \
                .env/versions/env270/lib/python2.7/dist-packages/numpy/core/include
    
    
  • 1
  • 2

其中路径前缀需要根据自己实际的环境进行配置。

PYTHON_LIB:=/usr/lib
    
    
  • 1

修改为:

PYTHON_LIB:=.env/versions/env270/lib
    
    
  • 1
阅读更多
版权声明:转载请注明出处 http://blog.csdn.net/TwT520Ly https://blog.csdn.net/TwT520Ly/article/details/80445432
个人分类: Linux技术
(".MathJax").remove();




    MathJax.Hub.Config({
            "HTML-CSS": {
                    linebreaks: { automatic: true, width: "94%container" },
                    imageFont: null
            },
            tex2jax: {
                preview: "none"
            },
            mml2jax: {
                preview: 'none'
            }
    });


    (function(){
        var btnReadmore =
(".MathJax").remove();    MathJax.Hub.Config({            "HTML-CSS": {                    linebreaks: { automatic: true, width: "94%container" },                    imageFont: null            },            tex2jax: {                preview: "none"            },            mml2jax: {                preview: 'none'            }    });    (function(){        var btnReadmore =
("#btn-readmore"); if(btnReadmore.length>0){ var winH = (window).height();vararticleBox= ( w i n d o w ) . h e i g h t ( ) ; v a r a r t i c l e B o x = ("div.article_content"); var artH = articleBox.height(); if(artH > winH*2){ articleBox.css({ 'height':winH*2+'px', 'overflow':'hidden' }) btnReadmore.click(function(){ articleBox.removeAttr("style"); $(this).parent().remove(); }) }else{ btnReadmore.parent().remove(); } } })()
想对作者说点什么? 我来说一句
老中医说:饭后用一物,体重瘦到90斤! 塑业商贸 · 顶新
var width = $("div.recommend-box").outerWidth() - 48; NEWS_FEED({ w: width, h : 90, showid : 'GNKXx7', placeholderId: "ad1", inject : 'define', define : { imagePosition : 'left', imageBorderRadius : 0, imageWidth: 120, imageHeight: 90, imageFill : 'clip', displayImage : true, displayTitle : true, titleFontSize: 20, titleFontColor: '#333', titleFontFamily : 'Microsoft Yahei', titleFontWeight: 'bold', titlePaddingTop : 0, titlePaddingRight : 0, titlePaddingBottom : 10, titlePaddingLeft : 16, displayDesc : true, descFontSize: 14, descPaddingLeft: 14, descFontColor: '#6b6b6b', descFontFamily : 'Microsoft Yahei', paddingTop : 0, paddingRight : 0, paddingBottom : 0, paddingLeft : 0, backgroundColor: '#fff', hoverColor: '#ca0c16' } })
老中医说:男人多吃它,性生活时间延长5倍 国瑞兴邦 · 顶新
var width = $("div.recommend-box").outerWidth() - 48; NEWS_FEED({ w: width, h: 90, showid: 'Afihld', placeholderId: 'a_d_feed_0', inject: 'define', define: { imagePosition: 'left', imageBorderRadius: 0, imageWidth: 120, imageHeight: 90, imageFill: 'clip', displayImage: true, displayTitle: true, titleFontSize: 20, titleFontColor: '#333', titleFontFamily: 'Microsoft Yahei', titleFontWeight: 'bold', titlePaddingTop: 0, titlePaddingRight: 0, titlePaddingBottom: 10, titlePaddingLeft: 16, displayDesc: true, descFontSize: 14, descPaddingLeft: 14, descFontColor: '#6b6b6b', descFontFamily: 'Microsoft Yahei', paddingTop: 0, paddingRight: 0, paddingBottom: 0, paddingLeft: 0, backgroundColor: '#fff', hoverColor: '#ca0c16' } })
# Contributions si…

u010598445 u010598445

2016-11-12 11:42:29

阅读数:2250

scrolling="no">
id="iframeu3394176_0" src="https://pos.baidu.com/bcqm?conwid=800&conhei=100&rdid=3394176&dc=3&di=u3394176&dri=0&dis=0&dai=7&ps=4457x662&enu=encoding&dcb=___adblockplus&dtm=HTML_POST&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1531185127055&ti=%E3%80%90Caffe%E3%80%91Linux%E9%85%8D%E7%BD%AEPycaffe%20-%20CSDN%E5%8D%9A%E5%AE%A2&ari=2&dbv=0&drs=3&pcs=1908x636&pss=1908x4560&cfv=0&cpl=0&chi=4&cce=true&cec=UTF-8&tlm=1531185127&prot=2&rw=636&ltu=https%3A%2F%2Fblog.csdn.net%2Ftwt520ly%2Farticle%2Fdetails%2F80445432&ecd=1&uc=1920x988&pis=-1x-1&sr=1920x1080&tcn=1531185127&qn=f9ea1af9c21b8517&tt=1531185126735.599.599.599" vspace="0" hspace="0" scrolling="no" width="800" height="100" align="center,center">

没有更多推荐了,返回首页

("a.flexible-btn").click(function(){ ("a.flexible-btn").click(function(){ (this).parents('div.aside-box').removeClass('flexible-box'); $(this).remove(); })

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值