Centos 6.5 Install Caffe+nvidia Driver+cuda 6.5

Source: Internet
Author: User

Centos 6.5 installation Caffe full record

Not long ago, Caffe was installed on a new machine for deep learning. In fact, I small white one, in the process of installing Caffe have gone a lot of detours. In the face of problems, fortunately there are **google**, you can get, oh some answers. But the tragedy is that there are some problems that really can't be answered. Like what:

NVCC src/caffe/layers/relu_layer.cusrc/caffe/layers/prelu_layer.cu(58): error: a host function call cannot be configureddetected during instantiation of "void caffe::PReLULayer::Forward_gpu(const std::vectorcaffe::Blob<Dtype *, std::allocatorcaffe::Blob<Dtype *>> &, const std::vectorcaffe::Blob<Dtype *, std::allocatorcaffe::Blob<Dtype *>> &) [with Dtype=float]" (127): here

At that time Google this error, unexpectedly someone and I encountered the same mistake. It's not good to be happy, but it doesn't have any eggs, because nobody answers. Of course, I solved the problem later, because most of the libraries that Caffe relied on were manually compiled by me, which is probably the problem. But the specific why there is such a problem I am not quite clear, which involves the version compatibility of the various libraries, no, headache. Hope the great God pointing.

So much nonsense, it's time to get to the point. Installation Caffe can be divided into two steps.

    • Install CPU only Caffe
    • Re-install GPU acceleration Caffe

This allows us to quickly locate problems and solve problems when errors occur.

1. Install CPU only Caffe

It is necessary to explain the basic information of Linux system before writing this section.


$ lsb_release -aLSB Version::base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarchDistributor ID:CentOSDescription:CentOS release 6.5 (Final)Release:6.5Codename:Final$ uname -r2.6.32-431.el6.x86_64

The prawns who installed Caffe must have read the Rhel/fedora/centos installation chapter.

1.1 Basic Library Installation
    • Basic development tools

      sudo yum -y groupinstall "Development Tools"
    • Add **epel repositories**

sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Then you can install the library happily.

sudo yum install protobuf-devel leveldb-devel snappy-devel hdf5-devel

    • Installing **boost-devel**

To see if there is rpm -qa boost a boost for CentOS, if there is a version, my own version is 1.44.1, the version is too low,


$ wget -O boost_1_55_0.tar.bz2 http://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F1.55.0%2F&ts=1385953406&use_mirror=softlayer-ams$ tar jxvf

-Installation **opencv-devel**

$ sudo yum -y install cmake pkgconfig gtk2-devel python-devel numpy tbb-devel libpng-devel$ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.10/opencv-2.4.10.zip$ unzip opencv-2.4.10.zip$ cd opencv-2.4.10$ mkdir build$ cd build$ cmake ../ -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_EXAMPLES=ON -DBUILD_NEW_PYTHON_SUPPORT=ON -DINSTALL_PYTHON_EXAMPLES=ON$ make -j 2$ sudo make install

1.2 OS Dependencies

Come on, knock on the following command.
sudo yum install gflags-devel glog-devel lmdb-develAnd found that Glog-devel could not find it. This time only on GitHub up and down a glog.zip.

$ unzip glog-master.zip$ cd glog-master$ ./configure$ make -j4$ sudo make install
1.3 BLAS

sudo yum install atlas-devel

1.4 Compiling
$ cp Makefile.config.example Makefile.config# Adjust Makefile.config (for example, if using Anaconda Python)$ make all$ make test$ make runtest
  • For CuDNN acceleration, your should uncomment the USE_CUDNN: = 1 switch in Makefile.config.
  • For Cpu-only Caffe, uncomment cpu_only: = 1 in Makefile.config.

If there is no accident caffe.so should be born. If the make runtest process, if there are errors related to **protobuf**, you should uninstall Protobuf-devel, manually download **protobuf** source code, manually compiled.

$ wget -O protobuf.zip https://github.com/google/protobuf/archive/master.zip$ unzip protobuf.zip$ cd protobuf-master$ ./autogen.sh$ make && make check$ sudo make install

——

2. Re-install GPU acceleration Caffe

At this stage, we are divided into two steps. :( Can't stand, really when we are small white <-_->

2.1 Installing NVIDIA Graphics drivers
    • First you need to know your graphics card model.
      Landlord is the computer graphics model GTX 970, how to feel is not local tyrants version. Then go to the NVIDIA official website to download the latest driver. While downloading the driver, let's do something shameful.


      $ lspci -nn | grep VGA

    • Disable default graphics driver
      Open the **/etc/modprobe.d/blacklist.conf** file, add **blacklist nouveau** disable CentOS default installation of the graphics driver. Prevent kernel from loading nouveau module (nonessential operation) Modify **/boot/grub/grub.conf**, "#vim/boot/grub/grub.conf", add kernel at the end of the rdblacklist= line Nouveau

blacklist nouveau
    • Installation of Kernel-devel, **dkms** and kernel-headers
      If you use *yum* installation, you will find the kernel source version of the installation is *2.6.32-504.el6.x86_64*, what ghost? If you do it unconsciously, there is no doubt that it will give you a big mistake when compiling the kernel. If you're smart enough to get around the wrong source, and build a new kernel, congratulations. Because, in a sunny morning, you open the computer to find out how your system became a **centos 6.6**. What the? You can stand it. But as a person to send honest little man, I can not endure ah. Here's how to fix it:
      On this website, find *kernel-devel-2.6.32-431.29.2.el6.x86_64.rpm* and *kernel-devel-2.6.32-431.29.2.el6.x86_64.rpm* download to local.
$ sudo yum install kernel-devel-2.6.32-431.29.2.el6.x86_64.rpm kernel-devel-2.6.32-431.29.2.el6.x86_64.rpm

Then you can find the source code under the **/usr/src/kernels/**. One more step, install **dkms**, let it help us compile and install the driver module.

$ yum install dkms$ sudo cp -r /usr/src/kernels/2.6.32-431.29.2.el6.x86_64/ /usr/src/kernels/2.6.32-431.el6.x86_64/
    • Re-establish **initramfs image** file
$ mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak$ dracut /boot/initramfs-$(uname -r).img $(uname -r)
    • Text mode
      Modify the **/etc/inittab** to boot the system into init 3 text mode:#vim /etc/inittab
      Modify the last line "Id:**5**:initdefault:" to "Id:**3**:initdefault:" (without quotation marks). After the installation of the driver file download is complete
$ reboot
    • Installation
      When it starts, it enters the text interface. The *cd* then enters the directory where the driver is located and starts the installation
$ chmod +x NVIDIA-Linux-XXXX.run$ ./NVIDIA-Linux-XXXX.run

After a few consents, the driver is set up. Modify the **/etc/inittab** to change back to the graphical interface.

$ reboot

Installation is successful, you can see the nvidia X Server settings menu in the system-preferences after logging in, you can view the basic information and make some settings.

2.1 Installing Cuda
    • First download the CUDA 6.5 Run File
$ chmod +x cuda_6.5_XXXX.run$ ./cuda_6.5_XXXX.run

Skip the first driver installation and either Yes or default on the back. Note that the final

    • /usr/local/cuda/bin Join **path**
    • /usr/local/cuda/lib64 Join **/etc/ld.so.conf**
    • Installation
      Then it's back to the process of installing Caffe. Comment cpu_only: = 1, compile again. When you do this, there is a smile on your little face.

Centos 6.5 Install Caffe+nvidia Driver+cuda 6.5

Related Article

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.