20170122-dev-install-caffe

layout title categories tags date description
post
深度学习:玩转caffe之安装
blog
framework
tools
2017-01-22 12:20:20 -0800
Caffe install in Ubuntu

Caffe安装初探

引言

做深度学习,没用玩过深度学习框架caffe就有点说不过去了。虽然自己的小机器显卡计算能力很弱,但是希望在cuda上跑caffe的心却没有停止过。从ubuntu12.04一直折腾到16.04,cuda从6.5也release到了8.0,中间走过的弯路很多。

  • cuda与系统的适配能力问题
  • ubuntu系统的问题
  • caffe的框架的问题 经过这几年的发展,现在caffe的安装已经变得异常简单便捷。在此记录一下曾经的坑。 建议: 直接在机器上安装linux进行下面操作,要是在虚拟机里整,几乎没有什么戏,而且会把你给整疯的。

安装BLAS

BLAS 可以通过mkl atlas openblas等实现,性能比较 发现这个mkl是不错的,但是要收费 最后选择默认的Atlas

********** Important Install Information: CPU THROTTLING *********** Architecture configured as Corei2 (27) /tmp/ccp8Kkgo.o: In function ATL_tmpnam': /home/charles/Repo/ATLAS//CONFIG/include/atlas_sys.h:224: warning: the use of tmpnam' is dangerous, better use `mkstemp'

Clock rate configured as 800Mhz

Maximum number of threads configured as  4
probe_pmake.o: In function `ATL_tmpnam':
/home/charles/Repo/ATLAS//CONFIG/include/atlas_sys.h:224: warning: the use of `tmpnam` is dangerous, better use `mkstemp`
Parallel make command configured as '$(MAKE) -j 4'
CPU Throttling apparently enabled!
It appears you have cpu throttling enabled, which makes timings
unreliable and an ATLAS install nonsensical.  Aborting.
See ATLAS/INSTALL.txt for further information
xconfig exited with 1

******************************* Solution *************************** use ubuntu main software source switch to root admin

apt-get install gnome-applets cpufreq-selector -g performance -c 0

sudo apt-get install libatlas-base-dev

安装BOOST

  • preinstall boost should install following software
  • compile the source code 下载源代码,当前最新版本为version 1.60
wget http://downloads.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.gz
unpacking boost 1.60.tar.gz
source boot
./b2
./b2 install --prefix=/usr/local
#include <boost/lexical_cast.hpp>
#include <iostream>
int main()
{
    using boost::lexical_cast;
    int a = lexical_cast<int>("123");
    double b = lexical_cast<double>("123.12");
    std::cout<<a<<std::endl;
    std::cout<<b<<std::endl;
    return 0;
}

或者直接apt-get install libboost-all-dev

从7.5之后安装的方法简单得多

sudo apt-get --purge remove nvidia-*https://developer.nvidia.com/cuda-downloads下载对应的deb文件 到deb的下载目录下

sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb 
sudo apt-get update 
sudo apt-get install cuda
sudo reboot

完成,cuda和显卡驱动就都装好了;其他的什么都不用动 而网上大部分中文和英文的参考教程都是过时的,折腾几个小时不说还容易装不成。

查看机器参数是否满足CUDA计算的最低要求

lspci | grep -i nvidia
01:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/820M / GT 620M/625M/630M/720M] (rev a1)

参照nvidia 往年发布的gpus 我的机器为Compute Capability 2.1,是可以使用CUDA加速的。: )

不是所有Nvida显卡都支持cuDNN的

折腾了很久的cuDNN安装,后来才发现是自己的显卡太low了,不支持cuDNN,因为Compute Capability 才2.1,要支持cuDNN, Capability >= 3.0,查看自己显卡的计算能力

install cuDNN

PREREQUISITES CUDA 7.0 and a GPU of compute capability 3.0 or higher are required. Extract the cuDNN archive to a directory of your choice, referred to below as .Then follow the platform-specific instructions as follows.

LINUX

cd <installpath>
export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH

Add to your build and link process by adding -I to your compile line and -L -lcuDNN to your link line.

WINDOWS

Add to the PATH environment variable.

In your Visual Studio project properties, add to the Include Directories and Library Directories lists and add cuDNN.lib to Linker->Input->Additional Dependencies.

非GPU的自动安装脚本

Install Caffe Script

pyCaffe编译安装

  1. 首先要编译caffe成功,make pycaffe也成功
  2. 使得pycaffe可以被访问到, set PYTHONPATH=$PYTHONPATH:/path/to/caffe/python
  3. install dependencies python package.在python文件夹下面有requirements.txt文件,列出了所有有关的python package. pip install -r requirements.txt Note 这里一定要弄明白,默认情况下是使用python2.x的,如果你使用python3.x的话,请安装python3-pip,使用pip3进行安装,

综合一个安装cuda的教程

可以参考https://gwyve.github.io/博客,为了方便把gwyve的cuda

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值