caffe学习笔记(1)安装 - Ubuntu 15.04

官方安装手册

备注:使用系统 - Ubuntu 15.04 64位操作系统(若系统位于虚拟机上,在安装CUDA后,Ubuntu将无法进入图形界面)

/**************************************************/

//准备工作:CUDA,OpenBLAS/ATLAS,Boost, protobuf,OpenCV, Python

/**************************************************/

方法一:

Ubuntu系统上安装caffe官方手册(第一次安装时竟没看到这个神器。。。)

0. 基本依赖项

$sudo apt-get install libprotobuf-dev  libleveldb-dev  libsnappy-dev  libopencv-dev  libhdf5-serial-dev  protobuf-compiler

$sudo apt-get install --no-install-recommends  libboost-all-dev

1. CUDA(使用方法二安装)

2. BLAS

若选择使用ATLAS:$sudo apt-get install libatlas-base-dev(安装较方便)

若选择使用OpenBLAS 则参考方法二安装;

3. Python(可选)

若需要使用Python,则$sudo apt-get install python-dev 安装pycaffe接口的Python头文件;

+方法二中的Python安装;

4. 剩余依赖项 (14.04及以上)

$sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

 

 

方法二:(因为系统空间问题失败。。。)

0. CUDA - 是一种由NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题

download

0.1 选择操作系统和安装类型

0.2 deb(network)方式的安装

下载上图所示软件到Ubuntu中;

执行后面3行命令即可;

 

1. OpenBLAS - 基础线性代数子程序库,里面拥有大量已经编写好的关于线性代数运算的程序

download

1.1 下载.zip / .tar.gz文件,解压;

1.2 安装命令

$sudo make

$sudo make PREFIX=/path/to/your/installation install

[1.3 将生成的.so库文件放入系统/lib文件夹中](可选步骤);

 

2. Boost库-为C++语言提供的扩展的C++程序库

download

方法一:(失败)

2.1 下载boost_1_60_0.tar.gz文件,解压;

2.2 安装命令

执行$sudo ./bootstrap.sh 编译成功;

执行$sudo ./bjam 开始编译,大约十几分钟,编译完成后出现:The Boost C++ Libraries were successfully built!

方法二:

直接执行命令:

$apt-cache search boost :搜索所有的boost库

$sudo apt-get install libboost-all-dev:安装相应的库

2.3 测试代码:利用boost库将字符串转换成整数

1 #include<iostream>
2 #include<boost/lexical_cast.hpp>
3 int main()
4 {
5    int a = boost::lexical_cast<int>("123456");
6    std::cout << a <<std::endl;
7    return 0;
8 }

 

 

3. protobuf - protocol buffer:google的一种数据交换的格式

方法一:根据源码安装(失败)

download

3.1 下载,并解压;

3.2 安装命令

C++下安装指南

安装编译工具$sudo apt-get install autoconf automake libtool curl

执行$./autogen.sh 生成configure脚本;

失败未解决:

提示 - Google Mock not present.  Fetching gmock-1.7.0 from the web... 未成功

解决:是否需要安装Google Mock?Google Mock安装指南 

 

开始编译:

$./configure

$make

$make check

$sudo make install

$sudo ldconfig # refresh shared library cache.

 方法二:(成功)

sudo apt-get install protobuf-compiler

 

4. OpenCV(安装时间较长)

利用自动脚本安装(脚本地址

Ubuntu执行:

$cd Ubuntu

$chmod +x *

$./opencv_latest.sh

 

5. Python(安装时间较长)

Ubuntu中缺省安装了Python;

执行$sudo apt-get install python-pip 安装pip(Python的一个安装和管理扩展库的工具);

下载caffe,解压,再进入python文件夹下,执行$ for req in $(requirements.txt); do pip install $req; done 操作,安装caffe中对Python的依赖项;

 

/*****************************/

//安装caffe

/****************************/

download

关键在于正确配置Makefile.config文件:

cp Makefile.config.example Makefile.config

根据情况修改配置:

CUDA_DIR;

BLAS:=open;(使用OpenBLAS)

未使用python接口则将对应的参数注释掉;

INCLUDE_DIRS和LIBRARY_DIRS下需要加入caffe所需要的所有头文件和库目录的文件夹地址;

 

配置完成后,执行命令:(这部分操作中使用的是cmake)

$make all - 编译生成caffe的库文件_caffe.so

 

posted on 2016-03-03 17:08  tanfy  阅读(348)  评论(0编辑  收藏  举报

导航