因为有项目想采用深度学习,而caffe是深度学习框架中比较理想的一款,并且跨平台,以及可以采用python/matlab的方式进行调用等优势,所以想在服务器上安装,下面就开始了血泪史。。。

服务器是阿里云的centos7.3,安装caffe,需要安装ffmpeg,boost,opencv等等。本文依照ffmpeg3.3.2 版,boost为1.64版,opencv为2.4.13.2,caffe的版本为最新版为例来说。

本文主要采用自行编译安装各大软件。

首先安装一些依赖包

 yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel SDL* yasm* python-devel nasm* cmake* git ncurses* *freetype2*

需要提一下,如果将来要采用python调用caffe的话,必须将numpy提前装好,最新的版本为1.13.2, ipython安装5.0版本(python2.7下)

安装Numpy 1.13.2 以及ipython

 pip install numpy
pip install pandas
pip install ipython==5.0

ok,装好就可以往下继续安装其他的的包了,先安装ffmpeg

1、安装x264编码器

因为最新版的x264进行编译的时候要求asm的版本较高,此处分享链接

 mkdir build
cd build
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120718-2245-stable.tar.bz2
tar -jxf x264-snapshot-20120718-2245-stable.tar.bz2 cd x264-snapshot-20120718-2245-stable/
./configure --prefix="/usr/local/ffmpeg" --bindir="/usr/local/ffmpeg/bin" --enable-static --enable-shared --enable-pic
make
make install

2、安装x265编码器

 cd build
git clone https://github.com/videolan/x265.git
cd x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr/local/ffmpeg/" -DENABLE_SHARED:bool=off ../../source
make
make install

3、安装libfdk_acc

 git clone --depth  git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="/usr/local/ffmpeg" --enable-shared --enable-static --with-pic make
make install

4、安装libmp3lame

 wget http://iweb.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar zxf lame-3.99..tar.gz
cd lame-3.99.
./configure --prefix="/usr/local/ffmpeg" --bindir="/usr/local/bin" --enable-shared --enable-nasm --enable-static --with-pic
make
make install

5、安装libopus

 git clone git://git.opus-codec.org/opus.git
cd opus
3 ./autogen.sh
./configure --prefix="/usr/local/ffmpeg" --enable-shared --enable-static --with-pic
make
make install

6、安装libogg库

 curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
tar xzvf libogg-1.3..tar.gz
cd libogg-1.3.
./configure --prefix="/usr/local/ffmpeg" --enable-shared --enable-static --with-pic
make
make install

7、安装libvorbis库

 curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz
tar xzvf libvorbis-1.3..tar.gz
cd libvorbis-1.3.
LDFLAGS="-L/usr/local/ffmpeg/lib"
CPPFLAGS="-I/usr/local/ffmpeg/include"
./configure --prefix="/usr/local/ffmpeg" --with-ogg="/usr/local/ffmpeg" --enable-shared --enable-static --with-pic
make
make install

8、安装libvps库

 git clone --depth  http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --prefix="/usr/local/ffmpeg" --enable-examples --enable-shared --enable-static --enable-pic
make
make install

9、编译安装ffmpeg

此处我才用的是2.8.12的代码,需要编辑ffplay.c,加上头文件<SDL/SDL_version.h>

修改 /etc/ld.so.conf 添加/usr/local/ffmpeg/lib

 git clone --depth  git://source.ffmpeg.org/ffmpeg
cd ffmpeg
export PKG_CONFIG_PATH=/usr/local/ffmpeg/lib/pkgconfig/:/usr/lib64/pkgconfig/:/usr/share/pkgconfig/$PKG_CONFIG_PATH
./configure --prefix="/usr/local/ffmpeg" --extra-cflags="-I/usr/local/ffmpeg/include" --extra-ldflags="-L/usr/local/ffmpeg/lib" --bindir="/usr/local/bin" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-avresample --enable-pic --enable-static --enable-shared
make
make install

10、编译安装boost

 wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar -zxf boost_1_64_0.tar.gz
cd boost_1_64_0
./boostrap.sh
./b2 install

11、再次安装一些依赖包

 yum install a52dec* giflib* imlib* lame* libICE* libXdmcp* *dc1394* *raw1394* *avc1394* *raw1394*
yum groupinstall "Development Tools"
yum install openssl* sqlite* gtk* *java* gstreamer* *v4l* gmp* gimp* *java* libpng*

12、安装opencv2.4.13.2

 ln -s /usr/include/libv4l1-videodev.h   /usr/include/linux/videodev.h
echo "/usr/local/ffmpeg/lib" >> /etc/ld.so.conf
ldconfig
export C_INCLUDE_PATH=/usr/local/ffmpeg/include/:/usr/include/:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/ffmpeg/include/:/usr/include/:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib/:/usr/loca/lib/:/usr/lib/:$LD_LIBRARY_PATH
wget https://github.com/opencv/opencv/archive/2.4.13.2.zip
unzip 2.4.13.2.zip
cd opencv-2.4.13.2/
mkdir build
cmake –D CMAKE_BUILD_TYPE=RELEASE–D CMAKE_INSTALL_PREFIX=./build/ ../opencv-2.4.13.2
make
make install

13、再次安装依赖包

 yum install protobuf* leveldb* snappy* hdf5* lmdb* libunwind*
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/google-glog/glog-0.3.3.tar.gz
tar -zxf glog-0.3..tar.gz
cd glog-0.3./
./configure --enable-static --enable-shared --with-pic
make
make install
wget https://github.com/schuhschuh/gflags/archive/master.zip
unzip master.zip
cd gflags-master/
mkdir build && cd build
export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=
make

14、安装BLAS,CBLAS,OpenBLAS

 wget http://www.netlib.org/blas/blas-3.7.1.tgz
tar -zxf blas-3.7..tgz
cd BLAS-3.7./
gfortran -c -O3 *.f
ar rv libblas.a *.o
wget http://www.netlib.org/blas/blast-forum/cblas.tgz
tar -zxf cblas.tgz
cd CBLAS/
cp Makefile.LINUX Makefile.in
cp ../BLAS-3.7./libblas.a testing/
cp lib/cblas_LINUX.a /usr/local/lib/libcblas.a
cp testing/libblas.a /usr/local/lib/libblas.a
cp include/cblas.h /usr/local/include/
wget http://github.com/xianyi/OpenBLAS/archive/v0.2.19.tar.gz
tar -zxf v0.2.19.tar.gz
cd OpenBLAS-0.2./
make
make PREFIX=/usr/local install
git clone https://github.com/BVLC/caffe.git
cd caffe
cp Makefile.config.example Makefile.config

15、编辑Makefile.config

 CPU_ONLY := 

 # CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr # CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
#CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
# -gencode arch=compute_20,code=sm_21 \
# -gencode arch=compute_30,code=sm_30 \
# -gencode arch=compute_35,code=sm_35 \
# -gencode arch=compute_50,code=sm_50 \
# -gencode arch=compute_52,code=sm_52 \
# -gencode arch=compute_60,code=sm_60 \
# -gencode arch=compute_61,code=sm_61 \
# -gencode arch=compute_61,code=compute_61 BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /usr/local/include
BLAS_LIB := /usr/local/lib

16、安装caffe

 cd python
for req in $(cat requirements.txt); do pip install $req; done
cd ..
make all
make test
make runtest
make pycaffe
cp -r python/caffe/ /usr/lib64/python2./site-packages/
echo "/root/build/caffe/.build_release/lib" >> /etc/ld.so.conf
pip uninstall numpy
wget https://pypi.python.org/packages/1a/5c/57c6920bf4a1b1c11645b625e5483d778cedb3823ba21a017112730f0a12/numpy-1.11.0.tar.gz#md5=bc56fb9fc2895aa4961802ffbdb31d0b
tar -zxf numpy-1.11..tar.gz
cd numpy-1.11.
python setup.py build
python setup.py install

 

CentOS7下安装caffe(包括ffmpeg\boost\opencv)的更多相关文章

  1. docker(一) Centos7下安装docker

    docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...

  2. centos7 下 安装部署nginx

    centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...

  3. CentOS7 下安装 iSCSI Target(tgt) ,使用 Ceph rbd

    目录 一.iSCSI 介绍 1. iSCSI 定义 2. 几种常见的 iSCSI Target 3. 优缺点比较 二.安装步骤 1. 关闭防火墙 2. 关闭selinux 3. 通过 yum 安装 t ...

  4. Centos7下安装Seafile实现私有网盘

    Seafile是一个开源.专业.可靠的云存储平台:解决文件集中存储.共享和跨平台访问等问题,由北京海文互知网络有限公司开发,发布于2012年10月:除了一般网盘所提供的云存储以及共享功能外,Seafi ...

  5. Windows和Linux(Centos7)下安装Nginx

    安装Nginx 这篇记录只不过做了一个简单总结,如果对这块没什么概念的话可以看一下知乎的这篇文章 https://zhuanlan.zhihu.com/p/83890573 window下安装 win ...

  6. CentOS7 下 安装 supervisor以及使用

    CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...

  7. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  8. Centos7下安装配置Redsocks

    Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...

  9. CentOS7下安装SVN服务端

    CentOS7下安装SVN服务 1. yum命令即可方便的完成安装# sudo yum install subversion 测试安装是否成功:# svnserve --version 更改svn的默 ...

随机推荐

  1. odoo开发笔记--模型中常用的方法

    create方法在数据表中插入一条记录(或新建一个对象的resource)格式:def create(self,cr,uid,vals,context={})参数:vals:待新建记录的字段值,是一个 ...

  2. Docker 之web api 访问 host sql server

    运行 Docker C:\Users\Administrator>docker run -it  -p 5000:5000 --name myapidocker1 webapiv1 root@3 ...

  3. 在matlab中实现PCA算法

    function [V,S,E]=princa(X) [m,n]=size(X); %计算矩阵的行m和列n %-------------第一步:标准化矩阵-----------------% mv=m ...

  4. Mysql的优化一则

    目的在于这么一个sql语句: SELECT w.* FROM wallpaper w inner join wallpaper_category_relation r ON w.wallpaper_i ...

  5. rtp header

    rtp协议基于udp传输,流媒体音视频数据被封装在rtp中,通过rtp协议进行实时的传输. 一.rtp协议头格式 The RTP header has a minimum size of 12 byt ...

  6. donet core 应用 部署到CentOS

    创建应用 新建一个Asp.net core Web API 应用 在program里指定监听端口 public static IWebHost BuildWebHost(string[] args) ...

  7. Yum安装Zabbix4.2.0

    目录 1. 下载所需的存储库 2. 安装zabbix 3. 安装mysql 4. 配置数据库 5. 基本配置 6. zabbix配置文件 7. 进入web安装zabbix 1. 下载所需的存储库 # ...

  8. -bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_US.UTF-8): No such file or directory -bash: warning: setlocale: LC_COLLATE:

    前几天登录服务器发现出现了这些个警告,一直没时间去处理他,今天难得有空,处理一下并记录下来,希望可以帮助到有需要的朋友. 警告信息如下: Last :: from 10.0.0.1 -bash: wa ...

  9. LVS+Heartbeat 高可用集群方案操作记录

    之前分别介绍了LVS基础知识和Heartbeat基础知识, 今天这里简单说下LVS+Heartbeat实现高可用web集群方案的操作说明. Heartbeat 项目是 Linux-HA 工程的一个组成 ...

  10. KMP字符串匹配算法理解(转)

    一.引言 主串(被扫描的串):S='s0s1...sn-1',i 为主串下标指针,指示每回合匹配过程中主串的当前被比较字符: 模式串(需要在主串中寻找的串):P='p0p1...pm-1',j 为模式 ...