Go Caffe installation process recording (CentOS, no discrete graphics, no GPU)

Source: Internet
Author: User
Tags lapack cuda toolkit intel mkl

Caffe installation process recording (CentOS, no discrete graphics, no GPU) original address: http://www.aiuxian.com/article/p-2410195.html reference:
http://www.tuicool.com/articles/uiuA3e Caffe Installation Configuration (CentOS + no GPU)
Http://blog.sina.com.cn/s/blog_990865340102vewt.html Caffe Installation Configuration (CentOS 6.5 + no GPU)
http://www.cnblogs.com/platero/p/3993877.html Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration Instructions http://blog.sciencenet.cn/ blog-1583812-841855.html Ubuntu+cuda6.5+caffe Installation Configuration Rollup
Caffe (http://caffe.berkeleyvision.org/) is a clear and efficient framework for deep learning, with the author of Jiayanqing (http://daggerfs.com/), a PhD graduate from UC Berkeley, He currently works for Google. The Caffe is a pure C++/cuda architecture that supports command line, Python, and MATLAB interfaces, and can be seamlessly switched between CPU and GPU directly.


March 11 Add: At the time of installation, it is possible to execute the relevant example inside the Caffe, can modify the Protobuf and different network configuration, but if you want to write a program in Python, execution or failure. The question is finally added.


1 First identify the machine is what graphics card:

Lspci |grep VGA
00:02.0 VGA compatible Controller:intel Corporation Xeon e3-1200 v2/3rd Gen Core Processor Graphics Controller (Rev 09)


The machine is tragic without Nvidia's graphics card.
But it doesn't matter, it can still run.


Basic Software Requirements
    • CUDA Library version 6.5 (recommended), 6.0, 5.5, or 5.0 and the latest driver version for Cuda 6 or 319.* for Cuda 5 (and Not 331.*)
    • BLAS (provided via ATLAS, MKL, or Openblas).
    • OpenCV (>= 2.4)
    • Boost (>= 1.55, although only 1.55 and 1.56 is tested)
    • gloggflagsprotobufleveldbsnappyhdf5,lmdb
    • For the Python wrapper
      • Python 2.7, numpy (>= 1.7) , boost-providedboost.python


2 CUDA

Download Cuda from Http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run
sudo./cuda_6.5.14_linux_64.run
Do not install the driver, or the installation will go wrong (driver installation is unable to locate the kernel source)
First option Select No


Install NVIDIA accelerated Graphics Driver for linux-x86_64 340.29? ((y) es/(n) o/(q) uit): N
Install the CUDA 6.5 Toolkit? ((y) es/(n) o/(q) uit): Y
Enter Toolkit Location [default is/usr/local/cuda-6.5]:
Do you want to install a symbolic link At/usr/local/cuda? ((y) es/(n) o/(q) uit): Y
Install the CUDA 6.5 Samples? ((y) es/(n) o/(q) uit): Y
Enter CUDA Samples Location [default IS/HOME/ROOT1]:
Installing the CUDA Toolkit in/usr/local/cuda-6.5 ...
Missing Recommended library:libGLU.so
Missing Recommended library:libXmu.so


Installing the CUDA Samples in/home/root1 ...
Copying Samples To/home/root1/nvidia_cuda-6.5_samples Now ...
Finished copying samples.


===========
= Summary =
===========

Driver:not Selected
Toolkit:installed in/usr/local/cuda-6.5
Samples:installed in/home/root1, but missing recommended libraries


sure that
-PATH Includes/usr/local/cuda-6.5/bin
-Ld_library_path includes/usr/local/cuda-6.5/lib64, or, add/usr/local/cuda-6.5/lib64 to/etc/ld.so.conf and run Ldcon Fig as Root



Then modify $path, $LD _library_path
vi /etc/profile#在文档最后,添加:export PATH="/usr/local/cuda-6.5/bin:$PATH"#保存,退出,然后运行:#source /etc/profile
vi ~/.bash_profile ~/目录下打开.bash_profile$ export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib64:$LD_LIBRARY_PATH#source ~/.bash_profile


3 Installing a series of dependencies
sudo yum install boost-develsudo yum install opencv-develyum -y install freeglutyum install atlas-devel yum install snappy-devel 
Glog, GFlags, Protobuf, Leveldb, Snappy, Hdf5, Lmdb Glog: A C + + library of logging information, programmed to be used in a similar way to the C + + stream operation
wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gztar zxf glog-0.3.3.tar.gzcd glog-0.3.3./configuremakesudo make install
Other people have dependent libraries that use the installation
sudo yum install gflags-devel protobuf-devel leveldb-devel snappy-devel hdf5-devel
But I had a lot of failures when I installed it. So list the various installation methods gflags: A set of command-line parameter parsing tools

tar zxvf gflags-2.1.1.tar.gz && cd gflags-2.1.1mkdir build && cd build export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1make sudo make install 
Protobuf: Serialization protocol, a mixed-language data standard within Google Inc.
第一次错误的方法:
tar zxvf protobuf-cpp-3.0.0-alpha-1.tar.gz && cd protobuf-cpp-3.0.0-alpha-1&& ./configure && makemake install
    第二次正确的方法:   wget https://github.com/google/protobuf/releases/download/v3.0.0-alpha-2/protobuf-python-3.0.0-alpha-2.tar.gz
不过当时没有下载下来,所以我从windows机器上下载了,然后用rz -b上传的。 之前不带-b参数,导致一直解压失败。 然后进去按照readme里面的步骤 #./configure 
#make 
#make check 
#make install

记得要去python文件夹内 安装python所需要的模块
#cd ./python 
#python setup.py build 
#python setup.py test 
#python setup.py install

安装完成,验证Linux命令 
#protoc –version

验证Python模块是否被正确安装 
#python 
>>>import google.protobuf 
如果没有报错,说明安装正常。


    leveldb:google开源的一个key-value存储引擎库
 
git clone https://github.com/google/leveldb.gitmakesudo cp -r include/leveldb /usr/local/includesudo cp libleveldb.so /usr/local/lib
Lmdb:mmap ' d database for OpenLDAP aka Lightning MDB
git clone git://gitorious.org/mdb/mdb.gitcd mdb/libraries/liblmdbmake && make install
Hdf5:hierarchical Data Format 5
rpm -i hdf5-1.8.10-2.1.1.src.rpmtar -xjf hdf5-1.8.8.tar.bz2 ./configuremake && make install
Ccmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gztar -zxvf cmake-2.8.10.2.tar.gz  cd cmake-2.8.10.2 ./bootstrap 

4 OPENCV Caffe Author default you have configured the OPENCV environment, the document does not say this step. Fortunately someone has written the configuration OpenCV script, Https://github.com/jayrambhia/Install-OpenCV, directly to use.

git clone https://github.com/jayrambhia/Install-OpenCVcd Install-OpenCV/RedHatsudo ./opencv_latest.sh

(This step I didn't use) if the script fails to run, read the opencv_install.sh code in detail and then manually click the command to install it.
cd opencv-2.4.7sed  -i ‘/string(MD5/d‘ cmake/cl2cpp.cmakemkdir buildcd buildcmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..make -j 4sudo make installsudo sh -c ‘echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf‘sudo ldconfig/usr/local/cuda-6.5/samples/bin/x86_64/linux/release/Install-OpenCV/OpenCV/opencv-2.4.10/build/lib
5 Installing Caffe

git clone https://github.com/BVLC/caffe.gitmake all
Does it look like you should be able to see the happy ending?
Not really ... 1 Error while loading shared Libraries:libprotobuf.so.10:cannot open Shared object file:no such file or directory
Workaround: Add the path to the PROTOBUF library function to Ld_library_path
2/usr/bin/ld:cannot FIND-LHDF5_HL
Workaround: After attempting to modify the various paths invalid, take the build soft link cd/etc/ld.so.conf.d
sudo ln-sv/usr/local/weiwei/hdf5-1.8.8/hdf5/lib/libhdf5_hl.so/usr/lib/libhdf5_hl.so

and modify # VI Makefile.config to join the LIB path to be used

3/usr/bin/ld:cannot Find-lcblas
BLAS CBLAS
VI makefile.in modifying the library path
/usr/local/blas
/usr/local/cblas/lib

sudo ln-sv/usr/lib64/atlas/libatlas.a/usr/lib/libatlas.a
sudo ln-sv/usr/lib64/atlas/libcblas.a/usr/lib/libcblas.a

4 Boost library Inside the boost_thread call has been problematic first reload the boost library
cd cd boost_1_57_0
./bootstrap.sh
./b2
./b2 install
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
See Success Tips
The Boost C + + Libraries were successfully built!

The following directory should is added to compiler include paths:
/usr/local/boost_1_57_0

The following directory should is added to linker library paths:
/usr/local/boost_1_57_0/stage/lib

But there's always been a problem. Always error undefined reference to ' boost::thread::join () '
However, the test file created in the Boost Library folder is not a problem to compile and run.
Finally, there is a problem with the boost version used by the first compilation Caffe, just reload the boost library, so Caffe the library that was located and the last compiled version is inconsistent
In the Caffe directory, make clean and recompile, OK
The selection of Ps:blas library Basic Linear Algebra subprograms (BLAS) is used to optimize the operation of vector inner product, matrix vector product and matrix product. There are two types of Blas libraries running on Intel processors: MKL (the Intel Math Kernel Library) and automatically Tuned Linear Algebra software (ATLAS).
atlas* (automatically Tuned Linear Algebra software) is a relatively popular computational function library for linear algebra. It implements most of the functions of Blas and Lapack. The site of ATLAS is: http://math-atlas.sourceforge.net/.*


Some functions in the Intel MKL Library use multithreaded parallel optimizations, where the user can control the number of threads in the MKL runtime using the environment variable omp_num_threads. On dual-core and multi-core processors, it provides a 2-5-fold performance boost for the DGEMM function. (Universal Matrix Computing (DGEMM) is a widely used mathematical function.) 1) Intel MKL can have significant performance compared to the Atlas Library 2) Intel MKL BLAS functions provide superior multi-threaded support






2) ScaLAPACK is a standard package for solving linear equations on a cluster. It is a subset of the linear algebraic package (LAPACK) functions. On the 64-bit Intel Xeon processor 32-node cluster, 1) Intel MKL ScaLAPACK performance significantly exceeds NETLIB ScaLAPACK. 2). Intel MKL performs more prominently than using the atlas* BLAS with the NETLIB scalapack code.




3). The Intel mkl Fourier transform function has been highly optimized for both medium and large issues. The performance of Intel MKL is compared with the performance of the widely used FFT calculation function FFTW, which shows that: 1) Intel MKL provides excellent Fourier transform performance. 2) Intel MKL provides excellent scalability for multi-processor systems. 3) Intel MKL is better than FFTW for medium and large conversions.


In addition to the Fast Blas Library, the MKL Library includes lapack (Linear Algebra package), FFT, and more. Atlas has a single-threaded C Blas Library, single-threaded FORTRAN Blas library, multi-threaded C Blas Library, multi-threaded Fortran Blas library, and so on; the difference between a single thread and a multiline libraries is that the Atlas function is serialized internally when using single-line libraries (equivalent to the omp_num in MKL _threads=1), while using multi-line libraries, the part of the function in Atlas uses multithreaded SMP parallelism (equivalent to omp_num_threads=2 in MKL).
Comprehensive comparison, MKL Cubby Atlas Library performance slightly better. MKL application path (non-commercial version) https://registrationcenter.intel.com/RegCenter/NComForm.aspx? Productid=1461&pass=yes Caffe Network Python interface writing program failure and resolution record. Caffe provides the Python interface and the Matlab interface, to use the Python interface, after the Caffe network executes, and then execute make Pycaffe compile the python file: Error 1 importerror:no module named ya ML requires installation of Pyyaml 3.11 http://pyyaml.org/download/pyyaml/PyYAML-3.11.tar.gz
wget http://pyyaml.org/download/pyyaml/PyYAML-3.11.tar.gz
TAR-ZXVF pyyaml-3.11.tar.gz
Python setup.py Install

Error 2 Importerror:no module named Argparse
Easy_install argparse Output is
Searching for Argparse
Reading http://pypi.python.org/simple/argparse/
Best Match:argparse 1.3.0
Downloading Https://pypi.python.org/packages/source/a/argparse/argparse-1.3.0.tar.gz#md5=9bcf7f612190885c8c85e30ba41db3c7
Processing argparse-1.3.0.tar.gz
Running argparse-1.3.0/setup.py-q Bdist_egg--dist-dir/tmp/easy_install-avn40q/argparse-1.3.0/egg-dist-tmp-o6ydra
Warning:no previously-included files matching ' *.pyc ' found anywhere in distribution
Warning:no previously-included files matching ' *.pyo ' found anywhere in distribution
Warning:no previously-included files matching ' *.orig ' found anywhere in distribution
Warning:no previously-included files matching ' *.rej ' found anywhere in distribution
No previously-included directories found matching ' doc/_build '
No previously-included directories found matching ' env24 '
No previously-included directories found matching ' env25 '
No previously-included directories found matching ' env26 '
No previously-included directories found matching ' env27 '
Zip_safe flag not set; Analyzing Archive Contents ...
Adding argparse 1.3.0 to easy-install.pth file
Installed/usr/lib/python2.6/site-packages/argparse-1.3.0-py2.6.egg
Processing dependencies for Argparse
Finished processing dependencies for Argparse 3 python-2.7.8/include/pyport.h:886:2: Error: #error "Long_bit definition Appears wrong for platform (Bad GCC/GLIBC config?). "
In file included from/usr/include/numpy/ndarrayobject.h:68,
From/usr/include/numpy/arrayobject.h:14,
From Python/caffe/_caffe.hpp:8,
From Python/caffe/_caffe.cpp:12:
/usr/include/numpy/npy_common.h:79:2: Error: #error must use Python with Unicode enabled.
Make: * * * [python/caffe/_caffe.so] Error 1 found py_unicode_size problem, prompting undefined Symbol:pyunicodeucs4_asenco. There is an error while loading shared libraries:libpython2.7.so.1.0: The reason is the cross-compilation of #define PY_UNICODE_SIZE 2 defined in cross-compiling python:pyconfig.h To other Python libraries, such as Dbus-python, the default header file path contains:/usr/include/python2.6/pyconfig.h defines a # define Py_unicode_size 4
So the UCS4 function is called, but the UCS2 function is defined in the cross version of Python.

So the workaround is to recompile the python once
./configure--prefix=/usr/local/weiwei/python--ENABLE-SHARED-ENABLE-UNICODE=UCS4
Make
Make install after compiling, to all use Python's place to modify, also do the corresponding soft link Ln-sf/usr/local/weiwei/python/bin/python/usr/bin/python found his record: 1. Some of the dependencies that you must have to install Pycaffe:
$ sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py Python-protobuf python-leveldb python-networkx python-nose Python-pandas


Python-gflags Cython Ipython
$ sudo apt-get install Protobuf-c-compiler Protobuf-compiler but CentOS does not use these instructions, many of which are not installed with Yum. First, the python is loaded with Easy_istall and then installed Easy_install NumPy
Easy_install Networkx 4 fails with import Caffe, there is no output directly, and killall-9 Python is used to end the process. Use gdb python for debugging. See the following error message: GNU gdb (gdb) Red Hat Enterprise Linux (7.2-60.EL6)
Copyright (C) Free Software Foundation, Inc.
License gplv3+: GNU GPL version 3 or later This was free software:you was free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "Show copying"
and "Show warranty" for details.
This GDB is configured as "X86_64-redhat-linux-gnu".
For bugs reporting instructions, please see:
Reading symbols From/usr/local/weiwei/python/bin/python...done.
(GDB) Set args a.py
(GDB) R
[Thread debugging using libthread_db enabled]
Traceback (most recent):
File "a.py", line +, in <module>
Import Caffe
File ".. /python/caffe/__init__.py ", line 1, in <module>
From. Pycaffe Import Net, Sgdsolver
File ".. /python/caffe/pycaffe.py ", line +, in <module>
Import Caffe.io
File ".. /python/caffe/io.py ", line 2, in <module>
Import Skimage.io
Importerror:no module named Skimage.io skimage not installed, check the official web instructions as follows
Easy_install-u Scikit-image
But rely on PIL, so first installed PIL Easy_install PIL found PIL installed after, display installation success, but compile the program still always error, still can't find. Probably because the Python version on the machine is more, and do not know why an installation is said to have installed, but the program can not find the compilation, so have to re-source code to try to install. wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz python setup.py build_ext-i then reinstall Skimage, download Skimage, pip Install Easy_install Cython 4 after installation, a problem that protobuf cannot find is found. This has been installed before. However, the CPP version was previously installed and was not installed with Python for python-protobuf. 5 Importerror:no module named Caffe
Make Pycaffe

Go Caffe installation process recording (CentOS, no discrete graphics, no GPU)

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.