如清华大学源,参见https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
sudo gedit /etc/apt/sources.list
添加清华大学软件源
sudo apt-get update
使用“软件更新器”更新系统和软件
sudo add-apt-repository ppa:graphics-drivers/ppa #添加源
sudo apt-get update
使用“软件更新器”更新Nvidia驱动,如367(专有)
重启
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
sudo gedit /etc/profile
添加
export PATH=/usr/local/cuda/bin:$PATH
添加 export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
sudo gedit /etc/ld.so.conf.d/cuda.conf
添加
/usr/local/cuda/lib64
sudo ldconfig
重启
测试是否安装成功\
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make #编译该项目
./deviceQuery #若正确,则会显示有效的输出信息
sudo cp ./include/cudnn.h /usr/local/cuda/include/
sudo cp ./lib64/lib* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64
sudo rm libcudnn.so
sudo rm libcudnn.so.5
sudo ln -s libcudnn.so.5.1.5 libcudnn.so.5
sudo ln -s libcudnn.so.5 libcudnn.so
安装必要的依赖库:
下载OpenCV3.1Unix源码,并解压
cd opencv-3.1.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
make-j8
make check -j8
sudo make install #
安装位置
/usr/local
安装
python
相关库(Anaconda务必升级)
conda update conda
conda install pip
python -m pip install --upgrade pip
conda update --all
cd ./caffe-master/python
for req in $(cat requirements.txt); do pip install $req; done
pip install pydot
pip install pyzmq
tornado jinja2
jsonschema
pip install jupyter
安装
Java
Runtime Environment
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java7-set-default
编译安装
octave
4.0.3
sudo add-apt-repository ppa:octave/stable
sudo apt-get update #用于安装octave依赖
下载
octave
源码
,网址
ftp://ftp.gnu.org/gnu/octave/
tar
zxvf octave-4.0.3.tar.gz
cd octave-4.0.3
sudo apt-get build-dep octave #安装octave依赖
sudo apt-get install libportaudio-dev libqt4-opengl-dev
./
configure
make -j8
make check -j8
sudo make install
编译安装
protobuf
查看
pip
安装的
protobuf
版本
pip list
#pip
安装列表
查看
protobuf
版本
,假设为
protobuf(3.1.0)
查看是否安装有旧版本的
protobuf
,若有则需要卸载旧版本
下载相应版本
ver
3.1
的
protobuf
代码
tar
zxvf protobuf-3.1.0.tar.gz
cd protobuf-3.1.0
sudo apt-get install autoconf automake libtool curl
./
autogen.sh
./
configure -prefix=/usr
make -j8
make check -j8
sudo make install
sudo ldconfig
编译
caffe/pycaffe/octave
su
do apt-get install -y
libleveldb-dev libsnappy-dev libhdf5-serial-dev
sudo apt-get install -y
libatlas-base-dev
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
再次确认
protoc
版本为
3.1.0
*
若不是则需卸载
libprotobuf-dev
和
protobuf-compiler
,并重新安装
protobuf3.1.0
git clone https://github.com/BVLC/caffe.git
cd caffe
cp Makefile.config.example Makefile.config
gedit Makefile.config #
详见附录
gedit CmakeLists.txt #
打开
MATLAB/Octave
编译选项
mkdir
build
cd build
cmake-gui.. #
在
cmake-gui
中配置相应的选项
确认编译方式为
Release
确认
libhdf
5.so
的位置(文件夹)
确认
octave
混合编译器的位置
(文件)
点击
configure
点击
generate
m
ake all -j8
make test
make runtest -j8
make pycaffe #
编译完成后将
./caffe/python
加入到
PYTHONPATH
环境变量
make octave #
编译完成后配置
octave
附件
1
:
CaffeMakefile.config
文件参考配置选项
##Refer to http://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 ifnecessary)
# Youshould not set this flag if you will be reading LMDBs with any
# possibilityof 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 thefollowing.
#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 thisinstead:
#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_30,code=sm_30 \
-gencodearch=compute_35,code=sm_35 \
-gencodearch=compute_50,code=sm_50 \
-gencodearch=compute_52,code=sm_52 \
-gencodearch=compute_52,code=compute_52
#BLAS choice:
#atlas for ATLAS (default)
#mkl for MKL
#open for OpenBlas
BLAS:= atlas
#Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
#Leave commented to accept the defaults for your choice of BLAS
#(which should work)!
#BLAS_INCLUDE := /path/to/your/blas
#BLAS_LIB := /path/to/your/blas
#Homebrew puts openblas in a directory that is not on the standardsearch 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_DIR := /Applications/MATLAB_R2012b.app
#MATLAB_DIR := /home/zq/programfiles/MATLAB/R2016b
#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)/anaconda
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 againstPython libs)
WITH_PYTHON_LAYER:= 1
#Whatever else you find you need goes here.
#HDF5_DIRS:=/usr/local/hdf5-1.8.17
INCLUDE_DIRS:= $(PYTHON_INCLUDE) /usr/include /usr/local/include /usr/lib/usr/include/hdf5 /usr/include/hdf5/serial/usr/lib/x86_64-linux-gnu/hdf5/serial/include
LIBRARY_DIRS:= $(PYTHON_LIB) /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/usr/lib/x86_64-linux-gnu/hdf5/serial
#If Homebrew is installed at a non standard location (for example yourhome 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 inone 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 tohttps://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?= @