Ubuntu14.04+cuda7.5+caffe installation instructions (measured available version)

Source: Internet
Author: User
Tags chmod nvcc

These two days to help the doctor's office to install Caffe, it is said that this thing is a Chinese student in Berkeley, California, developed to train the neural network, Super Good, the world is used, but also open source for free.

That is not very good outfit, said generally have to install more than three days, in fact, I probably also spent so much time, but installed down just found a lot of detours, below let me share my experience.

1 Ubuntu14.04 (64-bit) installation cuda7.5

Write in front: Before installing Cuda, it is best to ensure that the system does not update the graphics driver, if it has been updated, it is best to uninstall the video driver after installing Cuda.

First verify that you have an NVIDIA graphics card (Http://developer.nvidia.com/cuda-gpus this site to see if you have a graphics card that supports GPU):

See your Linux distributions (mostly 64-bit or 32-bit):

$ uname-m && cat/etc/*release  

My Linux version is the Ubuntu 14.04 LTS

Look at the version of GCC:


The version I use is gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

First download the NVIDIA Cuda Warehouse installation package, download the address:

Http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_6.5-14_amd64.deb

Note that the above URL although shown to be cuda6.5 but the actual download is cuda7.5 version, if you want to install 6.5 or other versions need to find in Https://developer.nvidia.com/cuda-downloads, Here environment variables are set according to cuda7.5, if cuda this edition different please according to own circumstance modification.

After the download is complete, get a file named Cuda-repo-ubuntu1404_7.5-18_amd64.deb to Deb installation package, which you can install using the following command:

After installing the Deb package, you need to install the Cuda and the graphics card needs to drive (the installation of the Cuda will also install the graphics driver, which is really very convenient.) But the download time is a bit long. )

When using Apt-get, be aware that the update source in the/etc/apt/sources.list is available and that the computer can link to the Internet.

After installation you need to set the environment variables:

Can be added to the end of a/ETC/BASH.BASHRC or/etc/profile file.

$ sudo gedit/etc/bash.bashrc

Add content at end:

Export Path=/usr/local/cuda-7.5/bin: $PATH

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

And then source a little bit.

$ SOURCE/ETC/BASH.BASHRC

Next, set the path used by the dynamic link

Enter the following in cuda.conf

/usr/local/cuda-7.5/lib64

Execute the following order to make it effective immediately

$ sudo ldconfig

After setting up, you can also choose whether to install Cuda with the sample code (<dir> indicate the location you want to install, you can replace the <dir> to ~):

Next, do some validation work:

To view the driver version of the video card

$ cat/proc/driver/nvidia/version  

Review the version of the NVCC compiler to verify that Cudatoolkit is successful.

$ nvcc-v I   

Sample code for compiling Cuda:

$ CD ~/nvidia_cuda-7.5_samples  

Then make the compilation code.

$ sudo make

Go to the bin path to run Devicequery

$/devicequery CD ~/nvidia_cuda-7.5_samples/bin/x86_64/linux/release 
$.   

The specific installation process can refer to http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html. It must be emphasized here: if the new ubuntu14.04 should not update the graphics driver after installation, because the sudo apt-get install Cuda will install the required drive, the advance installation may cause the CUDA installation to fail. Also, it is important to mention that starting Ubuntu may be a direct black screen (not entering the power-on login interface) After GRUB is not installed without the video card driver, which is due to the lack of a graphics driver, which causes gnome not to boot properly. You can start in grub via recovery mode (the screen resolution is also very good after startup), and it will be normal for Cuda to help you install the driver.

2 Installation Caffe

2.1 Installation OpenCV 2.4.11

I am a manual installation, but many people on the internet is used from the GitHub downloaded from the ready-made installation script, I have not tried, do not guarantee that will be available, also posted here (care for lazy people:-):

Https://github.com/jayrambhia/Install-OpenCV, download and unzip, then go into the directory, select your own operating system, and then execute the following command, which takes about twenty or thirty minutes.

$ chmod a+x *.sh                           #给脚本增加可执行权限
$ sudo./dependencies.sh                   #安装所需依赖
$ sudo./open2_4_9.sh                      #安装opencv

There may be an error in the middle

OPENCV-2.4.9/MODULES/GPU/SRC/NVIDIA/CORE/NCVPIXELOPERATIONS.HPP (Wuyi): ERROR:A storage class isn't allowed in Explicit specialization

Workaround here: http://code.opencv.org/issues/3814

Download NCVPIXELOPERATIONS.HPP replace the file in opencv2.4.9 and build again.

Below is a description of my own Ann (of course it may not be as convenient as the script above, but the measurements are feasible)

Install to OPENCV version 2.4.11, make sure that tools such as GCC and cmake are ready

1 Installation Required Dependencies

dependencies for using Apt-get installations are:

Build-essential Libgtk2.0-dev Libjpeg-dev Libtiff4-dev
Libjasper-dev Libopenexr-dev Python-dev Python-numpy
Python-tk Libtbb-dev Libeigen2-dev Yasm
Libfaac-dev Libopencore-amrnb-dev Libopencore-amrwb-dev Libtheora-dev
Libvorbis-dev Libxvidcore-dev Libx264-dev Libqt4-dev
Libqt4-opengl-dev Sphinx-common Texlive-latex-extra Libv4l-dev
Libdc1394-22-dev Libavcodec-dev Libavformat-dev Libswscale-dev

2 Download and install OpenCV source files

From the download address http://opencv.org/downloads.html Select we use the OpenCV 2.4.11 for linux/mac download zip compression package, the compression package into the installation directory and then unpack:

$ unzip opencv-2.4.11.zip-d.

Go to the Unpacked folder and create a build directory for CMake

$ mkdir Build 
$ cd Build
Execute cmake command after entering build directory

Before the installation of their own desktop machine did not encounter problems, this time on the workstation encountered an error, add the following parameters passed (if no error is not added to this parameter)

$ sudo cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local-d cuda_generation=kepler.

After successful CMake, execute:

$ sudo make
$ sudo make install

You should not get an error on the way, then set the path used by the dynamic link

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

Add in opnecv.conf

/usr/local/lib

<dir>/opencv-2.4.11/build/lib/#其中 <dir> The actual installation path for your OPENCV

Re-execution

$ sudo ldconfing

Finally, add a required to the environment variable

$ sudo gedit/etc/bash.bashrc

Add content at end

Export Pkg_config_path= $PKG _config_path:/usr/local/lib/pkgconfig

And then source a little bit.

$ SOURCE/ETC/BASH.BASHRC

This should be done by installation, testing:

Enter the SAMPLE/C directory under the OpenCV folder

$ cd samples/c
$/build_all.sh
$./facedetect  

Reference http://blog.sina.com.cn/s/blog_6e71624c0100n5f1.html

installation of 2.2 Blas

BLAS (Basic Linear algebra subprograms, Base linear algebraic assembly) is an application interface (API) standard. There are many of his implementations, and the Caffe uses three of them to achieve Atlas, MKL, or Openblas. Choose one installation is available.

Atlas and MKL I have installed and tested are available, in principle, only one choice on the line, but heard from the Caffe actual experience effect, Mkl>openblas>atlas.

(1) Install MKL:

First download and install the Intel Math Kernel Library Linux * mkl, download the link is: https://software.intel.com/en-us/intel-education-offerings, please download the student version, Need to use the Education Network mailbox registration (such as mailbox name edu.cn), and then download student free version (otherwise need to pay to use, if there is no education network mailbox and do not want to pay please use Atlas or openbals), a netizen said will receive a serial number for download and installation, However, I did not receive, after registration will be able to download directly, download to the installation package for parallel_studio_xe_2016.tgz,3.8 G, slowly waiting for it.

Next is the installation process, which is authorized first and then installed:

$ tar zxvf parallel_studio_xe_2016.tgz
$ chmod a+x parallel_studio_xe_2016-  R                                         #给文件里到脚本增加可执行权限
$ cd parallel_studio_xe_2016                                                    #进入解压后目录
$ sudo./install_gui.sh                                                         #启动图形界面安装mkl

The next step is to step next (if warned that missing Lib32 library, ignore it)

MKL and CUDA environment settings:

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

Add to:

/opt/intel/lib/intel64

/opt/intel/mkl/lib/intel64

Then completes the Lib file the link operation, executes:

$ sudo ldconfig–v

(2) Installation of Atlas:

Download directly via Apt-get:

$ sudo apt-get install Liblapack-dev
$ sudo apt-get install Libatlas-base-dev
$ sudo apt-get install Libatlas-dev

2.3 Installing additional dependency installations

Use the sudo apt-get install to install the following dependencies

Libprotobuf-dev Libleveldb-dev Libsnappy-dev Libopencv-dev
Libboost-all-dev Libhdf5-serial-dev Libgflags-dev Liblmdb-dev
Libgoogle-glog-dev Protobuf-c-compiler Protobuf-compiler


Depending on the actual test, the above dependencies can be installed through Apt-get (also to the http://pkgs.org download corresponding to the Deb installation package, but note the version, Deb package use method see http://www.cnblogs.com/TankXiao/p/ 3332457.html#removey), it is necessary to note that some online users provide tutorials also provided to download a separate installation package through make install installation of some of these dependencies, such as Protobuf, GFlags, Google-glog, My suggestion is that if the above dependencies can be successfully installed by atp-get or downloading the Deb package and do not report any of these dependencies when installing Caffe later, try not to download the installation packages from GitHub or other Web sites to install them manually.

Again, if the above dependencies have been successfully installed through Apt-get, do not go to other sites to download the installation package installed manually, the specific reasons I will explain later. Since I have been entangled on these four dependencies for a long time, so it is necessary to specifically note that if you do not encounter problems here can be skipped, and then come back to see if you encounter problems.

(1) Protobuf

Put it in the beginning to mention: If you have already downloaded and installed this package, but when the installation of Caffe always reported errors related to Protobuf, then please refer to the method I mentioned later uninstall the installation package.

From the HTTPS://GITHUB.COM/GOOGLE/PROTOBUF can be down to the installation package, note that he offers several versions, the parental test is available to the zip package called Protobuf-master (version Libprotoc 3.0.0). The corresponding Apt-get is installed with the Protobuf-c-compiler

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.