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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM