caffe + ubuntu16.04 (version without GPU)

This Guide is based on caffe github wiki guide (https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-or-15.10-Installation-Guide )

Some parts of it have been changed to suit my computer.

  

The following guide includes the how-to instructions for the installation of BVLC/Caffe in Ubuntu 16.04 (preliminary procedure does not function with the current Cuda Toolkit) or 15.10 Linux (works well). This also includes the KUbuntu 16.04 or 15.10 and the related distributions.

Execute these commands first:

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install -y build-essential cmake git pkg-config

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

sudo apt-get install -y libatlas-base-dev 

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

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

# (Python general)
sudo apt-get install -y python-pip

# (Python 2.7 development files)
sudo apt-get install -y python-dev
sudo apt-get install -y python-numpy python-scipy

I didn‘t try python 3.5 to avoid a version confilct problem, and I also didn‘t use opencv 3.1 for the same reason.I just want to make it simple and function well.
# (OpenCV 2.4)
sudo apt-get install -y libopencv-dev

Go to the https://github.com/BVLC/caffe and download zip archive. Unpack it to ~/bin/ or any other location. Enter the caffe-master directory in the terminal window.

Copy the Makefile.config.example to Makefile.config like this:

cp Makefile.config.example Makefile.config

and open it for editing (with a text editor). I use the kate editor for this purpose, so the command that I execute goes as follows. You first need to install the kate editor with:

sudo apt-get install kate

and then you can edit the configuration file with:

kate ./Makefile.config &

The following line in the configuration file tells the program to use CPU only for the computations.

CPU_ONLY := 1

This is the typical setting for a computer without any NVIDIA graphics card and it is typical for the installation of Caffe inside the typical virtual machine. (Notice that there is a special type of virtual machine inside the Ubuntu host machine that can access the physical NVIDIA graphics card directly. See https://github.com/NVIDIA/nvidia-docker)

Change the line accordingly by commenting it out (# CPU_ONLY := 1) if you have an NVIDIA graphics card with the proprietary driver, CUDA toolkit and CUDNN installed. The Makefile.config should contain the following lines, so find them and fill them in.

PYTHON_INCLUDE := /usr/include/python2.7 /usr/lib/python2.7/dist-packages/numpy/core/include

(For ways to create an isolated Python environment, explore the topic of virtual environments here: http://docs.python-guide.org/en/latest/dev/virtualenvs/)

WITH_PYTHON_LAYER := 1

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial

LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial

Now lets continue with the instructions for version 15.10 first, followed by instructions for 16.04 users.

Execute the additional commands:

find . -type f -exec sed -i -e ‘s^"hdf5.h"^"hdf5/serial/hdf5.h"^g‘ -e ‘s^"hdf5_hl.h"^"hdf5/serial/hdf5_hl.h"^g‘ ‘{}‘ \;

cd /usr/lib/x86_64-linux-gnu

sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so

sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

The above commands will need to be executed for Ubuntu 16.04 as well, but the file versions for libhdf5_serial.so and libhdf5_serial_h1.so are different and so the last two lines will need to be altered. Visit /usr/lib/x86_64-linux-gnu/ and list the relevant contents of that directory using a command

  such as ls | grep hdf5

The versions of libhdf5 that need to be linked to are 10.1.0 and 10.0.2 respectively.

So, for Ubuntu16.04, execute the additional commands like this:

  find . -type f -exec sed -i -e ‘s^"hdf5.h"^"hdf5/serial/hdf5.h"^g‘ -e ‘s^"hdf5_hl.h"^"hdf5/serial/hdf5_hl.h"^g‘ ‘{}‘ \;

  cd /usr/lib/x86_64-linux-gnu

  such as ls | grep hdf5

  sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so

  sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so

     

Now for both platforms lets return to the unpacked Caffe directory caffe-master and enter these commands:

cd python

for req in $(cat requirements.txt); do pip install $req; done


NOTE: If the Ubuntu operating system was updated, perhaps the Python layer needs to be updated and recompiled, because the Python module no longer works. Perform this step again in that case.

for req in $(cat requirements.txt); do pip install $req; done

In case of any problems, try:

for req in $(cat requirements.txt); do sudo -H pip install $req --upgrade; done


The build process will fail in Ubuntu 16.05 due to the GCC 5.x compiler, when compiling Cuda 7.5 sources. The updated version of Cuda Toolkit 8.0RC is compatible with GCC 5.x compiler in Ubuntu 16.05. Once Cuda Toolkit 8.0RC is installed, Caffe will successfully build and run in Ubuntu 16.05.

In any case, the next step is to execute the following code to build Caffe:

cd ..

(now you are in caffe-master directory)

make all

make test

make runtest

make pycaffe      -should be finished already, so you can omit this one

make distribute

Note that the build process can be sped up by appending -j $(($(nproc) + 1)) to the above commands, which distributes the build across the available processors on your system. For example:

make all

can become

make all -j $(($(nproc) + 1))

In order to make the Python work with Caffe, open the file ~/.bashrc for editing in your favorite text editor. There, add the following line at the end of file:

export PYTHONPATH=/path/to/caffe-master/python:$PYTHONPATH

You can also execute that same line immediately as a command for immediate effects.

 
时间: 2024-11-11 03:27:06

caffe + ubuntu16.04 (version without GPU)的相关文章

深度学习caffe:Ubuntu16.04安装指南(3)

caffe [完全版] 2017-01-19 配置如下: caffe + cuda8.0[GPU加速[只支持N卡]] + cudnn5.1 + opencv3.1 + python2.7 + boost58 , 主要参考了caffe官方教程 Ubuntu 16.04 or 15.10 Installation Guide 开始前,请先阅读: 深度学习caffe:Ubuntu16.04安装指南(2) 正式开始安装前,你需要一台已经安装好了Ubuntu16.04系统的电脑,然后/home分区最好有尽

深度学习caffe:Ubuntu16.04安装指南(2)

a:link { text-decoration: none } caffe [CPU ONLY] 2017-01-19 最简单的安装配置方式: 不用GPU加速,使用OPENCV3.1图像库, 这是根据官方教程(链接如下)简化而得到. Ubuntu 16.04 or 15.10 Installation Guide 0. Ubuntu16.04 安装 如果对于安装Ubuntu的过程不是很熟悉的话,这里有不错的教程和常见问题解决方案. Ubuntu16.04 U盘安装Ubuntu16.04制作 光

ubuntu16.04 安装配置matlab ,python ,cuda8.0,cudnn,opencv3.1的caffe环境

网络上有很多ubuntu上caffe配置环境的帖子,本人照着其中的许多进行了参考,都出现了或多或少的错误,很多地方也有差异. 于是自己整理了下自己的安装过程,成功进行了测试,跑通了faster-rcnn.配置环境时间为2017.1.4 系统ubuntu16.04 一:显卡驱动的安装: 由于要使用GPU,所以先要查看自己显卡所匹配的显卡驱动,网址:http://www.nvidia.com/Download/index.aspx%3Flang=en-us 选择电脑匹配的显卡驱动,本人电脑显卡为GT

【21天实战Caffe】学习笔记(一)Ubuntu16.04+Caffe环境搭建

安装前准备工作: 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 sudo apt-get install libatlas-base-dev sudo apt-get install th

Ubuntu16.04 +cuda8.0+cudnn+caffe+theano+tensorflow配置明细

本文为原创作品,未经本人同意,禁止转载,禁止用于商业用途!本人对博客使用拥有最终解释权 欢迎关注我的博客:http://blog.csdn.net/hit2015spring和http://www.cnblogs.com/xujianqing 本文主要是介绍在ubuntu16.04下,怎么配置当下流行的深度学习框架,cuda8.0+cudnn+caffe+theano+tensorflow 安装英伟达显卡驱动 首先去官网上查看适合你GPU的驱动 (http://www.nvidia.com/Do

caffe在ubuntu16.04配置流程

先说废话:在导师办公室2天+自己在家一天终于完成了caffe的配置,(上一篇随笔说好每天更新blog没有做到但我真的有在忙= =)整个过程掉坑无数,还好lucky enough配置完毕,趁着在跑cifar-10的train_full的时间整理一下整个流程,等导师的titanx到了以后还要再配置一次. env:Alienware17-R3, Ubuntu16.04 64-bit, NVIDIA Geforce GTX 980m (导师科研经费买的titanx没到,我的外星人只好先充公了,哈哈) 配

Ubuntu16.04 安装配置Caffe

Caffe已经是第三次安装配置了,为什么是第三次呢?因为我实在是低估了深度学习对于硬件的要求.第一次我在自己笔记本上配置的单核,CPU only ...  结果是,样例数据跑了4小时,这还怎么玩?第二次在台式机上,因为台式机比较low,I5处理器4核,没有NVIDIA的GPU.我把别人训练好的模型下载下来,然后自己测试,发现真的成功了,心里小激动~ 然而,当我自己训练模型时,我训练7天.....  关键是7天了还在跑..... 心想,我这个穷逼难道要自己掏钱买个服务器?那怎么可能.还好,老师人非

ubuntu16.04 cuda8.0 opencv3.2.0 caffe安装

安装过程 1.安装相关依赖项 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 sudo apt-get install libopenblas-dev liblapack-dev libat

Ubuntu16.04 Caffe 安装步骤记录(超详尽)

"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Ubuntu16.04 Caffe 安装步骤记录(超详尽) - yhao的博客 - 博客频道 - CSDN.NET yhao的博客 最怕庸碌无为,还安慰自己平凡可贵 目录视图 摘要视图 订阅 [活动]2017 CSDN博客专栏评选 &nbsp [5月书讯]流畅的Pyt