Ubuntu14.04+caffe+cuda8.0+cudnn v5.1配置
来源:互联网 发布:vpn free mac 编辑:程序博客网 时间:2024/04/29 09:54
1. 环境准备
在Ubuntu下用apt-get大法搞定所有依赖包。opencv和python建议通过别的方法自行安装
sudo apt-get install gitsudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compilersudo apt-get install --no-install-recommends libboost-all-devsudo apt-get install libatlas-base-devsudo apt-get install python-dev sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
2. 安装cuda8.0。从CUDA官网下载目前最新版的cuda8.0的.run文件。
安装之前先按下ctrl+alt+F1进入命令行界面,关闭图形界面
sudo stop lightdm
进入到下载的cuda8.0安装包所在文件夹下,直接在命令行运行.run文件开始安装
进入并accept完声明后注意第一个选项,询问你是否需要安装NVIDIA驱动程序,如果电脑已经安装过适合自己显卡的显卡驱动,此处一定得选择为no,后面的基本可以默认选择就好,根据自己需要。如果之前没有安装过NVIDIA驱动则第一个需要选择YES进行驱动的安装然后再进行cuda的安装。
打开图形界面,ctrl+alt+F7回到图形界面:
sudo start lightdm
查看驱动是否安装成功:
nvidia-smi
3. 安装配置cudnn5.1。下载最新的cudnn-8.0-linux-x64-v5.1.tgz文件。将解压出的cuda文件夹下的lib64文件夹里的静态库和动态库文件一并拷到cuda8.0的安装目录下的lib64中去,默认是/usr/local/cuda/lib64/。同时将include文件夹下的头文件cudnn.h拷贝到cuda8.0的include中去,默认为/usr/local/cuda/include/
tar -zxvf cudnn-8.0-linux-x64-v5.1.tgzcd cudasudo cp lib64/* /usr/local/cuda/lib64/sudo cp include/cudnn.h /usr/local/cuda/include/
cd /usr/local/cuda/lib64/sudo chmod +r libcudnn.so.5.1.5sudo ln -sf libcudnn.so.5.1.5 libcudnn.so.5sudo ln -sf libcudnn.so.5 libcudnn.sosudo ldconfig
4. 设置环境变量
sudo gedit /etc/profile在文件尾部添加以下内容:
PATH=/usr/local/cuda/bin:$PATH
export PATH
保存后, 执行下列命令, 使环境变量立即生效
source /etc/profile同时需要添加lib库路径: 在 /etc/ld.so.conf.d/加入文件 cuda.conf,
sudo gedit /etc/ld.so.conf.d/cuda.conf添加以下内容:
/usr/local/cuda/lib64
保存后,执行下列命令使之立刻生效
sudo ldconfig
此时可以通过命令行查看cuda是否安装成功:
nvcc -V
5. 通过git获取github上的官方caffe源码。
git clone https://github.com/bvlc/caffe.git
6. 配置caffe的config文件。
cd caffe/cp Makefile.config.example Makefile.config #以example为备份sudo gedit Makefile.config
根据自己需要进行配置,将cudnn的注释解开,并确保opencv(2或者3),python(或anaconda),cuda等路径的正确
7. 编译caffe
make all && make pycaffe
8. 相对于通过python命令import caffe到python库中,建议是在需要使用caffe的项目中再将库引进去,因为caffe版本可能会有多个,方法如下:
在python文件头部加上:
import sys
sys.path.append('/home/yourname/caffe/python')
import caffe
这样caffe即可正常使用了
9. 往python库里导入caffe时可能错误的解决情况
(0) ubuntu中很可能碰到的问题,系统的protobuf和pyhton的protobuf版本不一致,可能在C++调用python接口时候遇到问题,此时最好的方法是将python的protobuf版本降回2.6
pip install protobuf==2.6.0
(1)import caffe时出错:can not find module skimage.io
sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipythonsudo apt-get update(2)python caffe libcaffe.so.1.0.0-rc3: cannot open shared object file
cd /etc/ld.so.conf.dsudo gedit ./pycaffe.conf
在里边添加以下内容:
/home/yourname/caffe/build/lib
别忘了再load一下:
sudo ldconfig
然后将caffe/python文件夹下的整个caffe文件夹拷贝到/usr/lib/python2.7/dist-packages下
cd caffe/sudo cp -r ./python/caffe /usr/lib/python2.7/dist-packages
然后再import caffe就没问题了
(3)python caffe报错:No module named google.protobuf.internal
conda install protobuf
import google.protobuf
最后贴一份opencv3+anaconda3的Makefile.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 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 3OPENCV_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 OpenBlasBLAS := 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 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)/anaconda3PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ $(ANACONDA_HOME)/include/python3.5m \ $(ANACONDA_HOME)/lib/python3.5/site-packages/numpy/core/include \# Uncomment to use Python 3 (default is Python 2) PYTHON_LIBRARIES := boost_python-py34 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/libPYTHON_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/includeLIBRARY_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 := buildDISTRIBUTE_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 ?= @
- Ubuntu14.04+caffe+cuda8.0+cudnn v5.1配置
- 深度学习框架caffe配置(ubuntu14.04+cuda8.0+cudnn v5.1 + caffe)
- ubuntu14.04+caffe+cuda8.0+cudnn-8.0-v5.1(gtx1070)安装与测试
- ubuntu14.04配置caffe,cuda8.0+cudnn v6
- 深度学习框架tensorflow配置(ubuntu14.04+cuda8.0+cudnn v5.1+anaconda2+tensorflow)
- Ubuntu16.04 cuda8.0 cudnn v5.1 caffe py-faster-rcnn配置
- 安装配置 Ubuntu 14.04 + CUDA8.0 + cuDNN v5 + caffe
- Ubuntu14.04+CUDA8.0+cuDNN-v5.0+py_faster_rcnn实现
- Ubuntu16.04+caffe+CUDA8.0+cuDNN v5+python编译
- Ubuntu14.04下安装英伟达显卡驱动+cuda8.0+cudnn v5.1
- ubuntu14.04 cuda8.0 cudnn caffe tensorflow opencv
- Caffe+win10 64位+CUDA8.0+cuDNN v5+matlab R2014a详细配置
- [work]Caffe+win10 64位+CUDA8.0+cuDNN v5+matlab R2014a详细配置
- cuda8.0和cudnn v5.1在ubuntu16.04装机
- ubuntu16.04+Cuda8.0+CuDnn v5+OpenCV3.1.0+Matlab2014+Python+Caffe安装
- ubuntu16.04+Cuda8.0+CuDnn v5+OpenCV3.1.0+Matlab2014+Python+Caffe安装
- ubuntu16.04+gtx1080+cuda8.0+opencv3.1.0+cudnn-v5+caffe安装教程
- ubuntu16.04 安装配置matlab+python +cuda8.0+cudnn+opencv3.1的caffe环境
- Mybatis分页插件PageHelper的简单使用
- 临洮巨人
- C语言与C++文件的I/O操作
- aaadagsa
- 【codeforces 550C】Divisibility by Eight
- Ubuntu14.04+caffe+cuda8.0+cudnn v5.1配置
- lintcode,电话号码的字母组合
- [AHK]联动通达信其实很简单
- c#中怎样在打开一个form后让第二个form出现一段时间后消失
- Makefile 中:= ?= += =的区别
- RxJava 与 Retrofit 参考学习的资料
- AutoCompleteTextView搜索记录栏的使用
- 阿里云备案的那些事
- 一直有个问题说不清楚,我们学习知识的时候为什么一定要按照知识点积累和理论并行?