2024年2月23日发(作者:)
caffe+opencv+openblas+Anaconda+ubuntu14.04配置本安装教程主要包含7个部分,包括:第一部分:安装开发依赖包第二部分:opencv安装和调试第三部分:Anaconda安装和调试第四部分:openblas安装和调试第五部分:Caffe的安装和测试第六步分:在minist的数据包上训练测试第七部分:出现的问题及解决方案1.安装开发依赖包在linux命令行指令中安装开发所需要的一些基本包指令:sudoapt-getinstallbuild-essential安装caffe所需要的一些依赖包:sudoapt-getinstalllibprotobuf-devlibleveldb-devlibsnappy-devlibopencv-devlibboost-all-devlibhdf5-serial-devlibgflags-devlibgoogle-glog-devliblmdb-devprotobuf-compilerinstall-gcc-multilibinstall-gfortrain-multilib安装Anaconda所需要的依赖包:安装和调试安装opencv时没有手动安装,采用Github上有人已经写好了完整的安装脚本,选择这个链接/jayrambhia/Install-OpenCV,下载后解压,然后进去该目录,选择自己的操作系统,比如我的是Ubuntu,执行sudo././open2_4_其中第一步是安装依赖项opencv的所有依赖项,该依赖项就在这个文件中,第二部是安装opencv,包括下载解压存放opencv等操作,这个过程大概一两个小时,慢慢等。da安装和调试可以按照官方建议安装anaconda包。在anaconda官网(/downloads#all)下载.sh文件,切换到文件所在目录,执行.sh文件,最后添加bin目录到环境变量即可。在/etc/最后加入以下路径,并没有出现重启不能进入界面的问题/home/username/anaconda/lib在~/.bashrc最后添加下边路径exportLD_LIBRARY_PATH="/home/username/anaconda/lib:$LD_LIBRARY_PATH"4openblas安装和调试在官网下载openblas,在这个链接上选择和系统相匹配的版本
(/ubuntu/+source/openblas),并解压编译执行,具体步骤如下:首先建立一个文件夹用来盛放解压后的openblas$mkdiropenblas$cdopenblas然后编译$make这个编译是多线程编译。编译好之后安装之$sudomakeinstall安装后即可。的安装和测试将下载后的解压,并将解压后的文件放入要存放的目录,进入caffe-master目录,首先复制一份然后修改中的参数:主要修改的参数如下:然后编译makeall-j4maketestmakeruntest最后看是否能通过编译。6.在minist的数据包上训练测试首先在根目录上获取数据集并解压cd$CAFFE_ROOT./data/mnist/get_然后执行./examples/mnist/create_将数据格式转换为lmdb格式。并将新生成的2个文件mnist-train-lmdb和mnist-test-lmdb放于和create_相同目录下。最后执行测试集,指令如下:./examples/mnist/train_到此为止即把caffe的安装测试工作完成了。7.出现的部分问题及解决方法
1.在安装过程中出现:linktest.c:(.p+0x55ab):undefinedreferenceto`LAPACKE_clagsy'linktest.c:(.p+0x55b1):undefinedreferenceto`LAPACKE_clagsy_work'linktest.c:(.p+0x55b6):undefinedreferenceto`LAPACKE_dlagsy'linktest.c:(.p+0x55bb):undefinedreferenceto`LAPACKE_dlagsy_work'linktest.c:(.p+0x55c1):undefinedreferenceto`LAPACKE_slagsy'linktest.c:(.p+0x55c6):undefinedreferenceto`LAPACKE_slagsy_work'linktest.c:(.p+0x55cb):undefinedreferenceto`LAPACKE_zlagsy'linktest.c:(.p+0x55d1):undefinedreferenceto`LAPACKE_zlagsy_work'collect2:error:ldreturned1exitstatusmake[1]:***[../libopenblas_]Error1make[1]:Leavingdirectory`/usr/local/OpenBLAS-0.2.15/exports'make:***[shared]Error2lpg@ubuntu:/usr/local/OpenBLAS-0.2.15$sudomakeinstallgetarch_2nd.c:Infunction‘main’:getarch_2nd.c:67:5:warning:format‘%ld’expectsargumentoftype‘longint’,butargumenthastype‘unsignedint’[-Wformat=]printf("#defineSLOCAL_BUFFER_SIZEt%ldn",(SGEMM_DEFAULT_QSGEMM_DEFAULT_UNROLL_N*4*1*sizeof(float)));^getarch_2nd.c:68:5:warning:format‘%ld’expectsargumentoftype‘longint’,butargumenthastype‘unsignedint’[-Wformat=]printf("#defineDLOCAL_BUFFER_SIZEt%ldn",(DGEMM_DEFAULT_QDGEMM_DEFAULT_UNROLL_N*2*1*sizeof(double)));^getarch_2nd.c:69:5:warning:format‘%ld’expectsargumentoftype‘longint’,butargumenthastype‘unsignedint’[-Wformat=]printf("#defineCLOCAL_BUFFER_SIZEt%ldn",(CGEMM_DEFAULT_QCGEMM_DEFAULT_UNROLL_N*4*2*sizeof(float)));^getarch_2nd.c:70:5:warning:format‘%ld’expectsargumentoftype‘longint’,butargumenthastype‘unsignedint’[-Wformat=]printf("#defineZLOCAL_BUFFER_SIZEt%ldn",(ZGEMM_DEFAULT_QZGEMM_DEFAULT_UNROLL_N*2*2*sizeof(double)));^linstallmake[1]:Enteringdirectory`/usr/local/OpenBLAS-0.2.15'Generatingopenblas_/opt/OpenBLAS//opt/OpenBLAS//opt/OpenBLAS/includeCopyingLAPACKEheaderfilesto/opt/OpenBLAS/includeCopyingthestaticlibraryto/opt/OpenBLAS/libCopyingthesharedlibraryto/opt/OpenBLAS/n/opt/OpenBLAS/lib/cmake/n/opt/OpenBLAS/lib/cmake/openblas2*2*2*2*
InstallOK!make[1]:Leavingdirectory`/usr/local/OpenBLAS-0.2.15'这种问题通过以下方法解决:首先添加依赖库install-gcc-multilibinstall-gfortran-multiliblibopenblas,然后执行makeTARGET=BANISSINARY=32即可解决问题。2.修改后的的全部文件为#Referto/#Contributionssimplifyingandimprovingourbuildsystemarewelcome!#cuDNNaccelerationswitch(uncommenttobuildwithcuDNN).#USE_CUDNN:=1#CPU-onlyswitch(uncommenttobuildwithoutGPUsupport).#CPU_ONLY:=1CPU_ONLY:=1#uncommenttodisableIOdependenciesandcorrespondingdatalayersUSE_OPENCV:=1USE_LEVELDB:=1USE_LMDB:=1#uncommenttoallowMDB_NOLOCKwhenreadingLMDBfiles(onlyifnecessary)#YoushouldnotsetthisflagifyouwillbereadingLMDBswithany#possibilityofsimultaneousreadandwrite#ALLOW_LMDB_NOLOCK:=1#Uncommentifyou'reusingOpenCV3OPENCV_VERSION:=2.4.9#Tocustomizeyourchoiceofcompiler,uncommentandsetthefollowing.#aultforLinuxisg++andthedefaultforOSXisclang++#CUSTOM_CXX:=g++#CUDAdirectorycontainsbin/andlib/directoriesthatweneed.#CUDA_DIR:=/usr/local/cuda#OnUbuntu14.04,ifcudatoolsareinstalledvia#"sudoapt-getinstallnvidia-cuda-toolkit"thenusethisinstead:#CUDA_DIR:=/usr#CUDAarchitecturesetting:goingwithallofthem.#ForCUDA<6.0,commentthe*_50linesforcompatibility.
#CUDA_ARCH:=-gencodearch=compute_20,code=sm_20-gencodearch=compute_20,code=sm_21-gencodearch=compute_30,code=sm_30-gencodearch=compute_35,code=sm_35-gencodearch=compute_50,code=sm_50-gencodearch=compute_50,code=compute_50#BLASchoice:#atlasforATLAS(default)#mklforMKL#openforOpenBlas#BLAS:=atlasBLAS:=open#Custom(MKL/ATLAS/OpenBLAS)includeandlibdirectories.#LeavecommentedtoacceptthedefaultsforyourchoiceofBLAS#(whichshouldwork)!#BLAS_INCLUDE:=/path/to/your/blas#BLAS_LIB:=/path/to/your/blasBLAS_INCLUDE:=/usr/local/OpenBLAS-0.2.15BLAS_LIB:=/usr/local/OpenBLAS-0.2.15#exportLD_LIBRARY_PATH=/usr/lib/openblas-base/#Homebrewputsopenblasinadirectorythatisnotonthestandardsearchpath#BLAS_INCLUDE:=$(shellbrew--prefixopenblas)/include#BLAS_LIB:=$(shellbrew--prefixopenblas)/lib#Thisisrequiredonlyifyouwillcompilethematlabinterface.#MATLABdirectoryshouldcontainthemexbinaryin/bin.#MATLAB_DIR:=/usr/local#MATLAB_DIR:=/Applications/MATLAB_#NOTE:thisisrequiredonlyifyouwillcompilethepythoninterface.#mpy/_INCLUDE:=/usr/include/python2.7usr/lib/python2.7/dist-packages/numpy/core/include#epath:#Verifyanacondalocation,sometimesit'sinroot.#ANACONDA_HOME:=$(HOME)/anaconda#PYTHON_INCLUDE:=$(ANACONDA_HOME)/include#$(ANACONDA_HOME)/include/python2.7
#$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include#_LIB:=/usr/lib#PYTHON_LIB:=$(ANACONDA_HOME)/lib#Homebrewinstallsnumpyinanonstandardpath(kegonly)#PYTHON_INCLUDE+=$(dir$(shellpythonprint(.__file__)'))/include#PYTHON_LIB+=$(shellbrew--prefixnumpy)/lib-c';#UncommenttosupportlayerswritteninPython(willlinkagainstPythonlibs)#WITH_PYTHON_LAYER:=1#E_DIRS:=$(PYTHON_INCLUDE)/usr/local/includeLIBRARY_DIRS:=$(PYTHON_LIB)/usr/local/lib/usr/lib#IfHomebrewisinstalledatanonstandardlocation(forexampleyourhomedirectory)andyouuseitforgeneraldependencies#INCLUDE_DIRS+=$(shellbrew--prefix)/include#LIBRARY_DIRS+=$(shellbrew--prefix)/lib#Uncommenttouse`pkg-config`tospecifyOpenCVlibrarypaths.#(Usuallynotnecessary--OpenCVlibrariesarenormallyinstalledinoneoftheabove$LIBRARY_DIRS.)#USE_PKG_CONFIG:=1BUILD_DIR:=buildDISTRIBUTE_DIR:=distribute#:///BVLC/caffe/issues/171#DEBUG:=1DoesnotworkonOSXdueto#TheIDoftheGPUthat'makeruntest'_GPUID:=0#enableprettybuild(commenttoseefullcommands)


发布评论