caffe+ubuntu14.04+cuda7.5 Environment Building (new direction) guide

Source: Internet
Author: User
Tags git clone intel mkl

Order

This article is for beginners who want to learn how to use the Caffe framework, if there are errors in the text, please point out.

Since I built this environment to refer to a lot of online tutorials, but no, so the text of the pictures mostly from the network.

This article does not install MATLAB steps, so need to install and configure MATLAB classmate please Baidu matlab installation.

1. Build Ubuntu14.04 dual system in WIN10 environment

Please prepare the operation beforehand:

An empty USB stick, preferably more than 4G.

Go to Ubuntu website to download a Ubuntu14.04 ISO image file, note the 64-bit system.

Download some gadgets to use, such as Esaybcd,utraliso

The above things are ready to be OK. Below are the specific installation steps.

The first step, in My Computer Management tool to use Disk Management tool to allocate some hard disk space for Ubuntu system, personal advice to prepare at least 100G, because the building environment may need to install a variety of bloated software, when the time to suggest that the hard disk space is really embarrassing. The way to allocate space is to select a drive letter click on the compressed volume, and then enter a desired size is OK.

Second, use the Utraliso and Ubuntu image files to make an installation disk on the U disk. Use Utraliso to open the image file and then find the start-to-write hard disk image in the menu, then the hard drive chooses the inserted USB drive, writes the way usb-hdd+, writes directly.

The third step, restart the computer, using a USB stick to boot. Different models of the computer may enter the BIOS or boot options in a different way, but nothing is crazy press del Dafa, according to the power on the instant prompt click F1-f12 Dafa and so on. Using the USB flash drive will see the option to install Ubuntu, after the choice of access is the Ubuntu installation interface. (Do not know how to boot from the U-disk students please Baidu, tutorial super, also have photos, very intimate)

The fourth step is to partition Ubuntu. First install Please select ' Other options ' and continue, then in a lot of hard disk records to find our ready for that free space, for Ubuntu partition. After selecting the free space, click the plus sign in the lower left corner to add the partition. The order in which I recommend the partitions to be added is:

1. Add swap space, size is the memory size of the machine itself, if the hard disk space enough students can allocate to 1.5-twice times the memory size.

2. Add '/boot ' partition, size 200MB to 500MB, if the hard disk is rich, you can consider 1G, in the more also no use. (, other directories directly click the/Boot drop-down menu)

3. Add the '/' root mount point around 40G. The root directory can be as large as possible, because the various software that will be installed is installed here.

4. Add the '/home ' user master directory mount point and allocate the rest of the space.

In fact, the most recommended partition order is/boot in the first as the primary partition, the other as a logical partition, swap at the end, but since it is a dual system, there is no need to be so fastidious. (PS partition left lower corner can delete the set partition, Virgo students please go to the lower left corner)

Fifth step, eat a fruit to listen to a song waiting for the installation after the restart of the computer on the line. Reboot after the default will be in Ubuntu Grub Boot, Windows system will not be the default startup items, if you want to change Windows UEFI boot, you can use the prepared EASYBCD processing, the specific plan directly Baidu Google can.

At this point, Ubuntu installation is complete.

PS, there are many online do not need u disk direct EASYBCD boot installation of dual systems, interested students can try, but if your computer equipped with dual hard drives, especially the use of factory original system notebook, this need a little bit of relevant technical experience, because to change the default drive letter address, so I am not recommended, Borrow a small partner a U disk, save thousands of troubles.

Pps,linux use terminal very frequently, you can install the following a small plug-in, the file browser in the right-click menu to add ' Open in the terminal ' Save the CD directory of trouble, very recommended!

Enter command to install Nautilus-open-terminal

sudo apt-get install nautilus-open-terminal

After the installation is complete, restart the computer, you can open the terminal directly in the right-click menu!

2. Installing CUDA7.5

Go directly to Nvidia's official website to download CUDA7.5 for Ubuntu installation package, URL https://developer.nvidia.com/cuda-downloads, select can.

After downloading this 1.9GB installation package, remember not to use the hand to double-click on what software Center open and hand-installed, so there is no egg. Honestly open the terminal, use the CD command to switch to the folder where the installation package is located, enter the following command:

sudo dpkg--install cuda-repo-<distro>-<version>.<architecture>.deb

sudo apt-get update

sudo apt-get install Cuda

After waiting for installation, please honestly restart your computer and load the graphics driver. If you are able to restart successfully, see if you have successfully read out your NVIDIA graphics card in the overview of system settings, such as Ubuntu.

Students who can successfully complete the above actions, please skip the following paragraph ...

If the face is black and the restart fails, then select Ubuntu Advanced in the boot selection operating system and then enter to see the different Ubuntu boot and its recovery mode, try one side of those non-recovery choice to see which can go in, go inside can perform the following steps, Not to go to the classmate, please drink saliva, hundred degrees to check the solution or reload it.

If you go into the system and then find out that not Nvidia's graphics card, or Intel's integrated graphics, in the overview of Ubuntu's system settings, please do sudo apt-get update and then restart your computer.

Reasonable words, to this should be smooth after the installation of Cuda.

You can then run the run simple test: operate under the terminal

Configure Environment Variables First

Export Path=/usr/local/cuda-7.5/bin: $PATH
Export ld_library_path=/usr/local/cuda-7.5/lib64: $LD _library_path

Installing Simples

cuda-install-samples-7.5.sh ~

Go to the simple directory, compile and execute the Nbody sample program

CD ~/nvidia_cuda-samples_7.5/5_simulations/nbody
Make
./nbody

Success should pop up a graphics window, then a particle explosion simulation, as long as you can run this, the Cuda installation is successful.

Then link lib file, new cuda.conf:

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

and write in the Open file:

/usr/local/cuda/lib64

/lib

Save exit, update settings:

$ sudo ldconfig-v

Cuda Simples has a lot of interesting and practical procedures, interested students can compile their own run and read the source of learning.

Optional: Install the CUDNN Development Library

Go to the official website to register and download CUDNN (Cudnn-7.5-linux-x64-v4.0-prod) recommended here V4, old version stable, V5 may encounter the problem of compilation. Then install the

$ sudo cp include/cudnn.h/usr/local/include

$ sudo cp lib64/libcudnn.*/usr/local/lib

link library files

$ sudo ln-sf/usr/local/lib/libcudnn.so.4.0.7/usr/local/lib/libcudnn.so.4

$ sudo ln-sf/usr/local/lib/libcudnn.so.4/usr/local/lib/libcudnn.so

$ sudo ldconfig-v

3. Build Caffe Environment

Caffe need to rely on a lot of tools, such as BLAS,CUDNN and so on, we want to step-by-step installation, here remember to be patient.

Caffe Download: Recommended to be placed in the main directory, easy to use

git clone https://github.com/BVLC/caffe.git
The first step is to install some development essentials packages

It's usually already installed. We're just going to test it again.

sudo apt-get install build-essentialsudo apt-get install vim cmake gitsudo apt-get install Libprotobuf-dev Libleveldb-dev Libsnappy-dev Libopencv-dev Libboost-all-dev LIBHDF
Step two install Blas

Here you can choose Intel's Mkl,openblas and Atlas, run efficiently on Atlas < Openblas < MKL, and configure the ease of Atlas < MKL < Openblas.

Installing Atlas: Entering commands

sudo apt-get install Libatlas-base-dev

Complete!

Install mkl,https://software.intel.com/en-us/intel-education-offerings, select intel® Math kernel library for Linux * version mkl (Intel (R) Parallel Studio XE Cluster Edition for Linux 2016), this is actually to charge, but use a student mailbox can apply for free to 1 years, after downloading directly using the following command decompression and installation, installation is a graphical interface, directly installed on the line. Need 8.2GB space, if the previous small partner only to the root directory 20GB not to the size, then you can skip this step, the hard disk is probably not enough.

Tar zxvf parallel_studio_xe_2016.tar.gz

chmod a+x Parallel_studio_xe_2016-r

sudo sh install_gui.sh

Link lib files after installation is complete, like Cuda

New intel_mkl.conf:

$ sudo gedit/etc/ld.so.conf.d/intel_mkl.conf

Input:

/opt/intel/lib/intel64

/opt/intel/mkl/lib/intel64

Save exit, update settings:

$ sudo ldconfig-v

step three, install OpenCV

Here recommended 3.0 version, do not go to the official website to find, here to share a reprint of the file, directly run the installation can:

Link: Http://pan.baidu.com/s/1kVpOUHL Password: VFVB

After downloading into the installation directory, install dependencies: sudo sh ubuntu/dependencies.sh

Then enter ubuntu\3.0 to perform the installation: $ sudo sh opencv3_0_0.sh

Installation needs to be networked, about 30 minutes, a cup of tea to rest ....

Fourth step, install other dependent libraries

1. Google Logging Library (glog),: https://code.google.com/p/google-glog/, then install the command as follows:

Tar zxvf glog-0.3.3.tar.gz

./configure

Make

sudo make install

2. Install other dependent libraries

sudo apt-get install-y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev Libhdf5-serial-dev Libgflags-dev libgoogle-glog-dev Liblmdb-dev Protobuf-compiler protobuf-c-compiler Protobuf-compiler

3. Install some Python dependencies

I personally do not recommend the use of Anaconda, because the compilation of additional directory settings, very troublesome ...

Load a PIP directly:

sudo apt-get install Python-pip

Then what is missing directly according to the missing package name Pip install <package-name> can be.

Switch to the Python directory under the Caffe directory,

sudo apt-get install-y 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

Then use the sudo su command to go to root, and then check that the packages in the Requirement.txt are all installed.

sudo sufor req in $ (cat requirements.txt); do pip install $req; Done

If you hold the wrong, the general is the lack of dependency packages, apart, direct pip install <package-name>

At this point, compile Caffe need to install all the things, if you want to use MATLAB classmate, you can buy (PO) bought (Jie) ' A MATLAB self-installation, recommended matlab2014a (online crack resources, installation tutorial also more)

4. Compiling and testing

Compile Caffe The key is the Caffe configuration file, in the Caffe directory has a Makefile.config.example file, which is the configuration file sample and documentation, English can also students suggest carefully read the instructions, really useful!!

If you can't read it, just change it ...

First, copy an Makefile.config.example and name Makefile.config

CP Makefile.config.example Makefile.config

Then follow the changes as follows:

1. Enable CUDNN, remove the comment symbol #

USE_CUDNN: = 1

2. Enable OPENCV 3.0, remove the comment symbol #

Opencv_version =3

3. If you are using Intel Mkl, enable MKL (by default, Atlas)

BLAS: = Mkl

OK, now you can try to compile Caffe (burn a Buddha, hope there is no error)

You can add a-j number-like command to a multi-core compilation After the statement, such as make All-j4 four-core compilation, can speed up a lot of

Make all

Make Test

Make Runtest

Make Pycaffe (compile Python support)

If you have MATLAB installed, you need to compile the Caffe Support section for MATLAB:

Set matlab_dir in config file: =/usr/local/matlab/r2014a

Make Matcaffe

If the above compilation has passed properly, then you can test it.

Test 1 Python reference

Enter Python in the Caffe\python directory (terminal switch to this directory, enter Python)

Enter Import Caffe

If you do not error, congratulations, the compilation passed!

Test 2 Run the Example,mnist DataSet test Caffe comes with

Execute in Caffe root directory:

Get Data Set

SH data/mnist/get_mnist.sh

Establish input

SH examples/mnist/create_mnist.sh

Training

SH examples/mnist/train_lenet.sh

If you do not give an error, you will continue to output the number of iterations, Loss,err and other information.

At this point 0 Foundation builds Ubuntu Caffe framework end.

caffe+ubuntu14.04+cuda7.5 Environment Building (new direction) guide

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.