@H_404_1@2016.06.10 update cuda 7.5 and cudnn v5
@H_404_1@2015.10.23更新:修改了一些地方,身边很多人按这个流程安装,完全可以安装
折腾了两个星期的caffe,windows和ubuntu下都安装成功了。其中windows的安装配置参考官网推荐的那个blog,后来发现那个版本的caffe太老,和现在的不兼容,一些关键字都不一样,果断回到Linux下。这里记录一下我的安装配置流程。
电脑配置:
ubuntu 14.0464bit
8G 内存
GTX650显卡
软件版本:
CUDA 7.0
caffe 当天从github下载的版本
安装ubuntu的过程省略,建议安装后关闭自动更新,上一次安装caffe后用的很好,结果有一天晚上没关电脑,自己半夜更新了显卡驱动,然后...
caffe的安装流程主要参考这个blog,稍有改动:Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明
Caffe 安装配置步骤:
1, 安装开发所需的依赖包
- sudoapt-getinstallbuild-essential#basicrequirement
- sudoapt-getinstalllibprotobuf-devlibleveldb-devlibsnappy-devlibopencv-devlibboost-all-devlibhdf5-serial-devlibgflags-devlibgoogle-glog-devliblmdb-devprotobuf-compiler#requiredbycaffe
@H_404_1@Before install CUDA 7.5,you need update gcc 4.8+ to gcc 4.9+
@H_404_1@reference:update gcc/g++
2,安装CUDA 7.5
验证过程省略,按照官方文档自己操作吧(遇到问题首先要看官方文档啊,血泪教训)
安装CUDA有两种方法,
离线.run安装:从官网下载对应版本的.run安装包安装,安装过程挺复杂,尝试过几次没成功,遂放弃。
在离线.deb安装:deb安装分离线和在线,我都尝试过都安装成功了,官网下载地址
@H_404_1@安装之前请先进行md5校验,确保下载的安装包完整
- sudodpkg-icuda-repo-<distro>_<version>_<architecture>.deb
- sudoapt-getupdate
- sudoapt-getinstallcuda
- tar-zxvfcudnn-7.5-linux-x64-v5.0-ga.tgz
- cdcuda
- sudocplib/lib*/usr/local/cuda/lib64/
- sudocpinclude/cudnn.h/usr/local/cuda/include/
sudo chmod +r libcudnn.so.5.0.5
sudo ln -sf libcudnn.so.5.0.5 libcudnn.so.5
sudo ln -sf libcudnn.so.5 libcudnn.so
sudo ldconfig
- PATH=/usr/local/cuda/bin:$PATH
- exportPATH
- source/etc/profile
- /usr/local/cuda/lib64
- sudoldconfig
- sudomakeall-j4
- ./deviceQuery
- ./deviceQueryStarting...
- CUDADeviceQuery(RuntimeAPI)version(CUDARTstaticlinking)
- Detected1CUDACapabledevice(s)
- Device0:"GeForceGTX670"
- CUDADriverVersion/RuntimeVersion6.5/6.5
- CUDACapabilityMajor/Minorversionnumber:3.0
- Totalamountofglobalmemory:4095MBytes(4294246400bytes)
- (7)Multiprocessors,(192)CUDACores/MP:1344CUDACores
- GPUClockrate:1098MHz(1.10GHz)
- MemoryClockrate:3105Mhz
- MemoryBusWidth:256-bit
- L2CacheSize:524288bytes
- MaximumTextureDimensionSize(x,y,z)1D=(65536),2D=(65536,65536),3D=(4096,4096,4096)
- MaximumLayered1DTextureSize,(num)layers1D=(16384),2048layers
- MaximumLayered2DTextureSize,(num)layers2D=(16384,16384),2048layers
- Totalamountofconstantmemory:65536bytes
- Totalamountofsharedmemoryperblock:49152bytes
- Totalnumberofregistersavailableperblock:65536
- Warpsize:32
- Maximumnumberofthreadspermultiprocessor:2048
- Maximumnumberofthreadsperblock:1024
- Maxdimensionsizeofathreadblock(x,z):(1024,1024,64)
- Maxdimensionsizeofagridsize(x,z):(2147483647,65535,65535)
- Maximummemorypitch:2147483647bytes
- Texturealignment:512bytes
- Concurrentcopyandkernelexecution:Yeswith1copyengine(s)
- Runtimelimitonkernels:Yes
- IntegratedGPUsharingHostMemory:No
- Supporthostpage-lockedmemorymapping:Yes
- AlignmentrequirementforSurfaces:Yes
- DevicehasECCsupport:Disabled
- DevicesupportsUnifiedAddressing(UVA):Yes
- DevicePCIBusID/PCIlocationID:1/0
- ComputeMode:
- <Default(multiplehostthreadscanuse::cudaSetDevice()withdevicesimultaneously)>
- deviceQuery,CUDADriver=CUDART,CUDADriverVersion=6.5,CUDARuntimeVersion=6.5,NumDevs=1,Device0=GeForceGTX670
- Result=PASS
- sudoapt-getinstalllibatlas-base-dev
- sudosh./opencv2_4_10.sh
8,安装Caffe所需要的Python环境
- bashAnaconda-2.3.0-Linux-x86_64.s<em>h</em>
- /home/username/anaconda/lib
- exportLD_LIBRARY_PATH="/home/username/anaconda/lib:$LD_LIBRARY_PATH"
- forreqin$(catrequirements.txt);dopipinstall$req;done
- cpMakefile.config.exampleMakefile.config
- ##Refertohttp://caffe.berkeleyvision.org/installation.html
- #Contributionssimplifyingandimprovingourbuildsystemarewelcome!
- #cuDNNaccelerationswitch(uncommenttobuildwithcuDNN).
- USE_CUDNN:=1
- #cpu-onlyswitch(uncommenttobuildwithoutGPUsupport).
- #cpu_ONLY:=1
- #Tocustomizeyourchoiceofcompiler,uncommentandsetthefollowing.
- #N.B.thedefaultforLinuxisg++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:=atlas
- #Custom(MKL/ATLAS/OpenBLAS)includeandlibdirectories.
- #LeavecommentedtoacceptthedefaultsforyourchoiceofBLAS
- #(whichshouldwork)!
- #BLAS_INCLUDE:=/path/to/your/blas
- #BLAS_LIB:=/path/to/your/blas
- #Homebrewputsopenblasinadirectorythatisnotonthestandardsearchpath
- #BLAS_INCLUDE:=$(shellbrew--prefixopenblas)/include
- #BLAS_LIB:=$(shellbrew--prefixopenblas)/lib
- #Thisisrequiredonlyifyouwillcompilethematlabinterface.
- #MATLABdirectoryshouldcontainthemexbinaryin/bin.
- #MATLAB_DIR:=/usr/local
- #MATLAB_DIR:=/Applications/MATLAB_R2012b.app
- #NOTE:thisisrequiredonlyifyouwillcompilethepythoninterface.
- #WeneedtobeabletofindPython.handnumpy/arrayobject.h.
- #PYTHON_INCLUDE:=/usr/include/python2.7\
- /usr/lib/python2.7/dist-packages/numpy/core/include
- #AnacondaPythondistributionisquitepopular.Includepath:
- #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\
- #WeneedtobeabletofindlibpythonX.X.soor.dylib.
- #PYTHON_LIB:=/usr/lib
- PYTHON_LIB:=$(ANACONDA_HOME)/lib
- #Homebrewinstallsnumpyinanonstandardpath(kegonly)
- #PYTHON_INCLUDE+=$(dir$(shellpython-c'importnumpy.core;print(numpy.core.__file__)'))/include
- #PYTHON_LIB+=$(shellbrew--prefixnumpy)/lib
- #UncommenttosupportlayerswritteninPython(willlinkagainstPythonlibs)
- #WITH_PYTHON_LAYER:=1
- #Whateverelseyoufindyouneedgoeshere.
- INCLUDE_DIRS:=$(PYTHON_INCLUDE)/usr/local/include
- LIBRARY_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:=1
- BUILD_DIR:=build
- DISTRIBUTE_DIR:=distribute
- #Uncommentfordebugging.DoesnotworkonOSXduetohttps://github.com/BVLC/caffe/issues/171
- #DEBUG:=1
- #TheIDoftheGPUthat'makeruntest'willusetorununittests.
- TEST_GPUID:=0
- #enableprettybuild(commenttoseefullcommands)
- Q?=@
保存退出
- makeall-j4
- maketest
- makeruntest
- makepycaffe