CentOS下安装caffe(组合版本)

(一)安装OpenCV3.1(包括opencv_contrib)

  • 必须软件包

  • yum install -y gcc gcc-c++ gtk+-devel libjpeg-devel libtiff-devel jasper-devel libpng-devel zlib-devel cmake

  • yum install git gtk2-devel pkgconfig numpy python python-pip python-devel gstreamer-plugins-base-devel libv4l ffmpeg-devel

  • yum install mplayer mencoder flvtool2

  • yum install libdc1394

  • yum install gtk*

解压opencv,然后配置CMakeList文件

  • 将opencv_contrib路径写入OPENCV_EXTRA_MODULES_PATH中

set(OPENCV_EXTRA_MODULES_PATH /root/tools/opencv_contrib-master/modules)

  • 然后在root用户下

$ mkdir release

$ cd release
$ cmake ..

$ make -j4

$ make install

  • 在 /etc/ld.so.conf.d文件夹下建立opencv.conf,内容是/usr/local/lib

  • 在/etc/profile最后加入下面代码



PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

export PKG_CONFIG_PATH

然后记得 source /etc/profile

最最后:记得


sudo ldconfig

(二) 安装OpenBLAS的步骤

  • (1)下载最新的openblas

下载地址

  • (2)cd OpenBLAS

  • (3)make FC=gfortran (如果没有安装gfortran,执行sudo apt-get install gfortran)(centos是yum install gcc-gfortran)

  • (4)make install (将OpenBLAS安装到/opt下)

  • (5)执行以下命令完成安装


ln -s /opt/OpenBLAS/lib/libopenblas.so  /usr/lib/libblas.so.3

ln -s /opt/OpenBLAS/lib/liblapack.so.3 /usr/lib/liblapack.so.3

在/etc/profile中加入


LD_LIBRARY_PATH=/opt/OpenBLAS/lib

export LD_LIBRARY_PATH

(三) Install Caffe on CentOS 7

July 29, 2015 admin Caffe, Tutorials

原始链接

特别感谢

Caffe is one of the most powerful framework to train deep neural networks. This tutorial will show you how to install Caffe on CentOS 7 step by step.

I suggest you to apply this tutorial on a computer with a new and clean installation of CentOS 7.

  • Step 1: Install Basics

Update yum to get last version

sudo yum update

Install gcc compiler:

sudo yum install gcc gcc-c++

Install git, vim, python dev and pip:

sudo yum install git vim python-devel python-pip
  • Step 2: Install Caffe Dependencies

Install required libraries

sudo yum install protobuf-devel leveldb-devel openblas-devel snappy-devel opencv-devel boost-devel hdf5-devel gflags-devel glog-devel lmdb-devel

注意:如果安装中有些包没找到,先安装 sudo yum install epel-release 然后再尝试,就可以了。

什么是epel?

如果既想获得 RHEL 的高质量、高性能、高可靠性,又需要方便易用(关键是免费)的软件包更新功能,那么 Fedora Project 推出的 EPEL(Extra Packages for Enterprise Linux)正好适合你。EPEL(http://fedoraproject.org/wiki/EPEL) 是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。

  • Install CUDA
sudo wget http://developer.download.nvidia.com/compute/cuda/repos/rhel6/x86_64/cuda-repo-rhel6-6.5-14.x86_64.rpm
sudo rpm --install cuda-repo-rhel6-6.5-14.x86_64.rpm
sudo yum clean expire-cache
sudo yum install cuda
  • Step 2b: GPU Support (Optional: ONLY if computer has CUDA compatible GPU)

Note: CUDA only support NVIDIA graphic cards. ATI Radeon GPU can’t be used, you will have to stick with CPU only mode.

  • Download and Install last NVIDIA Driver for your device

Go to NVIDIA website, download your graphic card last driver and run the driver file to install it
Download and Install CUDNNv3 (You need to register to NVIDIA website to get last version, or just use the mirror provided below)

wget ...
sudo tar -xvf cudnn-7-0.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
  • Step 3: Get Caffe
Git clone Caffe repository

git clone https://github.com/BVLC/caffe
  • Step 4: Install Python Dependencies

Caffe has a Python interface for easy scripting, I suggest you to install it.


for req in $(cat caffe/python/requirements.txt); do sudo pip install $req; done
  • Step 5: Compile Caffe

Move to Caffe folder and copy/paste Make configuration file

cd caffe
cp Makefile.config.example Makefile.config

Edit Makefile.conf

vim Makefile.config

Edit the line

BLAS := atlas
Change ‘atlas’ to ‘open’

BLAS := open
And add a new line under it:

BLAS_INCLUDE := /usr/include/openblas
Then edit line: (located under “PYTHON_INCLUDE := /usr/include/python2.7 ”)

		/usr/lib/python2.7/dist-packages/numpy/core/include
Change python directory to ‘/usr/lib64/python2.7/site-packages/’, the line should then looks like that

		/usr/lib64/python2.7/site-packages/numpy/core/include
 

Then edit according to your device GPU capability:

Without GPU support:
Edit the line

# CPU_ONLY := 1
Remove the number sign “#”. The line will then looks like this:

CPU_ONLY := 1
Save and Close file

— OR —

With GPU support:

# USE_CUDNN := 1
Remove the number sign “#”. The line will then looks like this:

USE_CUDNN := 1

Start to compile Caffe

sudo make all
sudo make runtest
sudo make pycaffe
sudo make distribute
Done!

Now you can start to try Caffe examples and tutorials.

If you have any question, you can leave a comment.

原文地址:https://www.cnblogs.com/anmengcv/p/5641639.html