2016.06.10 update cuda 7.5 and cudnn v5

2015.10.23更新:修改了一些地方,身边很多人按这个流程安装,完全可以安装

折腾了两个星期的caffe,windows和ubuntu下都安装成功了。其中windows的安装配置参考官网推荐的那个blog,后来发现那个版本的caffe太老,和现在的不兼容,一些关键字都不一样,果断回到Linux下。这里记录一下我的安装配置流程。

电脑配置:

ubuntu 14.04 64bit

8G 内存

GTX650显卡

软件版本:

CUDA 7.0

caffe 当天从github下载的版本

安装ubuntu的过程省略,建议安装后关闭自动更新,上一次安装caffe后用的很好,结果有一天晚上没关电脑,自己半夜更新了显卡驱动,然后...

caffe的安装流程主要参考这个blog,稍有改动:Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明

Caffe 安装配置步骤:

1, 安装开发所需的依赖包

[plain] view plaincopyprint?
  1. sudo apt-get install build-essential  # basic requirement
  2. 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 #required by caffe

Before install CUDA 7.5, you need update gcc 4.8+ to gcc 4.9+

reference:update gcc/g++

2,安装CUDA 7.5

验证过程省略,按照官方文档自己操作吧(遇到问题首先要看官方文档啊,血泪教训)

安装CUDA有两种方法,

离线.run安装:从官网下载对应版本的.run安装包安装,安装过程挺复杂,尝试过几次没成功,遂放弃。

在离线.deb安装:deb安装分离线和在线,我都尝试过都安装成功了,官网下载地址

安装之前请先进行md5校验,确保下载的安装包完整

切换到下载的deb所在目录,执行下边的命令
[plain] view plaincopyprint?
  1. sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
  2. sudo apt-get update
  3. sudo apt-get install cuda
然后重启电脑:sudo reboot
NOTE:装不成功卸了多来几遍,总会成的
3,安装cuDNN
下载cudnn-7.5-linux-x64-v5.0-ga.tgz,官网申请不到,网上自己找的,就不给地址了。
[plain] view plaincopyprint?
  1. tar -zxvf cudnn-7.5-linux-x64-v5.0-ga.tgz
  2. cd cuda
  3. sudo cp lib/lib* /usr/local/cuda/lib64/
  4. sudo cp include/cudnn.h /usr/local/cuda/include/
更新软连接
cd /usr/local/cuda/lib64/
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
4,设置环境变量
在/etc/profile中添加CUDA环境变量
sudo gedit /etc/profile
[plain] view plaincopyprint?
  1. PATH=/usr/local/cuda/bin:$PATH
  2. export PATH
保存后, 执行下列命令, 使环境变量立即生效
[plain] view plaincopyprint?
  1. source /etc/profile
同时需要添加lib库路径: 在 /etc/ld.so.conf.d/加入文件 cuda.conf, 内容如下
[plain] view plaincopyprint?
  1. /usr/local/cuda/lib64
保存后,执行下列命令使之立刻生效
[plain] view plaincopyprint?
  1. sudo ldconfig
5,安装CUDA SAMPLE
进入/usr/local/cuda/samples, 执行下列命令来build samples
[plain] view plaincopyprint?
  1. sudo make all -j4
整个过程大概10分钟左右, 全部编译完成后, 进入 samples/bin/x86_64/linux/release, 运行deviceQuery
[plain] view plaincopyprint?
  1. ./deviceQuery
如果出现显卡信息, 则驱动及显卡安装成功:
[plain] view plaincopyprint?
  1. ./deviceQuery Starting...
  2. CUDA Device Query (Runtime API) version (CUDART static linking)
  3. Detected 1 CUDA Capable device(s)
  4. Device 0: "GeForce GTX 670"
  5. CUDA Driver Version / Runtime Version          6.5 / 6.5
  6. CUDA Capability Major/Minor version number:    3.0
  7. Total amount of global memory:                 4095 MBytes (4294246400 bytes)
  8. ( 7) Multiprocessors, (192) CUDA Cores/MP:     1344 CUDA Cores
  9. GPU Clock rate:                                1098 MHz (1.10 GHz)
  10. Memory Clock rate:                             3105 Mhz
  11. Memory Bus Width:                              256-bit
  12. L2 Cache Size:                                 524288 bytes
  13. Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  14. Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  15. Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  16. Total amount of constant memory:               65536 bytes
  17. Total amount of shared memory per block:       49152 bytes
  18. Total number of registers available per block: 65536
  19. Warp size:                                     32
  20. Maximum number of threads per multiprocessor:  2048
  21. Maximum number of threads per block:           1024
  22. Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  23. Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  24. Maximum memory pitch:                          2147483647 bytes
  25. Texture alignment:                             512 bytes
  26. Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  27. Run time limit on kernels:                     Yes
  28. Integrated GPU sharing Host Memory:            No
  29. Support host page-locked memory mapping:       Yes
  30. Alignment requirement for Surfaces:            Yes
  31. Device has ECC support:                        Disabled
  32. Device supports Unified Addressing (UVA):      Yes
  33. Device PCI Bus ID / PCI location ID:           1 / 0
  34. Compute Mode:
  35. < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
  36. deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.5, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GTX 670
  37. Result = PASS
NOTE:上边的显卡信息是从别的地方拷过来的,我的GTX650显卡不是这些信息,如果没有这些信息,那肯定是安装不成功,找原因吧!
6,安装Intel MKL 或Atlas
我没有MKL,装的Atlas
安装命令:
[plain] view plaincopyprint?
  1. sudo apt-get install libatlas-base-dev
7,安装OpenCV
我安装的是2.4.10
1)下载安装脚本
2)进入目录 Install-OpenCV/Ubuntu/2.4
3)执行脚本
[plain] view plaincopyprint?
  1. sudo sh ./opencv2_4_10.sh

8,安装Caffe所需要的Python环境
按caffe官网的推荐使用Anaconda
去Anaconda官网下载安装包
切换到文件所在目录,执行
[plain] view plaincopyprint?
  1. bash Anaconda-2.3.0-Linux-x86_64.s<em>h</em>
NOTE:后边的文件名按自己下的版本号更改,整个安装过程请选择默认
8.1,添加Anaconda Library Path
在/etc/ld.so.conf最后加入以下路径,并没有出现重启不能进入界面的问题(NOTE:下边的username要替换)
[plain] view plaincopyprint?
  1. /home/username/anaconda/lib
在~/.bashrc最后添加下边路径
[plain] view plaincopyprint?
  1. export LD_LIBRARY_PATH="/home/username/anaconda/lib:$LD_LIBRARY_PATH"

9,安装python依赖库
去caffe的github下载caffe源码包
进入caffe-master下的python目录
执行如下命令
[plain] view plaincopyprint?
  1. for req in $(cat requirements.txt); do pip install $req; done
10,编译Caffe
终于来到这里了
进入caffe-master目录,复制一份Makefile.config.examples
[plain] view plaincopyprint?
  1. cp Makefile.config.example Makefile.config
修改其中的一些路径,如果前边和我说的一致,都选默认路径的话,那么配置文件应该张这个样子
[plain] view plaincopyprint?
  1. ## Refer to http://caffe.berkeleyvision.org/installation.html
  2. # Contributions simplifying and improving our build system are welcome!
  3. # cuDNN acceleration switch (uncomment to build with cuDNN).
  4. USE_CUDNN := 1
  5. # CPU-only switch (uncomment to build without GPU support).
  6. # CPU_ONLY := 1
  7. # To customize your choice of compiler, uncomment and set the following.
  8. # N.B. the default for Linux is g++ and the default for OSX is clang++
  9. # CUSTOM_CXX := g++
  10. # CUDA directory contains bin/ and lib/ directories that we need.
  11. CUDA_DIR := /usr/local/cuda
  12. # On Ubuntu 14.04, if cuda tools are installed via
  13. # "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
  14. # CUDA_DIR := /usr
  15. # CUDA architecture setting: going with all of them.
  16. # For CUDA < 6.0, comment the *_50 lines for compatibility.
  17. CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
  18. -gencode arch=compute_20,code=sm_21 \
  19. -gencode arch=compute_30,code=sm_30 \
  20. -gencode arch=compute_35,code=sm_35 \
  21. -gencode arch=compute_50,code=sm_50 \
  22. -gencode arch=compute_50,code=compute_50
  23. # BLAS choice:
  24. # atlas for ATLAS (default)
  25. # mkl for MKL
  26. # open for OpenBlas
  27. BLAS := atlas
  28. # Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
  29. # Leave commented to accept the defaults for your choice of BLAS
  30. # (which should work)!
  31. # BLAS_INCLUDE := /path/to/your/blas
  32. # BLAS_LIB := /path/to/your/blas
  33. # Homebrew puts openblas in a directory that is not on the standard search path
  34. # BLAS_INCLUDE := $(shell brew --prefix openblas)/include
  35. # BLAS_LIB := $(shell brew --prefix openblas)/lib
  36. # This is required only if you will compile the matlab interface.
  37. # MATLAB directory should contain the mex binary in /bin.
  38. # MATLAB_DIR := /usr/local
  39. # MATLAB_DIR := /Applications/MATLAB_R2012b.app
  40. # NOTE: this is required only if you will compile the python interface.
  41. # We need to be able to find Python.h and numpy/arrayobject.h.
  42. #PYTHON_INCLUDE := /usr/include/python2.7 \
  43. /usr/lib/python2.7/dist-packages/numpy/core/include
  44. # Anaconda Python distribution is quite popular. Include path:
  45. # Verify anaconda location, sometimes it's in root.
  46. ANACONDA_HOME := $(HOME)/anaconda
  47. PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
  48. $(ANACONDA_HOME)/include/python2.7 \
  49. $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \
  50. # We need to be able to find libpythonX.X.so or .dylib.
  51. #PYTHON_LIB := /usr/lib
  52. PYTHON_LIB := $(ANACONDA_HOME)/lib
  53. # Homebrew installs numpy in a non standard path (keg only)
  54. # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
  55. # PYTHON_LIB += $(shell brew --prefix numpy)/lib
  56. # Uncomment to support layers written in Python (will link against Python libs)
  57. # WITH_PYTHON_LAYER := 1
  58. # Whatever else you find you need goes here.
  59. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
  60. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
  61. # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
  62. # INCLUDE_DIRS += $(shell brew --prefix)/include
  63. # LIBRARY_DIRS += $(shell brew --prefix)/lib
  64. # Uncomment to use `pkg-config` to specify OpenCV library paths.
  65. # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
  66. # USE_PKG_CONFIG := 1
  67. BUILD_DIR := build
  68. DISTRIBUTE_DIR := distribute
  69. # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
  70. # DEBUG := 1
  71. # The ID of the GPU that 'make runtest' will use to run unit tests.
  72. TEST_GPUID := 0
  73. # enable pretty build (comment to see full commands)
  74. Q ?= @

保存退出
编译
[plain] view plaincopyprint?
  1. make all -j4
  2. make test
  3. make runtest
11,编译Python wrapper
[plain] view plaincopyprint?
  1. make  pycaffe

到这里就基本结束了,跑个自带的例子测试一下吧!

NOTE:以上是我在自己PC上的安装步骤,因软件版本不同,硬件环境不同,按照以上方式可能出现错误,请耐心查找错误,欢迎留言

2015.08.17 Ubuntu 14.04+cuda 7.5+caffe安装配置相关推荐

  1. Ubuntu 14.04+cuda 7.5+caffe安装配置

    换了新电脑,整个人喜气洋洋,然后就屁颠屁颠地开始配置caffe的使用环境. 可是!!!配置这个坑爹的caffe环境让我重装系统N次加上重装cudaN次,后来发现有好多都是很琐碎的注意事项,好多人都没有 ...

  2. NVIDIA DIGITS-2.0 + Ubuntu 14.04 + CUDA 7.0 + cuDNN 7.0 + Caffe 0.13.0环境配置

    引言 DIGITS简介 DIGITS特性 资源信息 说明 DIGITS安装 软硬件环境 硬件环境 软件环境 操作系统安装 DIGITS安装前准备 安装CUDA70deb方式 安装cuDNN70 安装C ...

  3. Go在Ubuntu 14.04 64位上的安装过程

    1. 从 https://golang.org/dl/  或  https://studygolang.com/dl 下载最新的发布版本go1.10即go1.10.linux-amd64.tar.gz ...

  4. Ubuntu 14.04 FTP服务器--vsftpd的安装和配置

    http://jingyan.baidu.com/article/67508eb4d6c4fd9ccb1ce470.html Ubuntu 14.04 FTP服务器--vsftpd的安装和配置 我们经 ...

  5. Caffe配置简明教程 ( Ubuntu 14.04 / CUDA 7.5 / cuDNN 5.1 )

    1. 前言 本教程使用的系统是Ubuntu 14.04 LTS 64-bit,使用的CUDA版本为7.5,使用的NVIDIA驱动版本为352. 如果您使用的Pascal架构显卡,如GTX1080或者新 ...

  6. Ubuntu 14.04数据库服务器--mysql的安装和配置

    https://jingyan.baidu.com/article/425e69e6bbc6c7be14fc1640.html mysql是Oracle公司的一种开放源代码的关系型数据库管理系统,被广 ...

  7. Ubuntu 14.04 ThinkPad E431无线网卡驱动安装

    Ubuntu 14.04下安装无线网卡驱动. sudo apt-get install linux-headers-generic build-essential dkms   sudo apt-ge ...

  8. Ubuntu 14.04(64位)安装和使用docker

                          Docker介绍: Docker是一个开源的应用容器引擎,可以通过docker来安装一个独立的系统(类似于虚拟机(Vmware)之类的),不过其特点是非常轻 ...

  9. 虚拟机 Ubuntu 14.04 LTS (64 bits) 下安装 Kurento v6 并运行 kurento-hello-world

    这里是官网的教程,想自己折腾的可以完全对着官网教程来,然后不停的google遇到的问题. https://www.kurento.org/docs/6.0.0/installation_guide.h ...

最新文章

  1. php option如何循环每一个值,Js 在option ={ data:[]}中怎么使用循环;
  2. 润乾V5部署url应用名为空applet无法打印解决方案
  3. IE6环境下遭遇winow.location.href=''的跳转bug
  4. python cookie使用_Python使用cookielib模块操作cookie的实例教程
  5. (68)zabbix windows性能计数器使用详解
  6. Spring Bean懒加载与非懒加载
  7. 山东中职计算机应用基础课件,计算机应用基础课件(中职)-精选版.ppt
  8. 异星工场服务器直连,Factorio 异星工厂 搭建服务器
  9. Word 文档中的图片另存为 .jpg 格式图片方法
  10. Jupyter Notebook 更改默认浏览器
  11. stata如何快速导出表格
  12. HashMap的put过程
  13. lightoj 1009 - Back to Underworld 【DFS】
  14. ASP.NET MVC4 微信公众平台开发测试一: 验证
  15. Spark Structured Steaming实战
  16. AM5728设备数的描述
  17. 5. SAP S/4 运维基础知识(Basic Knowledge) - SAP S/4 Basis Learning
  18. 恢复chrome书签
  19. “易语言.飞扬”(EF)集成开发环境 EFIDE 0.2.2 下载地址
  20. 探索Ristretto量化工程—问题记录

热门文章

  1. boost::hana::string_c用法的测试程序
  2. boost::hana::tuple_c用法的测试程序
  3. boost::core模块实现fn地址
  4. Boost:双图bimap的范围标准方式的测试程序
  5. Boost:bimap双图lambda表达式的测试程序
  6. Boost:基于Boost的HTTP客户端的程序
  7. VTK:Shaders之ColorByNormal
  8. Qt Creator将对象连接到信号
  9. C++smallest circle 获取外接给定点集的最小圆的中心和半径算法(附完整源码)
  10. C++11新特性-容器的cbegin和cend函数