Ubuntu14.04+caffe+cpu

Source: Internet
Author: User

Just in the last blog record Windows10 under the GPU version Caffe installation, is preparing to run the code in the paper, found a lot of commands are. SH command, this is the Linux system script file. Cannot run directly under Windows, so I want to convert. Sh to a bat file that can be executed under Windows, but find that the code needs to convert the data to LEVELDB format. And leveldb can not be directly under Windows compile, but also need to configure, more cumbersome. And Lmdb can be compiled directly under Windows. Here are the two differences:

    • They are key/value pairs (key/value pair) embedded database management System programming library.
    • While Lmdb memory consumption is 1.1 times times leveldb, Lmdb is 10% to 15% faster than LEVELDB, and more importantly LMDB allows multiple training models to read the same set of data simultaneously.
    • So Lmdb replaced Leveldb as the default dataset generation format for Caffe

Said so much, is windows really inconvenient, so want to engage in a wave of Linux. But not very familiar, so there is no dual system, first on the virtual machine to practice practiced hand, although the virtual machine can not use the GPU.

My configuration: vmware-workstation-full-12.00 (12 seems more fit Win10), UBUNTU-14.04-DESKTOP-AMD64 (14LTS version and 16LTS version relatively stable, AMD64 that is 64-bit version)

Virtual machine and Ubuntu installation is relatively simple, basically a fool-style installation.

Caffe to install Python interface: (no GPU), no cuda (natural and no cudnn), no OpenCV (not required)

1. Install the necessary environment

sudo apt-get  update   #更新软件列表sudo apt-get  upgrade #更新软件sudo apt-get Install build-essentia #安装build essentialslsudo apt-get install linux-headers-'uname -R' #安装最新版本的kernel headers

2. Install the required dependency packages

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  

3. Install the necessary libraries

sudo apt-get install Libgflags-dev libgoogle-glog-dev liblmdb-dev  sudo apt-get Install libatlas-Base-dev  

4. Download Caffe and configure Python

Most of the online methods are:

CD ~   git clone https://github.com/bvlc/caffe.git #克隆caffe到本地, and named CaffeCD Caffecat python1 sudo pip install  installs caffe/python/requirements.txt all required libraries

I was in the pit here, the above command used PIP. So first install PIP, that is, execute sudo apt-get install Python-pip

But after installing the PIP, the above installed requirements.txt in the library, the speed is very slow, the basic is the error of timeout, many changes on the Web configuration of the tutorial, but I did not set the success.

So I take the following approach, that is, the requirements.txt in the library to take out, download:

sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python -h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython Ipython  

The above even Caffe/python all the required libraries. After the installation of no error, you can test: terminal input python, and then enter any import scipy or import Cython are not wrong.

5. Configure and compile Caffe

Modify Makefile.config.example

CD Caffe
CP Makefile.config.example Makefile.config

The above command means: Copy the Makefile.config.example in the Caffe folder to Makefile.config

Then go to the Makefile.config folder and change something:

#去掉CPU_ONLY:Note # = 1 #/usr/lib/python2  under Python_include#.  7/dist-packages/numpy/core/include# changed to  #/usr/local/lib/python2.  7/dist-packages/numpy/core/include

The following starts compiling Caffe:

Enter the Caffe folder root directory, eg:~/caffe$, to do the following:

Make Allmake pycaffemake distributemake test

This runs relatively long.

6. Modify the Environment path

Write Pythonpath to. BASHRC:

' Export PYTHONPATH = $PYTHONPATH:/home/ ' username'/caffe/python'>>~/~/.bashrc'

According to each person's different path to modify, for example, my is 'export pythonpath= $PYTHONPATH:/home/lps/caffe/python '

7. Testing

Run Mnist:

1) Prepare the data set according to the website first:

CD ~/Caffe #将终端定位到Caffe根目录. /data/mnist/get_mnist.sh #下载MNIST数据库并解压缩. /examples/mnist/create_mnist.sh #将其转换成Lmdb数据库格式

2) Edit Lenet_solver's Solver_mode mode from GPU to CPU:

vim. /examples/mnist/lenet_solver.prototxt# changed to Solver_mode:cpu

3) Training Model

CD $CAFFE _root. /examples/mnist/train_lenet.sh

4)训练结果

Ubuntu14.04+caffe+cpu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.