设为首页 收藏本站
查看: 779|回复: 0

[经验分享] CentOS下安装caffe(组合版本)

[复制链接]

尚未签到

发表于 2017-6-1 11:22:27 | 显示全部楼层 |阅读模式
(一)安装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>  


  
$ cd>  
$ 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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-382054-1-1.html 上篇帖子: Centos 6.5 安装 Nginx+MySQL+PHP 下篇帖子: 【原】Centos 7 下创建LVM流程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表