手机版
你好,游客 登录 注册
背景:
阅读新闻

Ubuntu 14.04 64bit下Caffe + Cuda6.5/Cuda7.0 安装配置教程

[日期:2016-12-21] 来源:Linux社区  作者:wangpengfei163 [字体:大 中 小]

第三部分:Caffe安装和测试

该部分主要安装Caffe相关工具

(一)安装MATLAB

假设matlab安装路径为:/usr/local/MATLAB/R2014b

matlab破解文件路径为/home/

1)挂载iso文件

把matlab的ISO文件挂载上去,需要注意的是:挂载上去之前,需要将iso文件中的Java/jar/install.jar文件替换为破解文件夹中的install.jar,可以使用UltraIso工具,替换保存后再使用文件挂载命令。为防止出现权限不够的问题,建议使用root用户。
文件挂载命令格式如下:
mount -o loop,rw /home/R2014b_glnxa64.iso /mnt
/mnt是你要挂载的文件夹目录,建议你自己新建一个文件夹。
2)安装matlab
进入解压后的matlab文件夹,运行 sudo ./install

选择"install manually without using the internet"项进行安装

输入"file installation key":12345-67890-12345-67890(随便都行)

激活:选择对应的”license.lic”文件进行激活(在Crack文件夹下面)

3)破解matlab
rm -rf /usr/local/MATLAB/R2014b/bin/glnxa64/libmwservices.so
把crack文件下的so文件拷贝过来:
cp /home/libmwservices.so /usr/local/MATLAB/R2014b/bin/glnxa64/
4)安装成功,运行
/usr/local/MATLAB/R2014b/bin/matlab
5)配置环境变量,使得直接输入matlab即可启动软件
vi /etc/profile
在文件末尾添加
export PATH=/usr/local/MATLAB/R2014b/bin:$PATH
保存并退出后使设置生效
source /etc/profile

 

(二)安装Python

 

sudo apt-get install python-dev python-pip
安装Python依赖包
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose 
python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx

 

(三)安装Intel MKL或者ATLAS

如果没有申请到Intel MKL,可以使用以下命令安装免费的ATLAS

  1. sudo apt-get install libatlas-base-dev 

如果申请到了MKL,解压下载到的文件,运行install_GUI.sh,然后按照图形界面步骤安装即可。

安装完成后,需要执行下列两个步骤:

1):在  /etc/ld.so.conf.d/  文件夹下添加 intel_mkl.conf文件,内容如下:

  1. /opt/intel/lib 
  2. /opt/intel/mkl/lib/intel64 

2):使库路径立即生效

  1. sudo ldconfig  [-v,可选] 
 (四)安装OpenCV(该选项【可选】)
安装2.4.10
1)下载安装脚本
2)进入目录 Install-OpenCV/Ubuntu/2.4
3)执行脚本
chmod +x *.sh
sh ./opencv2_4_10.sh 

(五)编译Caffe

1)下载Caffe源码包  Caffe源码包

2)进入caffe-master文件夹目录,复制一份 Makefile.config.examples

cp Makefile.config.example Makefile.config

3)修改Makefile.config文件中相关路径

  1. ## Refer to http://caffe.berkeleyvision.org/installation.html 
  2. # Contributions simplifying and improving our build system are welcome! 
  3.  
  4. # cuDNN acceleration switch (uncomment to build with cuDNN). 
  5. # USE_CUDNN := 1 
  6.  
  7. # CPU-only switch (uncomment to build without GPU support). 
  8. # CPU_ONLY := 1 
  9.  
  10. # uncomment to disable IO dependencies and corresponding data layers 
  11. # USE_OPENCV := 0 
  12. # USE_LEVELDB := 0 
  13. # USE_LMDB := 0 
  14.  
  15. # uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary) 
  16. #   You should not set this flag if you will be reading LMDBs with any 
  17. #   possibility of simultaneous read and write 
  18. # ALLOW_LMDB_NOLOCK := 1 
  19.  
  20. # Uncomment if you're using OpenCV 3 
  21. # OPENCV_VERSION := 3 
  22.  
  23. # To customize your choice of compiler, uncomment and set the following. 
  24. # N.B. the default for Linux is g++ and the default for OSX is clang++ 
  25. # CUSTOM_CXX := g++ 
  26.  
  27. # CUDA directory contains bin/ and lib/ directories that we need. 
  1. #CUDA的安装目录 
  2. CUDA_DIR := /usr/local/cuda 
  3. # On Ubuntu 14.04, if cuda tools are installed via 
  4. # "sudo apt-get install nvidia-cuda-toolkit" then use this instead: 
  5. # CUDA_DIR := /usr 
  6.  
  7. # CUDA architecture setting: going with all of them. 
  8. # For CUDA < 6.0, comment the *_50 lines for compatibility. 
  9. CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \ 
  10.         -gencode arch=compute_20,code=sm_21 \ 
  11.         -gencode arch=compute_30,code=sm_30 \ 
  12.         -gencode arch=compute_35,code=sm_35 \ 
  13.         -gencode arch=compute_50,code=sm_50 \ 
  14.         -gencode arch=compute_50,code=compute_50 
  15.  
  16. # BLAS choice: 
  17. # atlas for ATLAS (default) 
  18. # mkl for MKL 
  19. # open for OpenBlas 
  20. BLAS := atlas 
  21. # Custom (MKL/ATLAS/OpenBLAS) include and lib directories. 
  22. # Leave commented to accept the defaults for your choice of BLAS 
  23. # (which should work)! 
  24. # BLAS_INCLUDE := /path/to/your/blas 
  25. # BLAS_LIB := /path/to/your/blas 
  26.  
  27. # Homebrew puts openblas in a directory that is not on the standard search path 
  28. # BLAS_INCLUDE := $(shell brew --prefix openblas)/include 
  29. # BLAS_LIB := $(shell brew --prefix openblas)/lib 
  30.  
  31. # This is required only if you will compile the matlab interface. 
  32. # MATLAB directory should contain the mex binary in /bin. 
  1. #MATLAB的安装目录 

# 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.

  1. #PYTHON的安装目录 
  1. PYTHON_INCLUDE := /usr/include/python2.7 \ 
  2.         /usr/lib/python2.7/dist-packages/numpy/core/include 
  3. # Anaconda Python distribution is quite popular. Include path: 
  4. # Verify anaconda location, sometimes it's in root. 
  5. # ANACONDA_HOME := $(HOME)/anaconda 
  6. # PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ 
  7.         # $(ANACONDA_HOME)/include/python2.7 \ 
  8.         # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \ 
  9.  
  10. # Uncomment to use Python 3 (default is Python 2) 
  11. # PYTHON_LIBRARIES := boost_python3 python3.5m 
  12. # PYTHON_INCLUDE := /usr/include/python3.5m \ 
  13. #                 /usr/lib/python3.5/dist-packages/numpy/core/include 
  14.  
  15. # We need to be able to find libpythonX.X.so or .dylib. 
  16. PYTHON_LIB := /usr/lib 
  17. # PYTHON_LIB := $(ANACONDA_HOME)/lib 
  18.  
  19. # Homebrew installs numpy in a non standard path (keg only) 
  20. # PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include 
  21. # PYTHON_LIB += $(shell brew --prefix numpy)/lib 
  22.  
  23. # Uncomment to support layers written in Python (will link against Python libs) 
  24. # WITH_PYTHON_LAYER := 1 
  25.  
  26. # Whatever else you find you need goes here. 
  27. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include 
  28. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 
  29.  
  30. # If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies 
  31. # INCLUDE_DIRS += $(shell brew --prefix)/include 
  32. # LIBRARY_DIRS += $(shell brew --prefix)/lib 
  33.  
  34. # Uncomment to use `pkg-config` to specify OpenCV library paths. 
  35. # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.) 
  36. # USE_PKG_CONFIG := 1 
  37.  
  38. BUILD_DIR := build 
  39. DISTRIBUTE_DIR := distribute 
  40.  
  41. # Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171 
  42. # DEBUG := 1 
  43.  
  44. # The ID of the GPU that 'make runtest' will use to run unit tests. 
  45. TEST_GPUID := 0 
  46.  
  47. # enable pretty build (comment to see full commands) 
  48. Q ?= @  

4)编译Caffe

make all -j4 

make test  

make runtest

5)编译Matlab接口

make matcaffe

6)编译Python接口

make  pycaffe

至此,就可以学着运行Caffe中的Demo了。

如果你的机器没有可用的NVIDIA显卡,仍然可以使用Caffe,可以配置Caffe的CPU(无GPU)模式,在整个安装过程中,请跳过【第二部分:NVIDIA 驱动和CUDA 安装】,其他部分保持不变进行操作。

按照该教程在安装的过程中,有什么问题,欢迎在评论区留言,共同进步。

期待着NVIDIA将Caffe,Digits等一系列深度学习工具包集成到CUDA中吧,直接一键安装,相信美好的事情即将发生。

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-12/138625.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款