ubuntu16.04 Install Caffe Python interface installation __python

Source: Internet
Author: User

Download Caffe:

Git Clonehttps://github.com/bvlc/caffe

Install OPENCV, the specific steps can refer to:

Http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html

Copy the Makefile.config.example to makefile.config like this:

CP Makefile.config.example Makefile.config

Edit Makefile.config File:

If only CPU calculations are used, modify:

Remove Cpu_only: = 1 Front of #

That is, modify to:

Cpu_only: = 1

If the CUDA version is CUDA is 8.0, you will need to:

Cuda_dir: =/usr/local/cuda

Change to:

Cuda_dir: =/usr/local/cuda-8.0

To install the Python dependency library:

Into the Python directory:

CD Caffe/python

To run the installation command:

For req in $ (cat requirements.txt); Do sudo pip install $req; Done

Compile Caffe, enter Caffe directory:

Cd..

Run make all,

Make all

The following error occurred:

./include/caffe/util/math_functions.hpp:7:26:fatal error:glog/logging.h: No file or directory

The reason is that the Glog,glog installation command is not installed as follows:

Wgethttps://google-glog.googlecode.com/files/glog-0.3.3.tar.gztar ZXVF GLOG-0.3.5.TAR.GZCD glog-0.3.5./ Configuremake && make Install

Then rerun make all and error:

./include/caffe/common.hpp:5:27:fatal error:gflags/gflags.h: No file or directory

The reason is probably not to install gflags.

Glags installation is as follows:

Wgethttps://github.com/schuhschuh/gflags/archive/master.zipunzip MASTER.ZIPCD Gflags-mastermkdir Build && CD buildexport cxxflags= "-fpic" && cmake ... && make Verbose=1make && make install

When Ann is done, rerun make all and error:

Src/caffe/net.cpp:8:18:fatal error:hdf5.h: No file or directory

Workaround:

Cd/usr/lib/x86_64-linux-gnu

sudo ln-s libhdf5serial.so.10.1.0 libhdf5serial.so

sudo ln-s libhdf5serial_hl.so.10.0.2 libhdf5serial_hl.so

Modify Makefile.config

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/hdf5/serial/

Can.

Rerun make all with an error:

./include/caffe/util/db_lmdb.hpp:8:18:fatal error:lmdb.h: No file or directory

The reason is that the Lmdb,lmdb installation command is not installed as follows:

git clonehttps://gitorious.org//mdb/mdb.gitcd mdb/libraries/liblmdbmake && make install

After installing the Lmdb, recompile the Caffe:

Make All-j8

Error occurred:

Make: * * * * [. Build_release/tools/upgrade_net_proto_binary.bin] Error 1.build_release/lib/libcaffe.so: To ' Cv::imread ' ( cv::string const&, int) ' undefined reference. build_release/lib/libcaffe.so: To ' Cv::imencode ' (cv::string const&, cv::_ Inputarray Const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector< int, std::allocator<int> > const&) ' undefined reference. build_release/lib/libcaffe.so: To ' Cv::imdecode ' (cv::_ Inputarray const&, int) ' undefined reference collect2:error:ld returned 1 exit statusmakefile:625:recipe for Target '. Build_releas E/tools/convert_imageset.bin ' failedmake: * * * [. build_release/tools/convert_imageset.bin] Error 1

The reason is that the OPNECV version is different and enters the/usr/local/lib directory to view the OPENCV version:

Cd/usr/local/lib

Ls

If the OPENCV version is 3, remove the comments from the Makefile.config line #opencv_version: = 3 and recompile:
Make clean make all-j8

To install the Python interface:

Make Pycaffe

Test:

Make Test

Make Runtest

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.