zoukankan      html  css  js  c++  java
  • ubuntu16.04安装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 libatlas-base-dev
    sudo apt-get install python-dev
    sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

    接下来,下载caffe

    首先安装下载工具

    sudo apt-get install git

    然后下载caffe包

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

    进入caffe目录

    cd caffe/

    进入里面的PYTHON文件夹,然后输入

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

    这里出现问题:requirements.txt: 没有那个文件或目录

    解决方案:

    pip freeze >requirements.txt
    pip install -r requirements.txt

    创建一个副本就好了。

    安装caffe

    cp Makefile.config.example Makefile.config

    首先,打开makefile.config文件,在CPU_ONLY := 1前面的#要去掉.    (因为仅在CPU下跑Caffe

     然后,在其中找到如下内容,两个路径要改成这样:(添加后面的两个hdf5的路径, 否则编译时报hdf5错误)

    # Whatever else you find you need goes here.

    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial

    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial

    如果,你想再python3.5中安装caffe,在该文件夹下将

    PYTHON_INCLUDE := /usr/include/python2.7
    /usr/local/lib/python2.7/dist-packages/numpy/core/include用#引掉,同时,将

    PYTHON_INCLUDE := /usr/include/python3.5m
    /usr/lib/python3.5/dist-packages/numpy/core/include前得#号去掉即可。

    下面进行make

    make pycaffe

    这部分有个问题,我自己是两种解决方法都试了最后才好使,大家自己都试试最好。

    问题:报了错:fatal error: numpy/arrayobject.h没有那个文件或目录

    解决方案:sudo apt-get install python-numpy

    再不行就Makefile.config找到PYTHON_INCLUDE,发现有点不同:

    PYTHON_INCLUDE := /usr/include/python2.7
            /usr/lib/python2.7/dist-packages/numpy/core/include

    要加一个local,变成: 

    PYTHON_INCLUDE := /usr/include/python2.7
            /usr/local/lib/python2.7/dist-packages/numpy/core/include
    make pycaffeok

    接下来继续make

    make all
    
    make test
    
    make runtest

    配置python

    sudo pip install -r python/requirements.txt

    接下来是测试

    装好了,希望对大家有帮助。

  • 相关阅读:
    WRF WPS预处理
    CVS安装
    Linux窗口最小化消失,任务栏上无法找到的解决方法
    NCARG安装配置出现error while loading shared libraries: libg2c.so.0问题额解决办法
    Netcdf安装
    Embedding R-generated Interactive HTML pages in MS PowerPoint(转)
    The leaflet package for online mapping in R(转)
    Some 3D Graphics (rgl) for Classification with Splines and Logistic Regression (from The Elements of Statistical Learning)(转)
    What does a Bayes factor feel like?(转)
    Weka算法介绍
  • 原文地址:https://www.cnblogs.com/Fiona-Y/p/Fiona.html
Copyright © 2011-2022 走看看