Caffe Configuration Most concise tutorial (Ubuntu 14.04)

Source: Internet
Author: User
Tags intel mkl

1. Preface

The system used in this tutorial is Ubuntu 14.04 LTS 64-bit, using the Cuda version of 7.5, using the NVIDIA driver version of 352.

If you are using Pascal architecture graphics, such as GTX1080 or new TTX, you must use a later driver and Cuda 8. This tutorial is not suitable for this situation, please do not try.

Ubuntu releases the LTS version (the long-term support version) every two years, so the 16.04 LTS version has now been released. Given that many programs are not tested for compatibility with the new system, this tutorial is still about installing Caffe on the previous LTS version, followed by a tutorial for Ubuntu 16.04 and Cuda 8.

2. Installing the underlying dependencies

sudo Install build-essential
sudo Install cmake git

3. Installing the NVIDIA Driver

First, you need to close the graphical interface, use CTRL+ALT+F1 to enter the Virtual Console, and then enter the username and password to log in.

Then close LIGHTDM

sudo /etc/init.d/lightdm stop

Then update the source and install the Nvidia 352 driver from Ubuntu official source

sudo Install nvidia-352

This is currently the latest driver version of the official source, if you need a higher version of the driver, you can go to the NVIDIA official website for download.

Then restart your computer.

sudo reboot

PS: Installing the NVIDIA graphics driver in this way automatically overwrites the Ubuntu x server configuration so that if your monitor is not connected to an Nvidia video card, you will not be able to start the GUI properly. Please note this with the use of Tesla and other computing cards.

4. Installing Cuda 7.5

Download Cuda 7.5 's Deb Local installation package from Nvidia official website:

Click on the link above to download the Deb Local installation package that supports the x86 architecture CPU and Ubuntu 14.04 system, which is approximately 1.9GB in size and can be used as an official website tutorial if additional installation methods are required.

When the download is complete, open terminal, go to the specified directory, and then execute:

sudo Cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
sudo apt-get update
sudo Install Cuda

After the installation is complete, you need to add environment variables. Use Gedit to open the following document:

sudo gedit/etc/profile

Add at the end of the file:

path=/usr/local/cuda/Bin: $PATHexport PATH

Once the save is complete, execute the following command to make the environment variable effective immediately:

Source/etc/profile

You will then need to add the path to the Lib:

sudo gedit/etc/ld. so.conf.d/cuda.conf

Write the following in the file and save:

/usr/local/cuda/lib64

Then execute the following command to make it effective:

sudo ldconfig

PS: The above command makes L-D-C-O-N-F-I-G!!! Countless people wrote L and told me the error.

After performing these operations, you can also install Cuda samples to detect if Cuda is working properly, as this is not a cuda programming tutorial, this tutorial is not covered.

4. Install some other dependencies

sudo Install freeglut3-dev libx11-dev libxmu-dev libxi-dev Libglu1-mesa-dev
sudo Install libgtk2. 0 pkg-config Libavcodec-dev libavformat-dev Libswscale-dev
sudo Install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394- -dev
sudo Install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev Libhdf5-serial-dev Libgflags-dev Libgoogle-glog-dev Liblmdb-dev Protobuf-compiler

5. Install Atlas

This step can be replaced with Openblas or Intel Mkl. I tested these three libraries on the e5-2690v2+gtx780 platform, which is similar in performance, and describes one of them:

sudo Install Libatlas-dev

Then the automatic installation is complete.

6. Installing OPENCV

Download OpenCV's OpenCV source code from the official website of OPENCV Online:

Click here

Many domestic network open OPENCV official website slow, you can click the following address directly from GitHub download OPENCV 3.1 source code

After the download is complete, unzip and then terminal to the directory to perform

mkdir Build
CD Build
Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local.
 make-j10

PS:-j10 In the previous code refers to the 10 thread compile at the same time, according to the characteristics of their own CPU tuning this parameter, if you do not know your CPU, directly execute make.

sudo  Make Install

7. Download the caffe and install the Python environment

Download the latest version of Caffe directly from GitHub

Https://github.com/BVLC/caffe.git

Install related dependencies First

sudo Install Python-dev python-pip

Go to the directory of the downloaded Caffe and go to the Python directory

CD python

Execute the following command:

 for  in $ (catdoessudoinstall done

Wait for it to install automatically.

8. Installing MATLAB

This step is optional project, MATLAB is paid software, please support genuine.

9. Installing CUDNN

CUDNN need to register for accelerated Computing Developer program and can download it for free.

CUDNN is the Nvidia Cuda®deep Neural Network Library and is highly recommended for deep learning acceleration with nvidia.

After downloading, unzip, go to this directory, execute:

sudo CP lib*/usr/local/cuda/lib64/sudocp cudnn.h/usr/local/cuda/include/

Update soft Links

cd/usr/local/cuda/lib64/sudorm -rf libcudnn.so libcudnn.so. 5 sudo Ln -S libcudnn.so. 5.1. 3 libcudnn.so. 5 sudo Ln -S libcudnn.so. 5 libcudnn.so

PS: Depending on the version of CUDNN you downloaded, you need to modify the version as above, the command shown above is for CUDNN 5.1.3.

10. Compiling Caffe

Under the Caffe directory, execute:

CP Makefile.config.example Makefile.config

Then open makefile.config, modify the relevant parameters according to your own needs.

If CUDNN is used, uncomment it as follows:

1

As in the previous tutorial, OpenCV 3.1 was used, and the following comments were canceled:

3

Other can be modified according to the requirements, such as the installation of MATLAB after the correct MATLAB installation path and so on.

Then compile:

 make all –J10 make test make Runtest

Ps:-j10 This parameter has already been mentioned in the previous tutorial, again:

-j10 refers to 10 threads compile at the same time, according to the characteristics of their own CPU to adjust the parameters, if you do not know their CPU, directly execute make.

Matcaffe and Pycaffe can then be compiled on demand:

 Make Matcaffe  make Pycaffe

Then the Caffe is finished.

11. Run Minist Demo

Go to the Caffe directory

sh data/mnist/get_mnist. SH sh examples/mnist/create_mnist. SH sh examples/mnist/train_lenet. SH

If it works, Caffe will work properly.

This tutorial is written in the following tutorials, which are hereby acknowledged:

Http://www.cnblogs.com/platero/p/3993877.html

If you have any questions, you can contact me:

[Email protected]

Caffe Configuration Most concise tutorial (Ubuntu 14.04)

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.