root@k-Lenovo:/home/k# sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
root@k-Lenovo:/home/k# sudo apt-get install --no-install-recommends libboost-all-dev
root@k-Lenovo:~# sudo apt-get install linux-headers-$(uname -r)

BLAS

root@k-Lenovo:/home/k# sudo apt-get install libatlas-base-dev

其他依赖项

root@k-Lenovo:/home/k# sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

OpenCV

root@k-Lenovo:/home/k# sudo apt-get install build-essential
root@k-Lenovo:/home/k# sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
root@k-Lenovo:/home/k# sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
1
2
3
4
git clone https://github.com/Itseez/opencv.git  
cd ~/opencv  
mkdir build  
cd build
http://pan.baidu.com/s/1c1PF9w0   #opencv下载
root@k-Lenovo:~/opencv/build# cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local  ..
root@k-Lenovo:~/opencv/build# ls
3rdparty CPackSourceConfig.cmake Makefile
apps CTestTestfile.cmake modules
bin custom_hal.hpp opencv2
CMakeCache.txt cvconfig.h OpenCVConfig.cmake
CMakeFiles data OpenCVConfig-version.cmake
cmake_install.cmake doc OpenCVModules.cmake
cmake_uninstall.cmake include test-reports
CMakeVars.txt junk unix-install
CPackConfig.cmake lib version_string.tmp
root@k-Lenovo:~/opencv/build# make -j4
root@k-Lenovo:~/opencv/build#  sudo make install

Caffe

root@k-Lenovo:~/caffe# ls
caffe.cloc data INSTALL.md models tools
cmake docker LICENSE python
CMakeLists.txt docs Makefile README.md
CONTRIBUTING.md examples Makefile.config.example scripts
CONTRIBUTORS.md include matlab src
root@k-Lenovo:~/caffe# pwd
/root/caffe
root@k-Lenovo:~/caffe# cp Makefile.config.example Makefile.config
root@k-Lenovo:~/caffe# vim Makefile
endif
ifeq ($(USE_OPENCV), 1)
LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs #增加opencv_imgcodecs ifeq ($(OPENCV_VERSION), 3)
LIBRARIES += opencv_imgcodecs
endif
root@k-Lenovo:~/caffe# make all
root@k-Lenovo:~/caffe# make all
CXX src/caffe/common.cpp
In file included from ./include/caffe/common.hpp:19:0,
from src/caffe/common.cpp:7:
./include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
#include <cublas_v2.h>
^
compilation terminated.
make: *** [.build_release/src/caffe/common.o] Error 1
root@k-Lenovo:~/caffe# vi Makefile.config
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1 #关键
root@k-Lenovo:~/caffe# make all
root@k-Lenovo:~/caffe# make test
root@k-Lenovo:~/caffe# make runtest
root@k-Lenovo:~/caffe# make runtest
.build_release/tools/caffe
.build_release/tools/caffe: error while loading shared libraries: libopencv_core.so.3.1: cannot open shared object file: No such file or directory
make: *** [runtest] Error 127
root@k-Lenovo:~/caffe# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
root@k-Lenovo:~/caffe# make runtest
... [----------] 1 test from SolverTest/1, where TypeParam = caffe::CPUDevice<double>
[ RUN ] SolverTest/1.TestInitTrainTestNets
[ OK ] SolverTest/1.TestInitTrainTestNets (1 ms)
[----------] 1 test from SolverTest/1 (1 ms total) [----------] 2 tests from EuclideanLossLayerTest/1, where TypeParam = caffe::CPUDevice<double>
[ RUN ] EuclideanLossLayerTest/1.TestGradient
[ OK ] EuclideanLossLayerTest/1.TestGradient (0 ms)
[ RUN ] EuclideanLossLayerTest/1.TestForward
[ OK ] EuclideanLossLayerTest/1.TestForward (0 ms)
[----------] 2 tests from EuclideanLossLayerTest/1 (0 ms total) [----------] Global test environment tear-down
[==========] 1054 tests from 146 test cases ran. (37419 ms total)
[ PASSED ] 1054 tests.

安装python和pip

root@k-Lenovo:~/caffe# python --version
Python 2.7.6

pip是专门用于安装python各种依赖库的,所以我们这里安装一下pip1.5.6  http://pan.baidu.com/s/1cfsHv4

root@k-Lenovo:~# wget  https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
--2016-05-03 14:40:36-- https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
Resolving pypi.python.org (pypi.python.org)... 103.245.224.223
Connecting to pypi.python.org (pypi.python.org)|103.245.224.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 938120 (916K) [application/octet-stream]
Saving to: ‘pip-1.5.6.tar.gz’ 100%[===================================================>] 938,120 294KB/s in 3.1s 2016-05-03 14:40:40 (294 KB/s) - ‘pip-1.5.6.tar.gz’ saved [938120/938120]
root@k-Lenovo:~# cd pip-1.5.6
root@k-Lenovo:~/pip-1.5.6# ls
AUTHORS.txt docs MANIFEST.in pip.egg-info PROJECT.txt setup.cfg
CHANGES.txt LICENSE.txt pip PKG-INFO README.rst setup.py
root@k-Lenovo:~/pip-1.5.6# sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools

有些电脑可能会提示 no moudle name setuptools 的错误,这是没有安装setuptools的原因。那就需要先安装一下setuptools, 到https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz 下载安装包setuptools-19.2.tar.gz,然后解压执行

http://pan.baidu.com/s/1dFx31Ax

root@k-Lenovo:~# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz
--2016-05-03 14:44:07-- https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz
Resolving pypi.python.org (pypi.python.org)... 103.245.224.223
Connecting to pypi.python.org (pypi.python.org)|103.245.224.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 641777 (627K) [application/octet-stream]
Saving to: ‘setuptools-19.2.tar.gz’ 100%[===================================================>] 641,777 287KB/s in 2.2s 2016-05-03 14:44:11 (287 KB/s) - ‘setuptools-19.2.tar.gz’ saved [641777/641777]
root@k-Lenovo:~# ls
caffe opencv pip-1.5.6 setuptools-19.2
caffe.tar opencv.tar pip-1.5.6.tar.gz setuptools-19.2.tar.gz
root@k-Lenovo:~# cd setuptools-19.2
root@k-Lenovo:~/setuptools-19.2# ls
bootstrap.py ez_setup.py msvc-build-launcher.cmd release.py setuptools.egg-info
CHANGES.txt launcher.c PKG-INFO scripts tests
conftest.py Makefile pkg_resources setup.cfg tox.ini
docs MANIFEST.in pytest.ini setup.py
easy_install.py _markerlib README.txt setuptools
root@k-Lenovo:~/setuptools-19.2# sudo python setup.py install
root@k-Lenovo:~# cd pip-1.5.6
root@k-Lenovo:~/pip-1.5.6# sudo python setup.py install
安装pyhon接口依赖库

在caffe根目录的python文件夹下,有一个requirements.txt的清单文件,上面列出了需要的依赖库,按照这个清单安装就可以了。

在安装scipy库的时候,需要fortran编译器(gfortran),如果没有这个编译器就会报错,因此,我们可以先安装一下。

首先回到caffe的根目录,然后执行安装代码:
root@k-Lenovo:~/pip-1.5.6# cd ~/caffe
root@k-Lenovo:~/caffe# sudo apt-get install gfortran
root@k-Lenovo:~/caffe# cd python/
root@k-Lenovo:~/caffe/python# ls
caffe classify.py CMakeLists.txt detect.py draw_net.py requirements.txt
root@k-Lenovo:~/caffe/python# for req in $(cat requirements.txt); do sudo pip install $req; done
root@k-Lenovo:~/caffe/python# cd ..
root@k-Lenovo:~/caffe# ls
build CONTRIBUTORS.md examples Makefile.config README.md
caffe.cloc data include Makefile.config.example scripts
cmake distribute INSTALL.md matlab src
CMakeLists.txt docker LICENSE models tools
CONTRIBUTING.md docs Makefile python
root@k-Lenovo:~/caffe# sudo pip install -r python/requirements.txt
编译python接口

首先,将caffe根目录下的python文件夹加入到环境变量

打开配置文件bashrc
root@k-Lenovo:~/caffe# sudo vi ~/.bashrc
export PYTHONPATH=/root/caffe/python:$PYTHONPATH  #追加到最后
root@k-Lenovo:~/caffe/python# sudo ldconfig
root@k-Lenovo:~/caffe# sudo make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto

查看 python/caffe/ 目录下,除了原先的一堆py后缀文件,现在多出了一堆pyc后缀文件

/root/caffe/python/caffe
root@k-Lenovo:~/caffe/python/caffe# cd ..
root@k-Lenovo:~/caffe/python# ls
caffe classify.py CMakeLists.txt detect.py draw_net.py requirements.txt
root@k-Lenovo:~/caffe/python# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Net<float> > already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Blob<float> > already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Solver<float> > already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
>>>
root@k-Lenovo:~/caffe/python# cd caffe/
root@k-Lenovo:~/caffe/python/caffe# ls
_caffe.cpp classifier.pyc detector.pyc __init__.py io.pyc proto test
_caffe.so coord_map.py draw.py __init__.pyc net_spec.py pycaffe.py
classifier.py detector.py imagenet io.py net_spec.pyc pycaffe.pyc
安装好caffe后,将caffe/python的路径添加到用户环境变量~/.bashrc中:
export PYTHONPATH=/root/caffe/python:$PYTHONPATH #这个是之前写的

或者执行:

root@k-Lenovo:~/caffe# export PYTHONPATH=/root/caffe/python:$PYTHONPATH

安装jupyter

学会了python还不行,还得学习一下ipython,后者更加方便快捷,更有自动补全功能。而ipython notebook是ipython的最好展现方式。最新的版本改名为jupyter notebook,我们先来安装一下。
root@k-Lenovo:~/caffe/python# sudo pip install jupyter

安装成功后,运行notebook

root@k-Lenovo:~/caffe/python# jupyter notebook

caffe 无GPU 环境搭建的更多相关文章

  1. Ubuntu14.04+caffe+cuda7.5 环境搭建以及MNIST数据集的训练与测试

    Ubuntu14.04+caffe+cuda 环境搭建以及MNIST数据集的训练与测试 一.ubuntu14.04的安装: ubuntu的安装是一件十分简单的事情,这里给出一个参考教程: http:/ ...

  2. win10 caffe GPU环境搭建

    一.准备 系统:win10 显卡:gtx1050Ti 前期的一些必要软件安装,包括python3.5.matlab2016.vs2015.git, 可参考:win10+vs2015编译caffe的cp ...

  3. caffe版faster-RCNN环境搭建

    faster-rcnn提出论文: <Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks& ...

  4. ubuntu16.04下配置caffe无GPU

    1. 安装依赖项  1 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5- ...

  5. Windows下VS2013+Caffe无GPU配置

    Windows版本的caffe工具包下载地址: 点击打开链接 1. 将下载的caffe-master.zip解压到 D:\Software\Caffe 文件夹下,把 D:\Software\Caffe ...

  6. windows环境Caffe安装配置步骤(无GPU)及mnist训练

    在硕士第二年,义无反顾地投身到了深度学习的浪潮中.从之前的惯性导航转到这个方向,一切从头开始,在此,仅以此文记录自己的打怪之路. 最初的想法是动手熟悉Caffe,考虑到直接上手Ubuntu会有些难度, ...

  7. Windows7 64下搭建Caffe+python接口环境

    参考链接: http://www.cnblogs.com/yixuan-xu/p/5858595.html http://www.cnblogs.com/zf-blog/p/6139044.html ...

  8. 【神经网络与深度学习】Win10+VS2015 caffe环境搭建(极其详细)

    caffe是好用,可是配置其环境实在是太痛苦了,依赖的库很多不说,在VS上编译还各种报错,你能想象那种被一百多个红色提示所笼罩的恐惧.  且网上很多教程是VS2013环境下编译的,问人很多也说让我把1 ...

  9. 【神经网络与深度学习】caffe+VS2013+Windows无GPU快速配置教程

    首先来一波地址: happynear大神的第三方caffe:http://blog.csdn.net/happynear/article/details/45372231 Neil Z大神的第三方ca ...

随机推荐

  1. Android中调用百度地图

    一.调用百度地图 --第一种方法 1.下载百度地图SDK SDK可以拆分下载,需要使用那一部分功能就下载相应包含的SDK,如下图 核心的的jar 和so包,放在工程中的libs目录下 2.申请key ...

  2. MyEclipse修改项目名称后,部署到 tomcat问题

    问题描述: 修改项目名称后,部署到tomcat问题 解决方案: 项目->属性->myelcipse->web下,修 改web context root就可! 要在eclipse里面改 ...

  3. java内存模型及GC原理

    java内存模型 sun官方网站:sun java 虚拟机模型 JVM内存模型中分两大块,一块是 NEW Generation, 另一块是Old Generation. 在New Generation ...

  4. mongodb(基础用法)

    驱动和客户端库 https://mongodb-documentation.readthedocs.org/en/latest/ecosystem/drivers.html#id2 https://m ...

  5. how to combine jpg + separate alpha in png?

    http://www.tasharen.com/forum/index.php?topic=4018.msg19784#msg19784 I have tons of large sprites, I ...

  6. nl命令详解

    nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 cat -n 有点不太一样, nl 可以将行号做比较多的显示设计,包括位数与是否自动补齐 0 等 ...

  7. JavaScriptSerializer中日期序列化问题解决方案

    JavaScriptSerializer中日期序列化问题解决方案 直接进入主题: class Student { public int age { get; set; } public DateTim ...

  8. C#比较时间大小 1、比较时间大小的实验

    1.比较时间大小的实验    string st1="12:13"; string st2="14:14"; DateTime dt1=Convert.ToDa ...

  9. Linux 下 Redis 安装详解

    文章来源:www.oschina.net/question/12_18065 redis作为NoSQL数据库的一种应用,响应速度和命中率上还是比较高效的.项目中需要用集中式可横向扩展的缓存框架,做了一 ...

  10. sublime Text 3实用功能和常用快捷键收集

    下面是我通过网上视频教程或文本资料学习sublime Text3时收集的一些实用功能和常用快捷键,现在分享出来,如果还有其它的好用的功能可以在下面留言,以便互相学习. PS:ST3在Mac OX与Wi ...