(original) Ubuntu16 compiled in Caffe

Source: Internet
Author: User
Tags nvcc

Reprint please specify the source:

Http://www.cnblogs.com/darkknightzh/p/5797526.html

Reference URL:

Http://caffe.berkeleyvision.org/installation.html#prerequisites

1. Required dependencies: Boost >= 1.55,cuda,blas

Check out which directory your cuda is installed in. Makefile.config default Cuda_dir: =/usr/local/cuda

Dependent libraries: Protobuf, Glog, GFlags, Hdf5. Installation:

sudo install libgflags-devsudoinstall libgoogle-glog-devsudo Install Libhdf5-serial-dev

Blas can use ATLAS,MKL or Openblas. Atlas is the default choice for Caffe. Mkl and Openblas perform better. To install Atlas:

sudo Install Libatlas-base-dev

2. Optional: OpenCV >= 2.4 including 3.0 (default use 2.4. Uncomment 11 rows in Makefile.config if you want to not use it, or uncomment 21 lines in Makefile.config if you use Opencv3

IO Library: Lmdb (used by default.) If you want to not use it, uncomment the makefile.config in 13 rows, Leveldb (note:leveldb requires snappy; default). Uncomment 12 lines in Makefile.config if you want to not use them)

 Install Lmdb (PIP installation may be required first:sudoinstall python-pip)

CuDNN

3. If you are using only CPUs, uncomment cpu_only: = 1 in Makefile.config.

With CUDNN, uncomment the USE_CUDNN in makefile.config: = 1.

If using MKL, set makefile.config in blas: = Mkl

If you use Openblas, set makefile.config in blas: = Open

Description: after loading the dependent libraries, it's a good idea to reboot (like Boost, reboot), because the boost didn't restart and then make all passed.

This makes all and make test pass, but made runtest will prompt that Libboost_system is undefined (in fact, it's Ubuntu in Chinese, so it's undefined when the message is displayed.) But not at first. It's a success now, it's impossible. Can only find an English information posted here ... ):

Undefined reference to ' boost::system::generic_category () '

4. Compile Caffe: Enter the following command in the terminal:

CP Makefile.config.example makefile.config# Adjust makefile.config (forifif  CuDNN is desired)   make a test make Runtest

If you want to compile with multithreading, use make all-j8, where 8 is the number of threads in parallel.

PS: Compile with CMake (CMake version >= 2.8.7):

Navigate to the Caffe folder first. After:

mkdir BUILDCD Buildcmake.  Make  All  Make Install  make Runtest

Description: Use CMake Compilation Not successful ... There is always a problem. Finally, it's back to make compilation.

5. Copy the Caffe header file to the system directory:

sudo CP -a build/lib/usrsudocp –a INCLUDE/USR

It was very strange just now, in the second sentence has been prompted:

CP: Unable to get the ' –a ' file status (STAT): No file or directory

CP: Skip directory ' include '

Then the second sentence begins with the include changed to the absolute path, you can ... (Critical on another computer, the second sentence is available):

sudo CP -A/HOME/XXX/CAFFE-MASTER/INCLUDE/USR

6. Problems encountered:

1 ) Fatal error:hdf5.h: without that file or directory " Workaround

http://blog.csdn.net/xue_wenyuan/article/details/52037121

On line 90th of the Makefile.config file, add/usr/include/hdf5/serial/to Include_dirs.

Include_dirs: = $ (python_include)/usr/local/include /usr/include/hdf5/serial

In line 181th of the makefile file, change Hdf5_hl and Hdf5 to Hdf5_serial_hl and hdf5_serial.

LIBRARIES + = Glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

2 )/USR/LOCAL/CUDA/BIN/NVCC: command not found:

The 28th line of content in Makefile.config is changed from Cuda_dir: =/usr/local/cuda to (my side NVCC is located at/USR/LIB/NVIDIA-CUDA-TOOLKIT/BIN/NVCC):

Cuda_dir: =/usr/lib/nvidia-cuda-toolkit

3 ) Error: ' memcpy ' is not declared in this scope

Return (char *) memcpy (__dest, __SRC, __n) + __n;

http://blog.csdn.net/eagelangel/article/details/51531801

Makefile in 409 lines, add -d_force_inlines:

-d_force_inlines -ccbin=$ (CXX)-xcompiler-fpic $ (common_flags)

4 ) use make all directly , prompting for the following content.

Online says the PROTOBUF version is inconsistent. Re-installed the latest version of the Protobuf, and then use make all, or you will be prompted the above content. Now that all the folders are displayed, there is actually a. build_release directory in the Caffe root directory, with caffe.pb.cc in it.

Clean with make, prompt for insufficient permissions (caffe placed in the Usr/local directory), and then use sudomake (if it is in the home path, should not need sudo), successfully cleared. build_ The files inside the release. Then make all, you will not have the above hint.

(original) Ubuntu16 compiled in Caffe

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.