ƵµÀÀ¸Ä¿
Ê×Ò³ > ³ÌÐò¿ª·¢ > Èí¼þ¿ª·¢ > ÆäËû > ÕýÎÄ
Caffe´î½¨ÊÖ¼Ç_»ùÓÚUbuntu14.04LTS
2016-09-05 09:54:10         À´Ô´£ºdawin_2008µÄ²©¿Í  
Êղؠ  ÎÒҪͶ¸å

ÎÒµÄÓ²¼þÅäÖãº

Äڴ棺4GB

´¦ÀíÆ÷£ºi3-2120CPU@3.30GHz * 4

ͼÐΣºGeForce GTX 960/PCIe/SSE2

²Ù×÷ϵͳ£ºUbuntu14.04LTS 64λ

´ÅÅÌ£º100GB

Ubuntu14.04LTS°²×°

°²×°ÒÀÀµ¿â

sudo apt-get install build-essential # basic requirement

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler #required by caffe

CUDA Toolkit 7.5°²×°

1.²é¿´×Ô¼ºµÄÏÔ¿¨ÊÇ·ñÄܰ²×°CUDA Toolkit 7.5

$ lspci | grep -i nvidia

Ö»ÒªÐͺŴæÔÚÓÚhttps://developer.nvidia.com/cuda-gpus£¬¾ÍûÎÊÌâÁË

2.ÏÂÔØ NVIDIA CUDA Toolkit7.5

ÏÂÔØµØÖ·£ºhttps://developer.nvidia.com/cuda-toolkit

ÑéÖ¤µØÖ·£ºhttps://developer.nvidia.com/rdp/cuda-rc-checksums

ÎÒÏÂÔØµÄÊÇ cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb£¬¹Ø±Õlightdm£¬ÒÔÃâºÍÔ­À´µÄÇý¶¯·¢Éú³åÍ»£º

$ sudo service lightdm stop

°´ÏÂctrl+alt+F2½øÈëÃüÁîÐÐģʽ£¬ÔÚÃüÁîÐÐÖÐÊäÈ룺

$ cd /path/to/Downloads

$ sudo dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb

$ sudo apt-get update

$ sudo apt-get install -y cuda

°²×°Íê³É£¬ÖØÆô£¬Ìí¼Ó»·¾³±äÁ¿£º

$ export PATH=/usr/local/cuda-7.5/bin:$PATH

$ export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

3.°²×°NVIDIA cuDNN£¨¿ÉÑ¡£¬ÊÇÓÃÓÚÉî¶ÈÉñ¾­ÍøÂçµÄGPU¼ÓËٿ⣩

ÏÂÔØcuDNN£¬´Óhttps://developer.nvidia.com/rdp/cudnn-download£¬×¢²á£¬È»ºóÏÂÔØ£¬ÎÒÏÂÔØµÄÊÇcudnn-7.0-linux-x64-v4.0-prod.tgz:

$ sudo tar xvf cudnn-7.0-linux-x64-v4.0-prod.tgz

$ cd cuda/include

$ sudo cp *.h /usr/local/include/

$ cd ../lib64

$ sudo cp lib* /usr/local/lib/

$ cd /usr/local/lib

$ sudo chmod +r libcudnn.so.4.0.7

$ sudo ln -sf libcudnn.so.4.0.7 libcudnn.so.4

$ sudo ln -sf libcudnn.so.4 libcudnn.so

$ sudo ldconfig #ÕâÀïÓб¨´í£º/sbin/ldconfig.real: /usr/local/lib/libcudnn.so.4 is not a symbolic linkµ«ÊÇ¿´À´²»Ó°Ïì

ÉèÖû·¾³±äÁ¿£¬Ìí¼ÓCUDA»·¾³±äÁ¿£º

$ echo 'export PATH=/usr/local/cuda/bin:$PATH'>> ~/.bashrc

$ echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

±£´æºó£¬Ê¹»·¾³±äÁ¿Á¢¼´ÉúЧ£¬

$ sudo -s

$ source ~/.bashrc

½øÈë/usr/local/cuda/samples£¬Ö´ÐÐÏÂÃæµÄÃüÁîÀ´build samples:

$ sudo make all -j4

È«²¿±àÒëÍê³Éºó£¬½øÈë samples/bin/x86_64/linux/release£¬ÔËÐÐdeviceQuery:

$ ./deviceQuery

°²×°cuDNNЧ¹ûͼ<†·Ÿ"/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxwPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPjxjb2RlPru5v8nS1NPDPGNvZGU+JCBudmNjIC0tdmVyc2lvbrLpv7Sw5rG+usWjrMj0zOHKvm52Y2PD/MHusru05tTao6zLtcP3sLLXsNPQtO2joTwvY29kZT48L2NvZGU+PC9jb2RlPjwvY29kZT48L2NvZGU+PC9jb2RlPjwvY29kZT48L2NvZGU+PC9jb2RlPjwvY29kZT48L2NvZGU+PC9jb2RlPjwvcD4NCjxoMyBpZD0="matlab-r2014a°²×°">MATLAB R2014a°²×°

1.¹ÒÔØiso£¨Ðèн¨matlab_isoÎļþ¼Ð£©£º

$ sudo mount -o loop MATHWORKS_R2014A.iso ¡«/matlab_iso

2.¿ªÊ¼°²×°£º

$ cd ~/matlab_iso

$ sudo ./install

3.Ñ¡Ôñ”install manually without using the internet”Ïî½øÐа²×°

4.ÊäÈë”file installation key”:12345-67890-12345-67890£¨Ëæ±ã¶¼ÐУ©

5.¼¤»î£ºÑ¡Ôñ”license_405329_R2014a.lic”Îļþ½øÐм¤»î£¨ÔÚCrackÎļþ¼ÐÏÂÃæ£©

6.½«libmwservices.so¸´ÖƵ½/usr/local/MATLAB/R2014a/bin/glnxa64ÖУº

$ sudo cp libmwservices.so /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so

7.ÑéÖ¤£º

$ matlab

Èô²»±¨´í¾ÍÊǰ²×°³É¹¦

½â¾ö±àÒëÆ÷gcc/g++°æ±¾ÎÊÌâ

ÒòΪUbuntu 14.04µÄgcc/g++°æ±¾ÊÇ4.8.4£¬¶øMatlab R2014a£¨2015a£©µÄ°æ±¾ÊÇ4.7.xËùÒÔÔÚʹÓÃmatlaµ÷ÓÃmexÎļþµÄʱºò£¬»ù±¾É϶¼»á±¨´í£¬¸ù¾Ý±¨´íÐÅÏ¢£¬¿¼ÂÇÈçÏÂÁ½²½½â¾ö·½°¸¡£

1.ÏÂÔØgcc/g++ 4.7.x

$ sudo apt-get install -y gcc-4.7

$ sudo apt-get install -y g++-4.7

2.Á´½Ógcc/g++ʵÏÖ½µ¼¶

$ cd /usr/bin

$ sudo rm gcc

$ sudo ln -s gcc-4.7 gcc

$ sudo rm g++

$ sudo ln -s g++-4.7 g++

½µ¼¶³É¹¦£¡

°²×°OpenCV3.0

°²×°OpenBLAS

1.ÏÂÔØOpenBLAS:

https://github.com/xianyi/OpenBLAS/archive/v0.2.19.tar.gz

2.°²×°£º

$ mkdir ~/OpenBLAS

$ cd ~/OpenBLAS

$ tar zxvf OpenBLAS-0.2.19.tar.gz

$ make

$ make all #ĬÈϰ²×°ÔÚopt/OpenBLAS

°²×°Anaconda python

1.ÏÂÔØAnaconda

https://repo.continuum.io/archive/Anaconda2-4.1.1-Linux-x86_64.sh

2.°²×°£º

$ bash ~/Downloads/Anaconda3-4.0.0-Linux-x86_64.sh

3.Ìí¼Ó»·¾³±äÁ¿£¬²»ÓÃÿ´Î¶¼ÒªÊÖ¶¯ÊäÈë

3.1.ÐÞ¸ÄprofileÎļþ£º

$ sudo -s

#vi /etc/profile

ÔÚÀïÃæ×îºóÒ»ÐмÓÈë:

export PATH=/home/username/anaconda2/bin:$PATH

Èû·¾³±äÁ¿Á¢¼´ÉúЧÐèÒªÖ´ÐÐÈçÏÂÃüÁ

#source /etc/profile

3.2ÐÞ¸Ä.bashrcÎļþ£º

# vi /root/.bashrc

ÔÚÀïÃæ×îºóÒ»ÐмÓÈ룺

export PATH=/home/username/anaconda2/bin:$PATH

ÖØÐÂ×¢Ïúϵͳ²ÅÄÜÉúЧ

±àÒëcaffe

1.ÏÂÔØcaffe-master°ü£¬½âÑ¹ÖØÃüÃûΪcaffe£¬ÎÒ·ÅÔÚ/homeĿ¼ÏÂ

git@github.com:BVLC/caffe.git

2.½øÈëcaffeĿ¼£¬±àÒëÖ÷³ÌÐò

$ cp Makefile.config.example Makefile.config

$ sudo gedit Makefile.config

²ÎÊý˵Ã÷

CPU_ONLY ÊÇ·ñֻʹÓÃCPUģʽ£¬Ã»ÓÐGPUû°²×°CUDAµÄͬѧ¿ÉÒÔ´ò¿ªÕâ¸öÑ¡Ïî BLAS (ʹÓÃintel mkl¡¢atlas»¹ÊÇOpenBLAS)ÎÒÓõÄÊÇÓÅ»¯ºóµÄBLAS£¬¼´OpenBLAS£¬ËùÒÔ BLAS=£ºopen ²¢¼ÓÈë¿âÎļþ·¾¶ MATLAB_DIR Èç¹ûÐèҪʹÓÃMATLAB wrapperµÄͬѧÐèÒªÖ¸¶¨matlabµÄ°²×°Â·¾¶, ÈçÎҵķ¾¶Îª /usr/local/MATLAB/R2014a (×¢Òâ¸ÃĿ¼ÏÂÐèÒª°üº¬binÎļþ¼Ð£¬binÎļþ¼ÐÀïÓ¦¸Ã°üº¬mex¶þ½øÖƳÌÐò)

ÎÒµÄMakefile.configÅäÖÃÈçÏ£º

## Refer to https://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are 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 (only if necessary)
#   You should not set this flag if you will be reading LMDBs with any
#   possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
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_50,code=compute_50

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /opt/OpenBLAS/include
BLAS_LIB := /opt/OpenBLAS/lib

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
MATLAB_DIR := /usr/local/MATLAB/R2014a
#MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.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)/anaconda2
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
           $(ANACONDA_HOME)/include/python2.7 \
           $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a 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 written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @

$ make all -j4 #ʹÓöàºË¼ÓËÙ£¬ÎÒµÄÊÇËĺË

$ make test

$ make runtest

³öÏÖ±¨´íÐÅÏ¢:

error while loading shared libraries: libhdf5_hl.so.10: cannot open shared object file: No such file or directory

·²ÊÇÕâÖÖÇé¿ö,Èç¹û±¨´íÎļþµÄÈ·ÊÇ´æÔÚ,¾Í°ÑÎļþËùÔڵķ¾¶¼ÓÈë»·¾³±äÁ¿,ÔÚ~./bashrcÌí¼ÓÎļþËùÔÚ·¾¶,ÕâÊÇÎҳɹ¦±àÒëºóµÄbashrcÎļþÌí¼ÓµÄ·¾¶:

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/dawin/anaconda2/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/dawin/OpenBLAS:$LD_LIBRARY_PATH

ÔÙmake runtest,Ч¹ûÈçͼ:

caffe°²×°³É¹¦Ð§¹ûͼ

3.±àÒëMatlab wrapper

$ make matcaffe

È»ºó¾Í¿ÉÒÔÅܹٷ½µÄmatlab demo!

4.±àÒëPython wrapper

$ make pycaffe

ÒÔºóÒ²¿ÉÒÔÅܹٷ½µÄdemo

5.ÑéÖ¤python½Ó¿Ú

$ python

ÔÚpythonÃüÁî»·¾³ÏÂÊäÈëimport caffe,³öÏÖ±¨´í:

ImportError: No module named google.protobuf.internal

ÕâÊÇÒòΪÓÐÁ½¸öpython·¾¶ÔÚ±äÁ¿»·¾³ÖÐ,Òª¸øanacondaÖÐpythonºÍϵͳÖеÄpython°²×°protobuf,Í˳öpython,ÊäÈëÒÔÏÂÃüÁî:

$ sudo pip install protobuf

$ sudo /home/dawin/anaconda2/bin/pip install protobuf

ÔÙ´ÎÔÚpythonÃüÁî»·¾³ÏÂÊäÈëimport caffe,²»±¨´í¾Í³É¹¦ÁË!

ºó¼Ç

°²×°caffeÕæÊÇÒ»¸ö´ó¹¤³Ì,ÎÒ´ÓwindowsÀïÃæ°²×°caffe,ÔÙµ½ubuntuÖа²×°»¨Á˰ë¸öÔÂ,½Ó×ÅÊÔͼ²âÊÔfast-rcnnºÍfaster-rcnn¶¼Ã»³É¹¦,×îºó²âÊÔrcnn³É¹¦,¿ÉÊÇǰ¼¸ÌìÊÖ¼úÊäÈënvcc,ÌáʾûÓа²×°nvcc,¾ÍÖØÐ°²×°nvcc,µ¼ÖÂÏÔ¿¨³åÍ»²¢ÇÒ²»ÄÜÖØÐ°²×°nvidiaµÄÏÔ¿¨,Ö»Äܱ»±Æ×Å֨װubuntu,µÀ·Ï൱ÇúÕÛ,Ôڴ˹ý³ÌÖиÐлÎÒµÄÁ½Î»µ¼Ê¦–ºØ²©ºÍÖܲ©,ûÓÐËûÃǵÄÖ¸µ¼ÎÒºÜÄѼÌÐøÏÂÈ¥,Ï£ÍûÕâÊÇÎÒ×öÉñ¾­ÍøÂçÏà¹Ø¿ÎÌâµÄÁ¼ºÃ¿ª¶Ë

µã»÷¸´ÖÆÁ´½Ó ÓëºÃÓÑ·ÖÏí!»Ø±¾Õ¾Ê×Ò³
Ïà¹ØTAG±êÇ© ÊÖ¼Ç
ÉÏһƪ£ºdubboÉú²ú²¿ÊðͼÎÄʵÀý£¨¶þ£©£ºÓÃmaven´ò°üdubboÏîÄ¿²¢²¿Êðµ½ÔÆÆ½Ì¨
ÏÂһƪ£ºStrutsѧϰ×ܽá(°Ë)---ʹÓÃStruts2ʵÏÖÓû§ÐÅÏ¢µÄCRUD²Ù×÷(¶þ:Ìí¼Ó²Ù×÷)
Ïà¹ØÎÄÕÂ
ͼÎÄÍÆ¼ö
µã»÷ÅÅÐÐ

¹ØÓÚÎÒÃÇ | ÁªÏµÎÒÃÇ | ¹ã¸æ·þÎñ | Ͷ×ʺÏ×÷ | °æÈ¨ÉêÃ÷ | ÔÚÏß°ïÖú | ÍøÕ¾µØÍ¼ | ×÷Æ··¢²¼ | Vip¼¼ÊõÅàѵ | ¾Ù±¨ÖÐÐÄ

°æÈ¨ËùÓÐ: ºìºÚÁªÃË--ÖÂÁ¦ÓÚ×öʵÓõÄIT¼¼ÊõÑ§Ï°ÍøÕ¾