菜鸟跑通caffe(三)——编译NVIDIA/caffe-0.13/0.14+digist

下载地址:
caffe-0.13和digits-2.2
https://github.com/NVIDIA/caffe/blob/caffe-0.13/docs/installation.md
https://github.com/NVIDIA/DIGITS/blob/digits-2.2/docs/InstallCaffe.md

Installation

Prior to installing, have a glance through this guide and take note of the details for your platform. We install and run Caffe on Ubuntu 14.04 and 12.04, OS X 10.10 / 10.9 / 10.8, and AWS. The official Makefile and de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde> build are complemented by an automatic CMake build from the community.

  • Prerequisites
  • Compilation
  • Hardware
  • Platforms: Ubuntu guide, OS X guide, and RHEL / CentOS / Fedora guide

When updating Caffe, it's best to de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >make cleande> before re-compiling.

Prerequisites

Caffe has several dependencies.

  • CUDA is required for GPU mode.
    • library version 7.0 and the latest driver version are recommended, but 6.* is fine too
    • 5.5, and 5.0 are compatible but considered legacy
  • BLAS via ATLAS, MKL, or OpenBLAS.
  • Boost >= 1.55
  • OpenCV >= 2.4 including 3.0
  • de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >protobufde>, de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >glogde>, de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >gflagsde>
  • IO libraries de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >hdf5de>, de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >leveldbde>, de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >snappyde>, de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >lmdbde>

Pycaffe and Matcaffe interfaces have their own natural needs.

  • For Python Caffe: de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Python 2.7de> or de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Python 3.3+de>, de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >numpy (>= 1.7)de>, boost-provided de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >boost.pythonde>
  • For MATLAB Caffe: MATLAB with the de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >mexde> compiler.

cuDNN Caffe: for fastest operation Caffe is accelerated by drop-in integration of NVIDIA cuDNN. To speed up your Caffe models, install cuDNN then uncomment the de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >USE_CUDNN := 1de> flag in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde> when installing Caffe. Acceleration is automatic. For now cuDNN v1 is integrated but see PR #1731 for v2.

CPU-only Caffe: for cold-brewed CPU-only Caffe uncomment the de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >CPU_ONLY := 1de> flag in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde> to configure and build Caffe without CUDA. This is helpful for cloud or cluster deployment.

CUDA and BLAS

Caffe requires the CUDA de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >nvccde> compiler to compile its GPU code and CUDA driver for GPU operation. To install CUDA, go to the NVIDIA CUDA website and follow installation instructions there. Install the library and the latest standalone driver separately; the driver bundled with the library is usually out-of-date. Warning! The 331.* CUDA driver series has a critical performance issue: do not use it.

For best performance, Caffe can be accelerated by NVIDIA cuDNN. Register for free at the cuDNN site, install it, then continue with these installation instructions. To compile with cuDNN set the de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >USE_CUDNN := 1de> flag set in your de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde>.

Caffe requires BLAS as the backend of its matrix and vector computations. There are several implementations of this library. The choice is yours:

  • ATLAS: free, open source, and so the default for Caffe.
  • Intel MKL: commercial and optimized for Intel CPUs, with a free trial and student licenses.
    1. Install MKL.
    2. Set de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >BLAS := mklde> in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde>
  • OpenBLAS: free and open source; this optimized and parallel BLAS could require more effort to install, although it might offer a speedup.
    1. Install OpenBLAS
    2. Set de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >BLAS := opende> in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde>

Python and/or MATLAB Caffe (optional)

Python

The main requirements are de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >numpyde> and de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >boost.pythonde> (provided by boost). de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >pandasde> is useful too and needed for some examples.

You can install the dependencies with

de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; background- initial; background-repeat: initial initial;"  >for req in $(cat requirements.txt); do pip install $req; done
de>

but we suggest first installing the Anaconda Python distribution, which provides most of the necessary packages, as well as thede style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >hdf5de> library dependency.

To import the de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >caffede> Python module after completing the installation, add the module directory to your de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >$PYTHONPATHde> byde style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >export PYTHONPATH=/path/to/caffe/python:$PYTHONPATHde> or the like. You should not import the module in thede style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >caffe/python/caffede> directory!

Caffe's Python interface works with Python 2.7. Python 3.3+ should work out of the box without protobuf support. For protobuf support please install protobuf 3.0 alpha (https://developers.google.com/protocol-buffers/). Earlier Pythons are your own adventure.

MATLAB

Install MATLAB, and make sure that its de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >mexde> is in your de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >$PATHde>.

Caffe's MATLAB interface works with versions 2014a/b, 2013a/b, and 2012b.

Windows

There is an unofficial Windows port of Caffe at niuzhiheng/caffe:windows. Thanks @niuzhiheng!

Compilation

Now that you have the prerequisites, edit your de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde> to change the paths for your setup The defaults should work, but uncomment the relevant lines if using Anaconda Python.




最后一行的-nv说明这是NVIDIA的caffe

更改makefile:


这是由于我们有多个cudnn版本造成

de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; background- initial; background-repeat: initial initial;"  >cp Makefile.config.example Makefile.config
# Adjust Makefile.config (for example, if using Anaconda Python)
make all
make test
make runtest
de>
  • For cuDNN acceleration, you should uncomment the de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >USE_CUDNN := 1de> switch in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde>.
  • For CPU-only Caffe, uncomment de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >CPU_ONLY := 1de> in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde>.

To compile the Python and MATLAB wrappers do de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >make pycaffede> and de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >make matcaffede> respectively. Be sure to set your MATLAB and Python paths in de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde> first!

Distribution: run de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >make distributede> to create a de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >distributede> directory with all the Caffe headers, compiled libraries, binaries, etc. needed for distribution to other machines.

Speed: for a faster build, compile in parallel by doing de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >make all -j8de> where 8 is the number of parallel threads for compilation (a good choice for the number of threads is the number of cores in your machine).

Now that you have installed Caffe, check out the MNIST tutorial and the reference ImageNet model tutorial.

CMake Compilation

In lieu of manually editing de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgba(0, 0, 0, 0.0392157);" >Makefile.configde> to configure the build, Caffe offers an unofficial CMake build thanks to @Nerei, @akosiorek, and other members of the community. It requires CMake version >= 2.8.7. The basic steps are as follows:

de style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0px; margin-top: 0px; margin-bottom: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; background- initial; background-repeat: initial initial;"  >mkdir build
cd build
cmake ..
make all
make runtest
de>

See PR #1667 for options and details.

Hardware

Laboratory Tested Hardware: Berkeley Vision runs Caffe with K40s, K20s, and Titans including models at ImageNet/ILSVRC scale. We also run on GTX series cards (980s and 770s) and GPU-equipped MacBook Pros. We have not encountered any trouble in-house with devices with CUDA capability >= 3.0. All reported hardware issues thus-far have been due to GPU configuration, overheating, and the like.

CUDA compute capability: devices with compute capability <= 2.0 may have to reduce CUDA thread numbers and batch sizes due to hardware constraints. Your mileage may vary.

Once installed, check your times against our reference performance numbers to make sure everything is configured properly.

Ask hardware questions on the caffe-users group.

鉴于cudnn多版本冲突,我们采用已经安装的cudnn-v4版本重新安装。



下载地址:
caffe-0.14和digits-3.0
https://github.com/NVIDIA/caffe/blob/caffe-0.13/docs/installation.md
https://github.com/NVIDIA/DIGITS/tree/digits-3.0

可以看到digits-3.0对应caffe-0.14,当然digits是向前兼容的。所以下载最新版本也行。
安装说明看这个:





检查依赖库:

最后,开始编译:

 
      
  1. de >cmake ..de>
后:


最后编译:


报错:

解决:
添加cnmem



将lib和include放到cuda文件下。

 
       
  1. de >$ sudo ln -sf /usr/local/cuda/lib64/libcnmem.so.1.0.0 /usr/local/cuda/lib64/libcnmem.so.1de>
  2. de >de>
  3. de >$ sudo ln -sf /usr/local/cuda/lib64/libcnmem.so.1 /usr/local/cuda/lib64/libcnmem.sode>
和我类似的问题:



最后生成了但是还有一些错误。

发现/usr/local/cuda/lib64下libcudnn.so.4.0.7的权限好像不对
更改权限:
 
        
  1. de >sudo chmod 755 libcudnn.so.4.0.7de>
继续编译
 
        
  1. de >make all --jobs=10 2>&1|tee make.logde>
仍然报错,可能是冲突了

将这几个文件下cudnn其他版本删掉,终于成功了,泪流满面啊!!!
总而言之:这种undefine reference的错误八成都是因为cudnn多版本冲突造成的。






注意make all里面并没有make pycaffe和matcaffe,这都需要额外编译的。

尤其是使用digits时候,digits是调用pycaffe,所以必须编译pycaffe,否则会报以下错误

 
     
  1. de >make all --jobs=10 2>&1|tee make.logde>
  2. de >make test --jobs=10 2>&1|tee make.logde>
  3. de >make runtest --jobs=10 2>&1|tee make.logde>
  4. de >make pycaffe --jobs=10 2>&1|tee make.logde>
  5. de >make matcaffe --jobs=10 de>2>&1|tee make.log
  6. de style="color: rgb(190, 190, 197);" >make distribute --jobs=10 de>2>&1|tee make.log





测试下是否安装成功:
注意必须export或者在.bashrc里面写上。

如果提示cannot open shared object file,则是找不到lib,将lib路径加入./.bashrc


matlab没有安装成功。原因在于gcc版本不对,必须使用4.7.x才行。
使用mnist数字检测进行测试:

de style="margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; vertical-align: baseline;"  >cd $CAFFE_ROOT
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.de>
de style="margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; vertical-align: baseline;"  >
de>
de style="margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; vertical-align: baseline;"  >cd $CAFFE_ROOT
./examples/mnist/train_lenet.shde>







再使用caffe + digits训练下mnist:

下载mnist数据集








全部设置好后,点击"create" 按钮,开始生成lmdb数据。

右击右边Models模块的” Images" 按钮 ,选择“classification"





出现问题:
1) Couldn't import dot_parser, loading of dot files will not be possible

这是  dot-parser 所依赖的模块  pyparsing  从  1.X 升级到 2.X 的变化所导致的,所以呢,安回旧的版本就可以了。 
pip install pydot pyparsing==1.5.7 

2) 使用 Python   进行caffe 数据可视化的时候可能会遇到下面的错误:

No to_python (by-value) converter found for C++ type: boost::shared_ptr
No to_python (by-value) converter found for C++ type: boost::shared_ptr
No to_python (by-value) converter found for C++ type: boost::shared_ptr

上面的错误是由于boost-1.60.0 引起的,如果是boost-1.59.0,就没有上面问题,但是很容易无意中升级安装包的时候把boost也升级了,就会造成上面的问题。

解决的办法是在caffe/python/caffe/中对 _caffe.cpp 进行相应的修改:(参考:https://github.com/BVLC/caffe/issues/3494)


// Fix for caffe pythonwrapper for boost 1.6
boost::python::register_ptr_to_python > >();

boost::python::register_ptr_to_python > >();

boost::python::register_ptr_to_python > >();

// End fix


然后回到caffe 目录, 重新编译pycaffe:




来自为知笔记(Wiz)

你可能感兴趣的:(caffe)