【转载】Caffe (Convolution Architecture For Feature Extraction)

Caffe (Convolution Architecture For Feature Extraction)作为深度学习CNN一个非常火的框架,对于初学者来说,搭建Linux下的Caffe平台是学习深度学习关键的一步,其过程也比较繁琐,回想起当初折腾的那几天,遂总结一下Ubuntu14.04的配置过程,方便以后新手能在此少走弯路。

1. 安装build-essentials

安装开发所需要的一些基本包

sudo apt-get install build-essential

2. 安装NVIDIA驱动

输入下列命令添加驱动源

sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update

安装340版本驱动(具体版本取决于电脑显卡的型号,详细可到NVIDIA官网查看)

sudo apt-get install nvidia-340

安装完成后,继续安装下列包

sudo apt-get install nvidia-340-uvm

安装驱动完毕,reboot.

3. 安装CUDA 6.5

CUDA的Deb包安装较为简单,按照官网流程,事先安装必要的库

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev

3.1 安装CUDA

然后通过以下命令获取Ubuntu 14.04 CUDA相关的repository package

$ sudo dpkg -i cuda-repo-ubuntu1404_6.5-14_amd64.deb
$ sudo apt-get update

然后开始安装CUDA Toolkit

$ sudo apt-get install cuda

此时需要下载较长时间,网速较慢的中途可以出去吃个饭~

3.2 环境配置

CUDA安装完毕后,需要对.bashrc加入一下命令来配置环境

export CUDA_HOME=/usr/local/cuda-6.5
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 

PATH=${CUDA_HOME}/bin:${PATH}
export PATH

3.3 安装CUDA SAMPLE

通过复制SDK samples 到主目录下,完成整个编译过程

$ cuda-install-samples-6.5.sh  ~
$ cd ~/NVIDIA_CUDA-6.5_Samples
$ make

如果以上过程都成功后,可以通过运行bin/x86_64/linux/release 下的deviceQuery来验证一下。如果出现以下信息,则说明驱动以及显卡安装成功

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 670"
  CUDA Driver Version / Runtime Version          6.5 / 6.5
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 4095 MBytes (4294246400 bytes)
  ( 7) Multiprocessors, (192) CUDA Cores/MP:     1344 CUDA Cores
  GPU Clock rate:                                1098 MHz (1.10 GHz)
  Memory Clock rate:                             3105 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.5, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GeForce GTX 670
Result = PASS

4. 安装BLAS

Caffe的BLAS可以有三种选择,分别为atlas、mkl以及openBLAS。对于mkl可以到intel官网下载,解压完成后又一个install_GUI.sh文件,执行该文件会出现图形安装界面,根据说明一步一步执行即可。

也可对openBLAS源码进行编译,不过需要gcc以及gfortran等相关编译器。个人认为比较便捷的是atlas,在Caffe官网上有相关的介绍,对于Ubuntu,通过以下命令可以下载atlas

sudo apt-get install libatlas-base-dev

5. 安装OpenCV

OpenCV库安装可以通过网上写好的脚本进行下载:https://github.com/jayrambhia/Install-OpenCV

解压文档后,进入Ubuntu/2.4 给所有的shell脚本加上可执行权限

chmod +x *.sh

然后执行 opencv2_4_9.sh 安装最新版本,注意,OpenCV 2.4.9不支持gcc-4.9以上的编译器!!

6. 安装其他dependencies

对于Ubuntu 14.04,执行以下命令下载其他相关依赖库文件

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler

7. 安装python以及Matlab

首先安装pip和python –dev

sudo apt-get install python-dev python-pip

以及caffe python wrapper所需要的额外包

sudo pip install -r /path/to/caffe/python/requirements.txt

Matlab接口需要额外安装Matlab程序

Last shot --- 编译Caffe

完成所有的环境配置,终于可以编译caffe了,通过官网下载caffe源码,进入根目录caffe-master,首先复制一份makefile

cp Makefile.config.example Makefile.config

然后修改里面的内容,主要有:

CPU_ONLY   是否采用cpu模式,否则选择CUDNN(这里的CUDNN需要在NVIDIA-CUDNN下载,还有通过email注册申请才能通过审核)

BLAS:=atlas(也可以是open或者mkl)

DEBUG  如果需要debug模式

MATLAB_DIR 如果需要采用matlab 接口

完成配置后,可以进行编译了

make all -j4
make test
make runtest

最后如果都能正常,证明caffe里面所有的例子程序都可以运行了,放心都跑CIFAR、MNIST以及ImageNet吧~~

时间: 2024-08-10 02:24:09

【转载】Caffe (Convolution Architecture For Feature Extraction)的相关文章

ufldl学习笔记与编程作业:Feature Extraction Using Convolution,Pooling(卷积和池化抽取特征)

ufldl出了新教程,感觉比之前的好,从基础讲起,系统清晰,又有编程实践. 在deep learning高质量群里面听一些前辈说,不必深究其他机器学习的算法,可以直接来学dl. 于是最近就开始搞这个了,教程加上matlab编程,就是完美啊. 新教程的地址是:http://ufldl.stanford.edu/tutorial/ 学习链接: http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution

Feature Engineering versus Feature Extraction: Game On!

Feature Engineering versus Feature Extraction: Game On! "Feature engineering" is a fancy term for making sure that your predictors are encoded in the model in a manner that makes it as easy as possible for the model to achieve good performance.

Feature extraction - sklearn文本特征提取

http://blog.csdn.net/pipisorry/article/details/41957763 文本特征提取 词袋(Bag of Words)表征 文本分析是机器学习算法的主要应用领域.但是,文本分析的原始数据无法直接丢给算法,这些原始数据是一组符号,因为大多数算法期望的输入是固定长度的数值特征向量而不是不同长度的文本文件.为了解决这个问题,scikit-learn提供了一些实用工具可以用最常见的方式从文本内容中抽取数值特征,比如说: 标记(tokenizing)文本以及为每一个

Spatio-temporal feature extraction and representation for RGB-D human action recognition

propose a novel and effective framework to largely improve the performance of human action recognition using both the RGB videos and depth maps. The key contribution is the proposition of the sparse coding-based temporal pyramid matching approach (Sc

scikit-learn:4.2. Feature extraction(特征提取,不是特征选择)

http://scikit-learn.org/stable/modules/feature_extraction.html 带病在网吧里. ..... 写.求支持. .. 1.首先澄清两个概念:特征提取和特征选择( Feature extraction is very different from Feature selection ). the former consists in transforming arbitrary data, such as text or images, in

Feature extraction using convolution

http://ufldl.stanford.edu/wiki/index.php/Feature_extraction_using_convolution http://ufldl.stanford.edu/wiki/index.php/卷积特征提取

scikit-learn:4.2.3. Text feature extraction

http://scikit-learn.org/stable/modules/feature_extraction.html 4.2节内容太多,因此将文本特征提取单独作为一块. 1.the bag of words representation 将raw data表示成长度固定的数字特征向量.scikit-learn提供了三个方式: tokenizing:给每个token(字.词,粒度自己把握)一个整数索引id counting:每一个token在每一个文档中出现的次数 normalizing:

TensorFlow与caffe中卷积层feature map大小计算

刚刚接触Tensorflow,由于是做图像处理,因此接触比较多的还是卷及神经网络,其中会涉及到在经过卷积层或者pooling层之后,图像Feature map的大小计算,之前一直以为是与caffe相同的,后来查阅了资料发现并不相同,将计算公式贴在这里,以便查阅: caffe中: TF中: 参考: http://blog.csdn.net/lujiandong1/article/details/53728053 http://www.cnblogs.com/denny402/p/5071126.h

【Network Architecture】Feature Pyramid Networks for Object Detection(FPN)论文解析(转)

目录 0. 前言 1. 博客一 2.. 博客二 0. 前言 ??这篇论文提出了一种新的特征融合方式来解决多尺度问题, 感觉挺有创新性的, 如果需要与其他网络进行拼接,还是需要再回到原文看一下细节.这里转了两篇比较好的博客作为备忘. 1. 博客一 这篇论文是CVPR2017年的文章,采用特征金字塔做目标检测,有许多亮点,特来分享. 论文:feature pyramid networks for object detection 论文链接:https://arxiv.org/abs/1612.031