caffe+opencv+openblas+Anaconda+ubuntu14.04配置
本安装教程主要包含7个部分,包括:
第一部分:安装开发依赖包
第二部分:opencv安装和调试
第三部分:Anaconda安装和调试
第四部分:openblas安装和调试
第五部分:Caffe的安装和测试
第六步分:在minist的数据包上训练测试
第七部分:出现的问题及解决方案
1.安装开发依赖包
在linux命令行指令中安装开发所需要的一些基本包指令:
sudo apt-get install build-essential
安装caffe所需要的一些依赖包:
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 install-gcc-multilib install-gfortrain-multilib
安装Anaconda所需要的依赖包:
python-dev python-pip
numpy教程pdf2.opencv安装和调试
安装opencv时没有手动安装,采用Github上有人已经写好了完整的安装脚本,选择这个链接github/jayrambhia/Install-OpenCV,下载后解压,然后进去该目录,选择自己的操作系统,比如我的是Ubuntu,执行
sudo./dependencies.sh
sudo./open2_4_9.sh
其中第一步是安装依赖项opencv的所有依赖项,该依赖项就在这个dependencies.s件中,第二部是安装opencv,包括下载解压存放opencv等操作,这个过程大概一两个小时,慢慢等。
3.Anaconda安装和调试
可以按照官方建议安装anaconda包。在anaconda(inuum.io/downloads#all)下载.s件,切换到文件所在目录,执行.s件,最后添加bin目录到环境变量即可。
在/etc/f最后加入以下路径,并没有出现重启不能进入界面的问题/home/username/anaconda/lib
在~/.bashrc最后添加下边路径
export LD_LIBRARY_PATH="/home/username/anaconda/lib:$LD_LIBRARY_PATH "
4openblas安装和调试
在下载openblas,在这个链接上选择和系统相匹配的版本
(launchpad/ubuntu/+source/openblas),并解压编译执行,具体步骤如下:
首先建立一个文件夹用来盛放解压后的openblas
$mkdir openblas
$cd openblas
然后编译
$make
这个编译是多线程编译。编译好之后安装之
$sudo make install
安装后即可。
5.Caffe的安装和测试
将下载后的caffe-master.zip解压,并将解压后的文件放入要存放的目录,进入caffe-master目录,首先复制一份fig
fig
然后修改fig中的参数:
fig
主要修改的参数如下:
然后编译
make all-j4
make test
make runtest
最后看是否能通过编译。
6.在minist的数据包上训练测试
首先在根目录上获取数据集并解压
cd$CAFFE_ROOT
./data/mnist/get_mnist.sh
然后执行
./examples/mnist/create_mnist.sh
将数据格式转换为lmdb格式。并将新生成的2个文件mnist-train-lmdb和mnist-test-lmdb放于和create_mnist.sh相同目录下。
最后执行测试集,指令如下:
./examples/mnist/train_lenet.sh
到此为止即把caffe的安装测试工作完成了。
7.出现的部分问题及解决方法
1.在安装过程中出现:
linktest.c:(.text.startup+0x55ab):undefined reference to`LAPACKE_clagsy'
linktest.c:(.text.startup+0x55b1):undefined reference to`LAPACKE_clagsy_work'
linktest.c:(.text.startup+0x55b6):undefined reference to`LAPACKE_dlagsy'
linktest.c:(.text.startup+0x55bb):undefined reference to`LAPACKE_dlagsy_work'
linktest.c:(.text.startup+0x55c1):undefined reference to`LAPACKE_slagsy'
linktest.c:(.text.startup+0x55c6):undefined reference to`LAPACKE_slagsy_work'
linktest.c:(.text.startup+0x55cb):undefined reference to`LAPACKE_zlagsy'
linktest.c:(.text.startup+0x55d1):undefined reference to`LAPACKE_zlagsy_work'
collect2:error:ld returned1exit status
make[1]:***[../libopenblas_haswell-r0.2.15.so]Error1
make[1]:Leaving directory`/usr/local/OpenBLAS-0.2.15/exports'
make:***[shared]Error2
lpg@ubuntu:/usr/local/OpenBLAS-0.2.15$sudo make install
getarch_2nd.c:In function‘main’:
getarch_2nd.c:67:5:warning:format‘%ld’expects argument of type‘long int’,but argument2 has type‘unsigned int’[-Wformat=]
printf("#define SLOCAL_BUFFER_SIZE\t%ld\n",(SGEMM_DEFAULT_Q* SGEMM_DEFAULT_UNROLL_N*4*1*sizeof(float)));^
getarch_2nd.c:68:5:warning:format‘%ld’expects argument of type‘long int’,but argument2 has type‘unsigned int’[-Wformat=]
printf("#define DLOCAL_BUFFER_SIZE\t%ld\n",(DGEMM_DEFAULT_Q* DGEMM_DEFAULT_UNROLL_N*2*1*sizeof(double)));
^
getarch_2nd.c:69:5:warning:format‘%ld’expects argument of type‘long int’,but argument2 has type‘unsigned int’[-Wformat=]
printf("#define CLOCAL_BUFFER_SIZE\t%ld\n",(CGEMM_DEFAULT_Q* CGEMM_DEFAULT_UNROLL_N*4*2*sizeof(float)));
^
getarch_2nd.c:70:5:warning:format‘%ld’expects argument of type‘long int’,but argument2 has type‘unsigned int’[-Wformat=]
printf("#define ZLOCAL_BUFFER_SIZE\t%ld\n",(ZGEMM_DEFAULT_Q* ZGEMM_DEFAULT_UNROLL_N*2*2*sizeof(double)));
^
make-j1-f Makefile.install install
make[1]:Entering directory`/usr/local/OpenBLAS-0.2.15'
Generating openblas_config.h in/opt/OpenBLAS/include
Generating f77blas.h in/opt/OpenBLAS/include
Generating cblas.h in/opt/OpenBLAS/include
Copying LAPACKE header files to/opt/OpenBLAS/include
Copying the static library to/opt/OpenBLAS/lib
Copying the shared library to/opt/OpenBLAS/lib
ake in/opt/OpenBLAS/lib/cmake/openblas
ake in/opt/OpenBLAS/lib/cmake/openblas
Install OK!
make[1]:Leaving directory`/usr/local/OpenBLAS-0.2.15'
这种问题通过以下方法解决:
首先添加依赖库install-gcc-multilib install-gfortran-multilib libopenblas,然后执行make TARGET=BANIS SINARY=32即可解决问题。
2.修改后的fig的全部文件为
#Refer to /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
CPU_ONLY:=1
#uncomment to disable IO dependencies and corresponding data layers
USE_OPENCV:=1
USE_LEVELDB:=1
USE_LMDB:=1
#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 OpenCV3
OPENCV_VERSION:=2.4.9
#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 Ubuntu14.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*_50lines 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:=atlas
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:=/path/to/your/blas
#BLAS_LIB:=/path/to/your/blas
BLAS_INCLUDE:=/usr/local/OpenBLAS-0.2.15
BLAS_LIB:=/usr/local/OpenBLAS-0.2.15
#export LD_LIBRARY_PATH=/usr/lib/openblas-base/
#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_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)/anaconda
#PYTHON_INCLUDE:=$(ANACONDA_HOME)/include\
#$(ANACONDA_HOME)/include/python2.7\
#$(ANACONDA_HOME)/lib/python2.7/site-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'; __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
BUILD_DIR:=build
DISTRIBUTE_DIR:=distribute
#Uncomment for debugging.Does not work on OSX due to github/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)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论