Ubuntu16.04+Anaconda+caffe(Only CPU)
来源:互联网 发布:电视视频通话软件 编辑:程序博客网 时间:2024/05/17 08:47
序言:作者使用的是Ubuntu16.04+Anaconda+caffe(Only CPU),自己首先在win10下面安装caffe。好不容易成功,发现需要使用的demo是在ubuntu下面运行的,后来又琢磨啦好久,走过很多弯路,终于安装完成。
CUDA:
OpenCV:
Anaconda:
测试caffe:
1:Anaconda的安装
- 1.下载地址:https://www.continuum.io/downloads
下载Linux版本,根据Python版本选择相应的。 - 2.将下载的安装包放到某目录下,然后执行
sudo bash 你的目录/Anaconda2-4.2.0-Linux-x86_64.sh
读完license,回复个yes
输入安装地址/usr/local/anaconda2
安装路径放到/home/xx/.bashrc , 回复yes
路径添加到path:source ~/.bashrc
运行python,发现已经安装成功anaconda
输入:python
作者使用的是IDE 是Pycharm,以下为pycharm的默认设置
- 3.改变pycharm解释器为-anaconda python解释器
1) 打开pycharm,依次点击 file->Settings(如果以后想所有项目都用anaconda python解释器就点击Default settings) - >Project: xx - >Project Interpreter
2) 点击小齿轮,点击弹出来的add local
2:caffe的安装
- 1.安装protobuf,leveldb,snappy,OpenCV,hdf5, protobuf compiler andboost:
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compilersudo apt-get install --no-install-recommends libboost-all-dev
- 2.安装gflags,glogs ,lmdb andatlas.
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev sudo apt-get install libatlas-base-dev
- 3.下载Caffe
使用Git直接下载Caffe非常简单,或者去https://github.com/BVLC/caffe下载git clone git://github.com/BVLC/caffe.git
切换到caffe的目录:cd caffe
- 4.打开Makefile.config。
将下面代码修改成:
将下面代码修改成:# CPU-only switch (uncomment to build without GPU support).CPU_ONLY := 1 ##注释去掉即可
大致做的事情就是添加anaconda的python路径,注释掉系统本身自带的python路径。# NOTE: this is required only if you will compile the python interface.# We need to be able to find Python.h and numpy/arrayobject.h.#PYTHON_INCLUDE := /usr/include/python2.7 \ ###注释掉# /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:# Verify anaconda location, sometimes it's in root.ANACONDA_HOME := $(usr/local)/anaconda2 ##取消注释,并且修改(XXX)内为自己anaconda的安装路径PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ ##取消注释$(ANACONDA_HOME)/include/python2.7 \$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
# Uncomment to use Python 3 (default is Python 2) # PYTHON_LIBRARIES := boost_python3 python3.5m# PYTHON_INCLUDE := /usr/include/python3.5m \ ##注释掉系统自带的# /usr/lib/python3.5/dist-packages/numpy/core/include# We need to be able to find libpythonX.X.so or .dylib.#PYTHON_LIB := /usr/lib ##注释掉系统自带的 PYTHON_LIB := $(ANACONDA_HOME)/lib ##取消注释
- 5.接下来,Make Caffe:
作者在此处出现如下错误:make all -j8make test -j8make runtest -j8
解决方案为:http://blog.csdn.net/xiaxiazls/article/details/52039473In file included from src/caffe/util/hdf5.cpp:1:0:./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: 没有那个文件或目录compilation terminated.Makefile:581: recipe for target '.build_release/src/caffe/util/hdf5.o' failedmake: *** [.build_release/src/caffe/util/hdf5.o] Error 1
修改Makefile.config为:
修改Makefile为(caffe文件里面,与上者区分开):# 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 /usr/lib/x86_64-linux-gnu/hdf5/serial
问题:ifneq ($(CPU_ONLY), 1)INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)LIBRARY_DIRS += $(CUDA_LIB_DIR)LIBRARIES := cudart cublas curandendif##修改下面代码,对照添加上去LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
解决方案:/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
原因:make cleanexport CPLUS_INCLUDE_PATH=/usr/include/python2.7make all -j8
python路径都改为了anaconda的路径,但是CPLUS的path没有设置,系统中我也没把aneconda设置成默认的python导致的.
错误:
In file included from src/caffe/util/signal_handler.cpp:7:0:./include/caffe/util/signal_handler.h:4:34: fatal error: caffe/proto/caffe.pb.h: 没有那个文件或目录#include “caffe/proto/caffe.pb.h”
解决方案:sudo apt-get install –no-install-recommends libboost-all-dev
(这个命令在安装依赖库的时候,不能漏了)
问题:.build_release/src/caffe/proto/caffe.pb.h:22:35: fatal error: google/protobuf/arena.h: 没有那个文件或目录
解决方案:
重新
make cleanmake all -j8make test -j8make runtest -j8
出现运行最后一项后出现如下界面,表示安装完成。
运行成功画面
配置pycaffe:
安装依赖项:测试caffe
参考教程:
http://blog.csdn.net/sinat_23137713/article/details/53018104
http://blog.csdn.net/u010402483/article/details/51506616
http://blog.csdn.net/firethelife/article/details/51926754
http://blog.csdn.net/xiaxiazls/article/details/52039473
作者:东逝水_Derek
链接:http://www.jianshu.com/p/a71866734d51
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
- Ubuntu16.04+Anaconda+caffe(Only CPU)
- Ubuntu16.04+Caffe(CPU Only)
- Ubuntu16.04安装Caffe(CPU Only)
- Ubuntu16.04+caffe+Opencv3+Python(CPU ONLY)
- Ubuntu16.04中caffe安装(only cpu)
- Caffe学习(1) Ubuntu16.04 Caffe安装(CPU Only)
- Caffe学习日记之安装 Ubuntu16.04 cpu only
- Ubuntu16.04配置caffe和pycaffe(cpu only)
- Caffe学习(1):Ubuntu16.04上Caffe配置安装(Only CPU)
- Caffe学习(1):Ubuntu16.04上Caffe配置安装(Only CPU)
- ubuntu16.04+caffe(CPU only)&hdf5.h: No such file or directory
- caffe安装及python接口配置(ubuntu16.04 only cpu)
- caffe(only CPU)+Ubuntu16.04 环境配置(内附mnist测试)
- caffe在ubuntu16.04安装遇到的问题及解决方法(CPU ONLY)
- ubuntu16.04安装caffe2(CPU only)
- caffe+CPU︱虚拟机+Ubuntu16.04+CPU+caffe安装笔记
- Caffe_Linux学习笔记(一)基于Ubuntu16.04+CPU only+Python2.7环境下的Caffe配置
- ubuntu16.04配置caffe(CPU版)
- 时间复杂度
- 奇袭(raid)(分治)
- 挤奶网格
- 如何申请百度API Key
- js-cookie方法封装
- Ubuntu16.04+Anaconda+caffe(Only CPU)
- box-sizing
- CGAL window 10安装、Demo使用步骤以及问题解决记录
- Protel99SE的使用
- react-native image 设置默认图片
- 标题
- lua-base64-encode
- 我的Markdown的利器——Markdown Here、有道云笔记、iPic
- Calendar 类的应用