Caffe configuration process in ubuntu16.04

Source: Internet
Author: User
Tags tidy unsupported

First say nonsense: In the tutor's office 2 days + oneself at home Day finally completed Caffe configuration, (previous essay said every day update blog did not do but I really have in busy = =) The whole process out of countless, fortunately lucky enough configuration finished, while running cifar-10 train_ Full time to tidy up the whole process, and so the mentor's Titanx to be configured again.

ENV:ALIENWARE17-R3, Ubuntu16.04 64-bit, NVIDIA Geforce GTX 980m (Mentor research funds bought Titanx didn't arrive, my alien had to confiscate first, haha)

Configured with CUDA8.0, cuDNN5.0, opencv2.4.13

Reference to some of the intranet and external network information, I will try to write all myself, really encountered the need to refer to the content will be posted on the site.

First you have to have some basic Linux foundation, even if you play on MacOS Terminal also can, after all, is unix-based.

A little mention of the process of installing ubuntu16.04 yourself: Go to the next image file on Ubuntu website, make your own system disk with U-disk, and then follow the dress code, see http://www.linuxidc.com/Linux/2016-04/130520.htm for details.

First open terminal, enter the following dependencies:


1 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler2 sudo apt-get install--no-install-recommends libboost-all-dev3 sudo apt-get install Libopenblas-dev Liblapack-dev Libatlas-base-dev4 sudo apt-get install Libgflags-dev libgoogle-glog-dev Liblmdb-dev

I. Nvidia Driver

After installing the Nvidia driver for Ubuntu, the Ubuntu default driver recognizes that Intel's graphics card must not work, please visit Nvidia official website http://www.nvidia.com/Download/index.aspx?lang= En-US query what you need to drive, now January 30, 2017 basically standard is 375, but still check the more secure

Installation method There are many statements on the Internet, there is said to blacklist this one, to close XSERVER,LIGHTDM and the like. I've spent two days here, and all of these methods have caused problems. Finally, the way I installed my success was

1. Runsudo apt-get purge nvidia-*

2. Run and then sudo add-apt-repository ppa:graphics-drivers/ppasudo apt-get update

3. Runsudo apt-get install nvidia-375

4. Run sudo reboot

Here is a very tricky point, my time is mainly spent here, looked up a lot of information, before all kinds of machine reasons I only understand a few of them, here a little tidy up:

1. Choose Nvidia driver with additional drivers set in Ubuntu, fail to install completely

2. Blacklist the Nouveau, use Alt+ctrl+f1,sudo service LIGHTDM stop (Close xserver), apt-get manual download of the installation package, the same as when the machine

3. Install cuda8.0 when the first option "Install Nvidia driver" selected Yes ... Be sure to choose No here. Although his default is yes, he later discovered that the Caffe website has made it clear that the Nvidia driver version of Cuda binding is usually out-of-date so skip this step.

Can only say that if there is a special situation, please leave a message, I will try to help you solve. Blog I look at every day, reply no more than 24 hours

There are two methods to check whether the installation is complete, the first is the input sudo nvidia-smi, if the correct display of video card information is installed successfully

Second, directly in the upper right corner to view this computer, the video card is not the N card on the line

II. cuda8.0

When your Ubuntu can correctly recognize the Nvidia graphics card, we can start to install Cuda (in fact, there is a random order of information, but anyway I was in this order to configure the success, so to write).

First go to cuda official website download cuda8.0 https://developer.nvidia.com/cuda-downloads

Step by Step Select Linux->x86_64->ubuntu->16.04->runfile (here to choose Runfile to be able to skip Cuda's own n-card driver installation), then you can download, 1.4 g, You can drink a cup of tea now.

Download good after CD to your download place, run "sudo sh cuda_8.0.44_linux.run", the specific file name check, at the beginning there will be a lot to read the Overlord clauses, direct q to the last, input accept. The following will let you choose a variety of details of the installation items, here Note whether you want to install NVIDIA driver be sure to choose No, I installed the first.

After installing sudo gedit ~/.BASHRC, write the following to BASHRC last

Export Path=/usr/local/cuda-8.0/bin${path:+:${path}}

Export Ld_library_path=/usr/local/cuda8.0/lib64${ld_library_path:+:${ld_library_path}}

Then test the Cuda-given sample:

Cd/usr/local/cuda-8.0/samples/1_utilities/devicequery

Make

sudo./devicequery

If your GPU-related information is displayed, the installation is successful

III. CuDNN

Here I cudnn using the 5.0 version for CUDA8.0., in Https://developer.nvidia.com/rdp/cudnn-download download, you need to register an account first. Select Cudnn v5 Library for Linux.

Download and unzip sudo tar-zxvf later./File name

And then

$ cd folder/extracted/contents

$ sudo cp -P include/cudnn.h /usr/include

$ sudo cp -P lib64/libcudnn* /usr/lib/x86_64-linux-gnu/

$ sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn*

Iv. OpenCV

The version selected here is 2.4.13. There are some compatibility issues with 3.0,3.1, so I chose the 2016 release of 2.4.13

http://opencv.org/downloads.html Download here

Download Good later

Unzip Opencv-2.4.13.zip specific file name see for yourself, there will be discrepancies

Copy it to the ready to install directory, where the assume folder is named OpenCV

CD ~/OPENCV

mkdir Build

CD Build

sudo apt install cmake

sudo cmake-d cmake_build_type=release-d

Cmake_install_prefix=/usr/local.

sudo make

My 2.4 version of the direct configuration, if it is 3.0 and 3.1 may appear compatibility issues, specific to the individual choose to consult the data to solve, here I did not install 3.0

After compile

sudo make install

Complete the installation

V. caffe!

Foreplay so much finally getting to the point of starting to configure Caffe.

Download Caffe:git clone https://github.com/BVLC/caffe.git from GitHub

If you don't have Git installed, you'll need to: sudo apt-get install git

Then sudo cp Makefile.config.example makefile.config

Open the Makefile.config file, here you need permission do not forget sudo. You can use Getit or nano.

If you have not skipped cudnn before, you will need to

#USE_CUDNN: = 1 # removed

If your OPENCV version is 3, you need to remove the opencv_version:=3.

The other configuration is self-viewing, according to the previous steps only need to cudnn that line of comments removed can

And then

Will # Whatever else you find need goes here.

Include_dirs: = $ (python_include)/usr/local/include

Library_dirs: = $ (python_lib)/usr/local/lib/usr/lib

Modified to:

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

And then

(5) Modify the makefile file

Open the Makefile file and make the following changes:

Will:

Nvccflags +=-ccbin=$ (CXX)-xcompiler-fpic $ (common_flags)

To be replaced by:

Nvccflags + =-d_force_inlines-ccbin=$ (CXX)-xcompiler-fpic $ (common_flags)

(6) Edit/usr/local/cuda/include/host_config.h

Comment out the 115th line:

Will

#error--Unsupported GNU version! GCC versions later than 4.9 is not supported!

Switch

#error--Unsupported GNU version! GCC versions later than 4.9 is not supported!

Last sudo make all

The problem I encountered:

"libcudart.so.8.0 cannot open shared object File:no such file or directory"

The workaround is to copy some files to the/usr/local/lib folder:

#注意自己CUDA的版本号!

sudo cp/usr/local/cuda-8.0/lib64/libcudart.so.8.0/usr/local/lib/libcudart.so.8.0 && sudo ldconfig

sudo cp/usr/local/cuda-8.0/lib64/libcublas.so.8.0/usr/local/lib/libcublas.so.8.0 && sudo ldconfig

sudo cp/usr/local/cuda-8.0/lib64/libcurand.so.8.0/usr/local/lib/libcurand.so.8.0 && sudo ldconfig

Test after completion:

sudo make runtest

After running, if the bottom left corner shows the green passed, then the Caffe configuration is successful and done!

VI. Small trial Sledgehammer

Here Caffe has been configured, let's find a set of datasets to test, here choose Cifar-10.

Specific Process Caffe Official website has http://caffe.berkeleyvision.org/gathered/examples/cifar10.html

I'll simply write

First download install cifar-10, here I assume you install Caffe folder is called Caffe

CD Caffe

./data/cifar10/get_cifar10.sh

./examles/cifar10/create_cifar10.sh

Then it's OK, easy, come up with a quick set of tests:

CD Caffe

./examples/cifar10/train_quick.sh

A cup of tea he should have run out, set the iteration only 5000, the last will show optimization done.

Vii. Summary

No more said, pit giant, specific questions please leave a message I try to help

Reference

Http://www.2cto.com/kf/201610/552429.html

http://askubuntu.com/questions/767269/how-can-i-install-cudnn-on-ubuntu-16-04



Caffe configuration process in ubuntu16.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.