ubuntu16.04 installation configuration matlab, Python, cuda8.0,cudnn,opencv3.1 Caffe Environment

Source: Internet
Author: User
Tags unsupported

On the network there are a lot of Ubuntu on the Caffe configuration environment posts, I follow a lot of them for reference, have appeared more or less errors, many places also have differences.

So he tidied up his own installation process, successfully tested, ran through the faster-rcnn. Configure the environment time for the 2017.1.4 system ubuntu16.04

One: Graphics driver installation:

Because you want to use the GPU, you first need to see your video card matches the graphics driver, url: http://www.nvidia.com/Download/index.aspx%3Flang=en-us

Select the computer matching graphics card driver, my Computer graphics card for GTX760, select as shown

Enter the following command to perform the installation drive:

sudo add-apt-repository ppa:graphics-drivers/ppa  sudo apt-get update   sudo Install nvidia-375// driver version for sudoinstall mesa-common- Dev   sudo Install Freeglut3-dev

After the installation is complete, restart the computer and enter

Nvidia-smi

A list of your computer's GPUs appears, as shown below, indicating that the driver installation was successful.

Two: Installation configuration CUDA8.0

Cuda official: Https://developer.nvidia.com/cuda-downloads, choose as follows:

  

After the download is complete, unzip to the current directory and switch to the directory input:

sh cuda_8. 0. 44_linux.run--override

During the installation process, a lot of options appear, first always press s slide to hundred percent, and then according to the prompt input, respectively, as follows:

1 Enter Accept acceptance Terms 2 Input n does not install the Nvidia image driver, it has been installed before // must be selected here n38. 0 Tools 4 Enter Confirm cuda default installation path:/usr/local/cuda-8.05 enter y run Setup with sudo permission, enter password 6 Enter Y or N to install or do not installa symbolic link to/usr/local/cuda 78.0  Samples for later test 8 8.0 Samples default installation path:

The most important thing is to make sure you don't choose to install the driver here.

To add an environment path:

sudo vim ~/.bashrc  // end add export cuda_home=/usr/local/cuda-8.0     Export Ld_library_path=/usr/local/cuda-8.0/lib64: $LD _library_path   export PATH=/usr/ local/cuda-8.0/bin: $PATH  

After the add is complete, source ~/.BASHRC makes it effective.

Test the Cuda example and get the following output:

cd/usr/local/cuda-8.0/samples/1_utilities/devicequery  make -  sudo ./devicequery  

Indicates that Cuda installation was successful.

Three: Installation of CUDNNV5

Download the latest cudnn, URL: https://developer.nvidia.com/rdp/cudnn-download, select the appropriate CUDNN version from the official website

  

I downloaded it in the download directory, entered the directory and unzipped, and established a soft connection as follows:

CD./download/Tar-xvzf cudnn-8.0-linux-x64-v5.1. tgzsudo CP./cuda/include/cudnn.h/usr/local/cuda/includesudo CP./cuda/lib64/lib*/usr/local/cuda/LIB64CD/usr/local/cuda/lib64/sudo RM-RF libcudnn.so libcudnn.so.5sudo LN-S libcudnn.so.5.1.5Libcudnn.so.5sudoLn-s libcudnn.so.5libcudnn.sosudoLdconfig

Four: The installation and configuration of MATLAB

I use the MATLAB version bit: R2014b_glnxa64_withcrack.iso

1, Mount ISO (new Matlab_iso folder required):mkdirMatlab_iso//Home Directory   sudo Mount-O loop r2014b_glnxa64_+withcrack.iso ~/Matlab_iso2, start installation: CD~/Matlab_isosudo./Install3, choose not networked installation4, key input,29797-39064-48306-324525, activate: Select "license.lic" File for activation (under Crack folder)6, copy libmwservices.so to/usr/local/matlab/r2014b/bin/in Glnxa64:sudo CPLibmwservices.so/usr/local/matlab/r2014b/bin/glnxa64/libmwservices.so

After starting the MATLAB problem, you can refer to this post http://blog.csdn.net/csd_ct/article/details/51837894. You only need to rename the libstdc++.so.6 bit libstdc++.so.6.old under/sys/os/glnxa64/.

V: Installation of Opencv3.1

opencv3.1 Download, website link: http://opencv.org/downloads.html

Install the necessary items:

1 sudoapt-Get update2 sudoApt-getInstall-Y build-essential cmake gitPkg-config 3 sudoApt-getInstall-y Libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler4 sudoApt-getInstall-Y libatlas-base-Dev5 sudoApt-getInstall-Y--no-Install-recommends libboost-all-Dev6 sudoApt-getInstall-Y Libgflags-dev Libgoogle-glog-dev liblmdb-Dev7 sudoApt-getInstall-Y python-Pip8 sudoApt-getInstall-Y python-Dev9 sudoApt-getInstall-Y Python-numpy python-scipy
sudo Install build-essential  sudoinstall cmake git libgtk2.  0pkg-config libavcodec-dev libavformat-dev libswscale-dev  sudoinstall python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22
    C12>-dev  

Unzip the OPENCV and enter the directory:

CD opencv-3.1. 0 mkdir  -D cmake_build_type=release-d cmake_install_prefix=/usr/local.

The period may be stuck in the IPPCV download, Ctrl + C interrupted, can be downloaded to ippicv_linux_20151201.tgz. Replace the downloaded file with the same name as the file under OPENCV-3.1.0/3RDPARTY/IPPICV/DOWNLOADS/LINUX-8B449A536A2157BCAD08A2B9F266828B.

 Make-J4     sudomakeinstall  

graphcuts.cpp the error occurred during the make process, as follows:

sudo vim: /modules/cudalegacy/src/graphcuts. CPP

Change the revision of line 45 to #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

Note that you need to run sudo make install to perform the installation after the compilation is complete

VI: Caffe Compilation

  

1 cd ~2 git clone https://github.com/bvlc/caffe.git    //  Git Caffe from GitHub

If you do not have Git installed, you can use sudo apt-get install git to perform the installation first.

1 CD Caffe 2 sudo CP  3sudo vim makefile.config

The compilation configuration of the Caffe is modified and needs to be modified as follows:

1# Use_cudnn: =1Modified to: USE_CUDNN: =1 2# opencv_version: =3Modified to: opencv_version: =33# With_python_layer: =1Modify to With_python_layer:=14#USE_OPENCV: =0Modify into Use_opencv: =15#USE_LEVELDB: =0Modify to Use_leveldb:=16#USE_LMDB: =0Modify bit Use_lmdb: =17 //Modify the MATLAB directory8Will Matlab_dir: =/usr/local/matlab2014b/9 //Final Change # Whatever else you find need goes here.TenInclude_dirs: = $ (python_include)/usr/local/include OneLibrary_dirs: = $ (python_lib)/usr/local/lib/usr/Lib AModified 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//This is because the ubuntu16.04 file contains a location that has changed, especially the location of the hdf5 that needs to be used, so you need to change this path

To modify the Makefile file:

sudo+=-ccbin=$ (CXX)-xcompiler-FPIC $ (common_flags)  

Edit/usr/local/cuda/include/host_config.h will be 119 rows of

Error--Unsupported GNU version! GCC versions later than 5 is not supported! Modified to #error--unsupported GNU version! GCC versions later than 5 is not supported!, which adds a comment to invalidate it

To compile:

 make All-J8  make runtest-j8  

At this point the correct situation is as follows:

  

Compile Matcaffe:

Execute Make MATCAFFE-J4

Displays the Mex completed successfully, which indicates that the compilation Matcaffe succeeded,

Execute make MATTEST-J4 the test program that runs Matcaffe, as shown in the following:

  

Compiling Pycaffe

sudo  make Pycaffe-J4sudo make Distribute-j4

Run make Pytest-j4 to test and appear as:

  

Indicates that Pycaffe compilation succeeded in adding export Pythonpath=/home/zf/caffe/python at the end of the ~/.BASHRC: $PYTHONPATH//self-control path.

Open Python import Caffe can succeed, as follows:

Seven: Mnist set test:

CD ~/Caffe. /data/mnist/get_mnist. SH   . /examples/mnist/create_mnist. SH   . /examples/mnist/train_lenet. SH  

As a result, the correct rate is 99.08%

Eight: FASTER-RCNN Configuration and testing:

  

mkdir~/caffetestcd Caffetestgit Clone--recursive https://Github.com/rbgirshick/py-faster-rcnn.git//Download RCNN source codeCD py-faster-Rcnncd Lib MakeCD../caffe-fast-rcnn//Replace RCNN's makefile.config with the previously compiled Caffesudo CP~/caffe/makefile.config./caffe-fastr-rcnn/sudo  Make-j4 && MakePYCAFFECD ./sudo./data/script/fetch_faster_rcnn_models.SH

If a CUDNN error occurs during this process, it can be resolved as follows:

CD caffe-fast-rcnn git remote add caffe https://github.com/bvlc/caffe.git  git Fetch Caffe// requires GitHub account git stash savegit merge Caffe

CAFFE-FAST-RCNN/INCLUDE/CAFFE/LAYERS/PYTHON_LAYER.HPP 29 Lines Self_.attr ("phase") = Static_cast<int> (this-> Phase_); Comment out

After the successful compilation, the demo is executed, the two demos are different model frameworks,

CD ~/caffetest. /tool/demo.py. /tool/demo.py--net ZF

If the check Failed:error = = cudasuccess (8 vs 0) Invalid device function appears, the 135th line of the py-faster-rcnn/lib/setup.py is Change arch to match the value of your video card (e.g. my GTX 760, compute power is 3.0, change sm_35 to sm_30) and then delete utils/bbox.c,nms/cpu_nms.c, Nms/gpu_nms.cpp recompile

The final results are part of the picture below:

  

Nine: summary and experience

Before it took time to Caffe installation and configuration, but there will always be large and small problems, but finally found to be the first driver of the problem, many blog said that the compiler problem, in my installation process did not appear.

It is said to have been repaired after the cuda8.0. It is also very gratifying to be able to succeed in the end, and it also shows that to do a thing, you have to honestly concentrate on it. Write this blog, one is to commemorate the installation of the sad, but also

is to facilitate the future of the people, hope that they can help, less go a little detour. Cheer Up ~

Installation process used in the installation software, the author will later upload to the network disk, you need to contact the author. The author qq:476833883.

  

  

ubuntu16.04 installation configuration matlab, Python, cuda8.0,cudnn,opencv3.1 Caffe Environment

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.