ubuntu14.04安装caffe+digits
来源:互联网 发布:vr视频软件 编辑:程序博客网 时间:2024/04/30 08:36
最近在研究深度学习,对自己安装caffe+digits的过程进行一个总结。
1、安装ubuntu14.04
这里强烈推荐安装ubuntu14.04版本,不然caffe在其他的linux版本上安装总是会遇到很多莫名其妙的问题。(linux高手可忽略)
使用U盘安装,在bios的bootsequence>boot list option选择UEFI
ubuntu的安装这里不必多说,重点注意分区,留有足够大的空间存储数据,
还有一些训练会需要较大的内存,内存不够的情况下可以将交换分区(swap)划的大一些。还要留一定大小的启动分区
安装后替换源,作者目前使用的是清华ipv6的源
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trusty mainrestricted universe multiverse
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-security main restricted universe multiverse
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-updates main restricted universe multiverse
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-proposed main restricted universe multiverse
deb http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-backports main restricted universe multiverse
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/ trustymain restricted universe multiverse
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-security main restricted universe multiverse
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-updates main restricted universe multiverse
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-proposed main restricted universe multiverse
deb-src http://mirrors.6.tuna.tsinghua.edu.cn/ubuntu/trusty-backports main restricted universe multiverse
deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu/ trusty/
替换pypi 源
pypi 镜像每 5分钟同步一次。
临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simplesome-package
注意,simple 不能少, 是 https 而不是 http
设为默认
修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,例如
[global]
index-url =https://pypi.tuna.tsinghua.edu.cn/simple2安装cuda-7.5
作者的GPU是GTX970,可以支持CUDA7.5版本,这个安装没什么可说的,按照安装手册一步步来就可以。
下载地址:https://developer.nvidia.com/cuda-downloads
3安装cudnn-v4.0
cudnn4.0是目前cudnn最新的版本,在进一步提高速度的同时,加入了batch normalization等新技术的支持
到nvidia的官网https://developer.nvidia.com/rdp/cudnn-download下载
作者之前安装过别的版本的cuda和cudnn,所以在安装新版本的时候要把旧版本删掉,特别是路径/usr/local/cuda/lib64下面的要删干净,不然caffe会找到旧版本的cuda或cudnn。
4安装caffe
作者是到nvidia的官网下载caffe,注意不是BVLC版本的caffe,而是nvidia的分支,最新版本的caffe只支持cudnnv4.0,所以一定要安装正确的cudnn版本
在安装之前注意更改LD_LIBRARY_PATH
在~/.bashrc的最后加上
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
caffe的安装可以参照http://caffe.berkeleyvision.org/installation.html
首先需要预装一些支持库:
其中BLAS 支持 ATLAS, MKL或OpenBLAS,推荐使用OpenBLAS,速度更快。
如果不知道openblas在源中的名字,可以执行以下命令搜索
apt-cache search openblas
安装openblas命令
sudo apt-get install libopenblas-dev
在安装好支持后进行编译,caffe的编译有两种方式,一种是直接make,需要自己更改 Makefile.config文件,更改的地方有
USE_CUDNN := 1(去掉这行的注释,启用cudnn加速)
BLAS := open(blas默认使用的是atlas,替换为为open,使用openblas版本)
另外一种方式是cmake,会自动找到caffe依赖库的路径。作者觉得这两种方式其实都差不多。
caffe在ubuntu上面安装没有什么问题,顺利编译通过。这里提一下之前在suse上安装的时候cmake过程中遇到一个问题:
error while loading shared libraries: libpython2.7.a(object.o)relocation R_X86_64_32S against `alocal symbol' can not be used when making a shared object; recompile with -fPIC,即提示需要recompile with -fpic。一开始我理解错误,以为是caffe需要重新编译,就不停的重编caffe,后来发现是python需要重新编译。这里把caffe和python使用-fPIC重新编译的方法都写一下:
caffe在build/CmakeCache.txt中设置CMAKE_CXX_FLAGS:STRING=-fPIC,之后再重新运行make
python的版本是2.7.10,重新编译需要运行./configure --enable-shared with –fPIC,这样在生成的makefile文件中就有了fpic标记。如果之前安装了python,注意下面以前的python库不论是静态库还是动态库都要删掉。
5安装digits
安装digits之前不要忘记在编译pycaffe。
作者安装的是digits3.0版本,也遇到了一个问题。按照手册安装完之后启动不起来服务。这是因为digits3.0使用的是新版本的Flask,需要将老版的Flask-WTF DataRequired重命名为Required
在 /usr/lib/python2.7/dist-packages/wtforms/validators.py在最后一行添加
DataRequired = Required
或者使用pip安装最新版本的flask, 不要用apt-get安装
- ubuntu14.04安装caffe+digits
- Ubuntu14.04 Caffe安装
- Ubuntu14.04 Caffe安装
- Caffe安装 Ubuntu14.04
- Ubuntu14.04 安装 Caffe
- ubuntu14.04 安装 caffe
- Ubuntu14.04 安装caffe
- ubuntu14.04 + caffe安装
- Ubuntu14.04 安装caffe
- Ubuntu14.04 安装Caffe
- caffe ubuntu14.04安装
- ubuntu14.04 安装caffe
- ubuntu14.04 + caffe安装
- ubuntu14.04安装caffe
- Ubuntu14.04安装caffe指南
- Ubuntu14.04下安装Caffe
- Ubuntu14.04上安装caffe
- 在Ubuntu14.04 安装Caffe
- 进程基础的一些相关函数
- ”google play 服务”(Google play services) 如何安装
- jQuery对radio,checkbox,select元素的操作
- execl家族函数总结
- 嵌入式linux文件系统相关
- ubuntu14.04安装caffe+digits
- 【Android开发小记--8】传感器 以及 指南针的实现
- 计算机网络6--多路复用技术
- BO SDK - 列出所有 web intelligence 报表用到的 universe object
- Android基础之Fragment
- Codeforces Round #322 (Div. 2) F. Zublicanes and Mumocrates(树形dp)
- JavaScript
- hdu1512 Monkey King【左偏堆、并查集】
- MFC CListView 设置和获取item图片