Ubuntu 14.04 64-bit Configuration Caffe tutorial (Cuda 7.5)

Source: Internet
Author: User

Deep learning is an important tool for the study of computer vision, especially in the field of image classification and recognition, which has epoch-making significance. Now there are many deep learning frameworks, and Caffe is one of the more common ones. This article describes the basic steps for configuring Caffe in the Ubuntu 14.04 (64-bit) system, referring to the official website of Caffe http://caffe.berkeleyvision.org/.

First, the system environment configuration

1.1 First install some dependencies that are typically used. Open the Ubuntu system terminal and enter the following command:

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

1.2 Download and install Cuda

I'm using Cuda 7.5, https://developer.nvidia.com/cuda-downloads.

Select the appropriate version and download it. According to the settings in the diagram, download to Cuda_7.5.18_linux.run, the default download path is ~/downloads, enter in the terminal:

CD ~/downloads

sudo sh cuda_7.5.18_linux.run

After running there will be a large section of text to let you browse, terminal left corner has a progress display, the current should be 0%, no need to see, directly press CTRL + C skip, and then enter "accept". The bottom is that you choose to install each component. The first video card driver do not install, the rest can be loaded. Note, also do not install the official driver of NVIDIA graphics card, may produce the system boot cycle login not to enter the situation. I was because of the latest version of the official driver, leading to a circular login, tried the network on the way the great God gave the method, are not effective. Finally give up, or use your own open source graphics driver.

But even then there may be some special cases. For example, using the own open source driver, after compiling the Caffe, run the test using the GPU, will prompt Error:cuda driver version is insufficient for CUDA runtime version. This means that the graphics driver is not installed. Instead of using the GPU, only the CPU is used. Of course, if you want to use the GPU, you can only install the appropriate graphics driver. As I said earlier, installing the latest NVIDIA graphics drivers has caused problems with Ubuntu logins, so which driver should I install?

Open System settings--> Software & updates--> Additional Drivers

My video card is GTX 760, and the newer version of the driver in the list is 352.63. As a result, we can download this version of the graphics driver from the NVIDIA website. According to your own graphics card and the system to download the corresponding driver, my download is Nvidia-linux-x86_64-352.63.run

Installation method:

(1) Turn off the desktop system first, Terminal input:

sudo service LIGHTDM stop

(2) then press CTRL + ALT +F1 to enter the console and enter your account number and password. CD to the directory where the graphics driver is located, and then execute:

sudo sh nvidia-linux-x86_64-352.63.run

Follow the instructions step by step installation is complete.

(3) The middle may require that you disable your own open source driver and restart your computer. You need to repeat the previous steps after restarting, then confirm all the way. When the installation is complete, enter the command:

sudo service LIGHTDM start

You can return to your desktop system.

1.3 Installing Blas

enter the following command in the terminal:

sudo apt-get install Libatlas-base-dev

1.4 To install Python (optional)

If you need to use the built-in Python, you need to run the following command so that you can have a Python header file when you generate the Pycaffe interface:

sudo apt-get Install the Python-dev

1.5 Some of the remaining dependencies

sudo apt-get install Libgflags-dev libgoogle-glog-dev Liblmdb-dev

Second, installation and compilation of Caffe

2.1 Installing Caffe

we use Git to get caffe, and if we don't have Git installed before, we need Manual Installation

sudo apt-get install git

git clone https://github.com/BVLC/caffe/

2.2 Configuring Caffe  

Enter the root directory of the Caffe. My caffe is downloaded in the home directory, so in terminal input:

CD ~/caffe

then create a configuration file. Since you have a Makefile.config.example file in the downloaded Caffe directory, you only need to copy the file and name it makefile.config. So you can use the following command:

CP Makefile.config.example Makefile.config

Some of the notes on Makefile.config are as follows:

(1) Using CPU&GPU accelerated Caffe, do not need to modify the existing configuration;

(2) with Nvidia's CUDNN software accelerated Caffe, you need to cancel the comment symbol before "USE_CUDNN: = 1". It should be noted that CUDNN is not necessarily faster than the Caffe GPU acceleration.

(3) Use only the Caffe of the CPU to cancel the comments in front of "cpu_only: = 1".

2.3 Compiling Caffe

we use CMake to compile the Caffe, if the CMake is not previously installed, it needs to be installed manually

sudo apt-get install CMake

then execute the following command at a time (if you encounter execution permission problems, add sudo before the command)

mkdir Build

CD Build

CMake.

Make all

Make install

Make Runtest

At this point, the Caffe has been successfully installed. Some tests can be done on some datasets.

Third, the use of Caffe

3.1 Preparing the Mnist data set

prepare the data set first. We need to download the data from the Mnist website and convert the format. For simplicity, you can execute the following command directly:

CD ~/caffe

./data/mnist/get_mnist.sh

./examples/mnist/create_mnist.sh

After running, the Mnist_train_lmdb and Mnist_test_lmdb two folders are generated under Caffe/examples/mnist.

3.2 Execution Results

Terminal Enter the following command (the current working directory is still ~/caffe):

./examples/mnist/train_lenet.sh

Run this command and finally train a successful result.

Ubuntu 14.04 64-bit Configuration Caffe tutorial (Cuda 7.5)

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.