Caffe Ubuntu Compilation

Source: Internet
Author: User

First, installation environment

System: Ubuntu 16.04 x64_64

cuda:7.5
cudnn:7.5

General dependencies:

sudo Install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-Compiler  sudoinstall --no-install-recommends Libboost-all-dev

Openblas:

sudo Install Libatlas-base-dev Libopenblas-dev

Python:

Download Miniconda python 2.7 to https://conda.io/miniconda.html and install it.
After the installation is successful, install Dumpy: Start the terminal, enter
Install dumpy

Remaining dependencies:

sudo Install Libgflags-dev libgoogle-glog-dev Liblmdb-dev

Second, compile

Go to the Caffe directory, copy the Makefile.config.example file to Makefile.config, and read as follows:

# # Refer to http://caffe.berkeleyvision.org/installation.html# Contributions simplifying and improving our build system is welcome!# CuDNN Acceleration switch (uncomment to build with CuDNN). USE_CUDNN: = 1 # CPU-Only switch (uncomment to build without GPU support). # Cpu_only:=1# Uncomment to disable IO dependencies and corresponding data layers# USE_OPENCV:=0# Use_leveldb:=0# Use_lmdb:=0# Uncomment to allow Mdb_nolock when reading LMDB files ( onlyifnecessary) # You should no set this flagifYou'll be reading Lmdbs with any# possibility of simultaneous read andWrite# Allow_lmdb_nolock:=1# UncommentifYou're using OpenCV 3# opencv_version: =3# To customize your choice of compiler, uncomment and set the following.# n.b. The default forLinux is g++ and the default forOSX is clang++# Custom_cxx:= g++# CUDA directory contains bin/And lib/directories that we need. Cuda_dir:=/usr/local/cuda# on Ubuntu14.04,ifCuda Tools is installed via#"sudo apt-get install Nvidia-cuda-toolkit"  ThenUse this instead:# cuda_dir:= /usr# cuda Architecture setting:going with all of them.# for CUDA<6.0, comment The *_50 through *_61 lines forcompatibility.# for CUDA<8.0, comment The *_60 and *_61 lines forcompatibility. Cuda_arch:=-gencode arch=compute_20,code=sm_20-gencode arch=compute_20,code=sm_21-gencode arch=compute_30,code=sm_30-gencode arch=compute_35,code=sm_35-gencode arch=compute_50,code=sm_50-gencode arch=compute_52,code=sm_52-gencode arch=compute_60,code=sm_60-gencode arch=compute_61,code=sm_61-gencode arch=compute_61,code=compute_61# BLAS choice:# Atlas forATLAS (default) # MKL formkl# Open forOpenblasblas:=atlas# Custom (MKL/atlas/Openblas) include and Lib directories.# Leave commented to accept the defaults forYour choice of blas# (whichshould work)!# Blas_include:=/path/to/your/blas# blas_lib:=/path/to/your/blas# Homebrew puts OpenblasinchA directory that's not on the standard search path# blas_include:= $ (Shell brew--prefix openblas)/include# blas_lib:= $ (Shell brew--prefix openblas)/lib# This was required onlyifYou'll compile the matlab interface.# matlab directory should contain the MEX binaryinch/bin.# Matlab_dir:=/usr/local# Matlab_dir:=/applications/matlab_r2012b.app# Note:this is required onlyifYou'll compile the Python interface.# We need to being able toFindPython.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: = $ (HOME)/miniconda2python_include:= $ (anaconda_home)/INCLUDE $ (anaconda_home) /include/python2. 7 $ (anaconda_home)/lib/python2. 7/site-packages/numpy/core/ include# uncomment to use Python3(Default is Python2) # Python_libraries:=boost_python3 python3.5m# python_include:=/usr/include/Python3.5m #/usr/lib/python3.5/dist-packages/numpy/core/include# We need to being able toFindlibpythonx.x.so or. Dylib. Python_lib:=/usr/Libpython_lib: = $ (anaconda_home)/ Lib# Homebrew installs NumPyincha non standard path (keg only) # Python_include+= $(dir$ (Shell python-c'import numpy.core; print (numpy.core.__file__)'))/include# Python_lib+ = $ (Shell brew--prefix numpy)/lib# uncomment to support layers writteninchpython (would link against Python libs) # With_python_layer:=1# WhateverElseYouFindYou need goes. Include_dirs:= $ (python_include)/usr/local/include Library_dirs:= $ (python_lib)/usr/local/lib/usr/lib# If Homebrew is installed at a non forExample your home directory) and use it forGeneral dependencies# Include_dirs+ = $ (Shell brew--prefix)/include# Library_dirs+ = $ (Shell brew--prefix)/lib# NCCL acceleration switch (uncomment to build with NCCL) # https://GITHUB.COM/NVIDIA/NCCL (last tested version:v1.2.3-1+cuda8.0)# USE_NCCL: =1# Uncomment to use 'Pkg-config' to specify OpenCV library paths.# (usually not necessary--OpenCV libraries is normally installedinchOne of the above $LIBRARY _dirs.) # Use_pkg_config:=1# n.b. Both build and distribute dirs is cleared on ' MakeClean ' Build_dir:=Builddistribute_dir:=distribute# Uncomment forDebugging. Does not work on OS X due to https://github.com/bvlc/caffe/issues/171# DEBUG: =1# The ID of the GPU that'Make runtest'Would use the to run unit tests. Test_gpuid:=0# Enable pretty build (comment to see full commands) Q?= @

Caffe Ubuntu Compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.