zoukankan      html  css  js  c++  java
  • 来杯Caffe——在ubuntu下安装Caffe框架并测试

    Caffe是一种深度学习框架...blablabla......

    Caffe要在ubuntu下安装

    1. 安装依赖

    sudo apt-get install libatlas-base-dev
    sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev
    sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler

    2. 下载Caffe

    # 从自己的git仓库下更快,我的仓库地址 https://git.oschina.net/rongfangliu/caffe.git
    git clone https://github.com/BVLC/caffe.git cd caffe cp Makefile.config.example Makefile.config

    3. 修改生成时配置文件

    修改Makefile.config文件的第8行,将CPU_ONLY的注释打开,只使用CPU(当然是因为穷diao如我没有N卡)

    # Adjust Makefile.config (for example, if using Anaconda Python)
    CPU_ONLY := 1 #这里原来是# CPU_ONLY := 1,去掉注释,只使用CPU

    Makefile.config文件的第85行,添加/usr/include/hdf5/serial/INCLUDE_DIRS,也就是把下面第一行代码改为第二行代码。

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

    Makefile文件的第181行,把 hdf5_hl 和hdf5修改为hdf5_serial_hlhdf5_serial,也就是把下面第一行代码改为第二行代码。

    LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
    
    LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

    4. 编译

    make all    # 编译
    make pycaffe   # 编译python接口

    5. 跑下基本测试

    make test
    make runtest

    运行时会出现一堆run OK,至此Caffe已经装好了。

    ============================================= 我是分割线 ===============================================

    下面的是在Caffe上跑经典的手写字符识别网络Minst

    cd caffe
    sh data/mnist/get_mnist.sh        # 从lecun网站上下载minst数据包
    sh examples/mnist/create_mnist.sh   # 创建minst网络
    

    接着打开examples/mnist/lenet_solver.prototxt

    # 修改 solver_mode 为 CPU

    然后训练网络

    sh examples/mnist/train_lenet.sh   # 运行网络训练

    最后得到一个lenet_iter_5000.caffemodellenet_iter_10000.caffemodel,里面包含了这次训练的特征数据,可以用到以后的识别中。

     ============================================= 我是分割线 ===============================================

    1、caffe编译出现问题

    finenet.bin一堆_D.place()xx函数未定义,在网上搜索没找到重点,尝试使用cmake,然后再make all就好了

    2、尝试导入caffe

    出现no module caffe

    sudo gedit /etc/profile

    export PYTHONPATH=/home/liurf/program_files/caffe/python:$PYTHONPATH

    3、再尝试导入

    出现ImportError: /home/liurf/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/liurf/program_files/caffe/python

    错误,输入命令

    export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH

    4、再尝试导入,出现

    ImportError: No module named google.protobuf.internal

    搜索了下发现是protobuf没有安装,于是下载,安装,好了

    5、opencv

    万一自己安装的出现各种so报错,可以使用pip install opencv-python安装

  • 相关阅读:
    使用IDEA模拟git命令使用的常见场景
    解决 No converter found for return value of type: class java.util.ArrayList
    Connections could not be acquired from the underlying database! ### The error may exist in mapper/BookMapper.xml
    There is no PasswordEncoder mapped for the id "null"
    The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone
    MySQL错误:2003-Can't connect to MySQL server on 'localhost'(10061 "unknown error")
    镜像源
    读书笔记 Week5 2018-4-5
    [第五周课后作业] 软件创新分析
    C#入门学习笔记
  • 原文地址:https://www.cnblogs.com/rongfangliu/p/6254548.html
Copyright © 2011-2022 走看看