• caffe-ssd


    1.安装依赖

    1 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
    2 sudo apt-get install --no-install-recommends libboost-all-dev
    3 sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
    4 sudo apt-get install libatlas-base-dev
    5 sudo apt-get install python-dev

    sudo apt-get install libopenblas-dev
      1.   1)sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage  
      2.     python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags  
      3.     Cython ipython 
      4.         2)sudo apt-get update 
      5.         3)切换到caffe目录下,执行: 
      6.              python 
      7.              import caffe
     sudo pip install protobuf
     sudo apt-get install liblapack3

    2、下载caffe 

    https://github.com/BVLC/caffe

    3.编译Caffe 
    (1)切换到Caffe所在目录

    cp Makefile.config.example Makefile.config

    (2)修改配置文件Makefile.config

    • CPU_ONLY := 1
    • 配置引用文件(解决新版本下,HDF5的路径问题)
    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
    BLAS := atlas

    opencv问题:

    1.$ pkg-config --modversion opencv查看是否安装

    2. Makefile文件中,找到LIBRARIES(在PYTHON_LIBRARIES := boost_python python2.7 前一行)

    LIBRARIES += glog gflags protobuf leveldb snappy lmdb boost_system hdf5_hl hdf5 m opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio

    3.将Makefile.config中OPENCV_VERSION := 3取消注释;

    cuda环境变量

    sudo vim ~/.bashrc
    export PATH=/usr/local/cuda-9.0/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH
    source ~/.bashrc

    (3)编译 Caffe

    make all -j8
    make test -j8
    make runtest -j8

    4.编译Python接口 
    Caffe拥有pythonC++shell接口,在Caffe使用python特别方便,在实例中都有接口的说明。

    sudo apt-get install python-pip
    • 执行安装依赖
    cd ~/caffe
    sudo apt-get install gfortran
    cd ./python for req in $(cat requirements.txt); do pip install $req; done

    安装完成以后,再次回到caffe根目录我们可以执行:

    sudo pip install -r python/requirements.txt

    就会看到,安装成功的,都会显示Requirement already satisfied, 没有安装成功的,会继续安装。

    • 编译python接口
    make pycaffe -j8

    --结果显示ALL TESTS PASSED就安装好了!

    • 运行python结构
    复制代码
    $ python2.7
    Python 2.7.12 (default, Jul  1 2016, 15:12:24) 
    [GCC 5.4.0 20160609] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import caffe
    >>> 
    复制代码

    如果没有报错,说明caffe安装全部完成(注意:要进入caffe/python再执行python命令,否则import caffe会提示找不到caffe)!

    5.在Mnist运行Lenet

    • 获取数据源
    ./data/mnist/get_mnist.sh
    ./examples/mnist/create_mnist.sh
    • 因为是CPU运行,所以修改在examples文件下的Mnist下的lenet_solver.prototxt中的solver_mode:CPU
    solver_mode: CPU
    • 训练模型
    ./examples/mnist/train_lenet.sh

    添加python目录

    vi ~/.bashrc
    export PYTHONPATH=/home/username/caffe/python:$PYTHONPATH
    source ~/.bashrc

  • 相关阅读:
    Redhat7 安装 yum源(亲测有效)
    Win10开启FTP与配置(完整无错版)
    DataStage中Transformer的函数大全
    缺省值是什么
    扫描线
    2021.07.02笔记-DP
    2021.07.02-2膜你赛
    2021.07.01膜你赛
    2021.06.21模拟赛
    2021.06.09模拟赛
  • 原文地址:https://www.cnblogs.com/crazybird123/p/9123055.html
Copyright © 2020-2023  润新知