zoukankan      html  css  js  c++  java
  • Caffe安装教程(原创)

    转载请注明地址

    说明:本文档参考自Caffe官网的安装说明,http://caffe.berkeleyvision.org/installation.html

    如果对安装过程中,需要用到的依赖不明,请自行百度其作用。Ubuntu系统的安装请自行百度。 

    1.安装环境

    硬件:Intel E3 CPUNVIDIA  GTX960 GPU; 操作系统:Ubuntu14.04

    2.依赖安装

    接下来的安装全部使用linux命令行操作

    (1)通用依赖 

    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 

    (2)CUDA安装

    可以使用apt-get方式,或者去官网下载linux系统下的.run包进行离线安装。由于apt-get指令拿到的软件包通常不是最新的,官网推荐使用.run包的方式进行离线安装。

    对于没有GPU的同学来说,可以跳过这一步之后在编译源码时配置CPU-ONLY)。

    1)下载CUDA.run

    地址:https://developer.nvidia.com/cuda-downloads 

    根据自己的OSCPU架构选择.run包并下载

    2)退出桌面环境

    使用键盘Ctrl+Alt+F1,系统退出桌面版,进入命令行模式。

    注意:此时有些系统会遇到黑屏问题。解决方法:切回桌面版本(Ctrl+Alt+F7),修改/etc/default/grub文件中GRUB_CMDLINE_LINUX_DEFAULT的值为nomodeset,更新grub(sudo update-grub),重启电脑(或者重启电脑,在启动时进入grub设置中,将倒数第2行的roquiet splash 后面空格添加nomodesetF10启动系统,然后再按ctrl+alt+F1发现可以正常进入字符界面了)。

    (安装时遇到这个问题,我通过后一种方式解决) 

    3)退出X Windows桌面环境

    sudo stop lightdm

    4)安装CUDA .run

    .run包加上可执行权限:

    chmod +x cuda_7.5.18_linux.run

    执行.run包:

    ./cuda_7.5.18_linux.run 

    5)返回X Windows桌面环境

    sudo start lightdm
    Ctrl+Alt+F7

    6)cuDNN 安装(可选)

    如果使用 cuDNN 优化神经网络, 需要安装 cudnn-v5.0 以上版本。 该软件的安装非常简单。

    tar -xzvf cudnn-7.5-linux-x64-v5.0-ga.tgz
    cd cudnn-7.5-linux-x64-v5.0
    sudo cp lib* /usr/local/cuda/lib64/
    sudo cp cudnn.h /usr/local/cuda/include/

    (3)BLAS

    sudo apt-get install libatlas-base-dev

    (4)Python

    如果使用默认Python的方式进行Caffe开发,则需要安装python开发包。

    sudo apt-get install python-dev

    (5)兼容性说明 

    操作系统

    版本

    兼容性说明

    Ubuntu

    16.04

    CUDA8是被需要的

    14.04

    sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

    12.04

    需要手动安装依赖(如下)

     

    如果是Ubuntu12.04,需要手动安装兼容性依赖,如下:

    wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz
    tar zxvf glog-0.3.3.tar.gz
    cd glog-0.3.3
    ./configure
    make && make install
    # gflags
    wget https://github.com/schuhschuh/gflags/archive/master.zip
    unzip master.zip
    cd gflags-master
    mkdir build && cd build
    export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1
    make && make install
    # lmdb
    git clone https://github.com/LMDB/lmdb
    cd lmdb/libraries/liblmdb
    make && make install

    3.编译Caffe源代码并安装

    Caffe源码支持make编译,或者CMake方式进行编译。编译前请确认已经安装好了gcc工具链(sudo apt-get install build-essential),如果使用CMake构建工程,请确认安装好CMake

    (1)下载Caffe源码

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

    或者在github官网搜索Caffe,选择需要的分支然后Zip打包下载。

    (2)Make编译源码

    说明1

    Configure the build by copying and modifying the example Makefile.config for your setup. The defaults should work, but uncomment the relevant lines if using Anaconda Python.

    以下为命令行

    cp Makefile.config.example Makefile.config
    # Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
    make all
    make test
    make runtest 

    说明2

    For CPU & GPU accelerated Caffe, no changes are needed.

    For cuDNN acceleration using NVIDIA’s proprietary cuDNN software, uncomment the USE_CUDNN := 1 switch in Makefile.config. cuDNN is sometimes but not always faster than Caffes GPU acceleration.

    For CPU-only Caffe, uncomment CPU_ONLY := 1 in Makefile.config. 

    (3)CMake方式构建工程并编译

    根据需要可以配置Makefile.config

    mkdir build
    cd build
    cmake ..
    make all
    make install
    make runtest 

    如果编译没有报Error,在runtest时一切OK,那么说明安装完成。可以开始Caffe的第一个小例子MNIST

  • 相关阅读:
    基于springboot1.5.9整合shiro时出现静态文件找不到的问题
    基于springboot多模块项目使用maven命令打成war包放到服务器上运行的问题
    关于使用map存放数据乱序”问题“
    springboot1.5.9整合websocket实现实时显示的小demo
    SpringBoot1.5.10.RELEASE配置mybatis的逆向工程
    SpringBoot1.5.10.RELEASE整合druid时,在druid monitor界面出现(*) property for user to setup
    SpringBoot1.5.10.RELEASE整合druid
    SpringBoot1.5.10.RELEASE项目如何在tomcat容器中运行
    JS学习-01
    List,Set,Map在java.util包下都是接口 List有两个实现类:ArrayList和LinkedList Set有两个实现类:HashSet和LinkedHashSet AbstractSet实现了Set
  • 原文地址:https://www.cnblogs.com/fang-io/p/5889017.html
Copyright © 2011-2022 走看看