实时警报通知:微信告警通知的重要性解析
728
2023-02-13
centos6.5 下安装caffe
注:系统安装好后,先确认kernel kernel-headers kernel-devel kernel-firmware四个包的版本要相同
1 | #rpm -qa |grep kernel |
注: 先修改yum配置文件 /etc/yum.conf 修改 keepcache=1
1. 安装库
2、JDK安装
编译安装python2.7(必须先安装zlib与openssl的包再执行编译)
先安装gcc zlib openssl 等包
1 2 3 4 5 | tar-xvf Python-2.7.9.tgz-C/usr/src cd/usr/src/Python-2.7.9 ./configure--enable-shared make-j12 make altinstall |
(altinstall在安装时会区分已存在的版本)(解决libpython2.7.so.1.0办法:vi /etc/ld.so.conf 添加/usr/local/lib,然后ldconfig)
替换系统中的python
1 2 3 | ls-l`which python python2 python2.6` rm/usr/bin/python ln-s-f/usr/local/bin/python2.7/usr/bin/python |
保持yum可用性
1 2 | vim/usr/bin/yum #!/usr/bin/python 改为 #!/usr/bin/python2.6 |
4、安装pip
(必须先安装openssl-devel与zlib的包,再执行python编译,若执行该命令的时候出现红色cann't remove easy-install.pth的提醒,但目录下又无此文件,可新建后再次执行一遍命令,安装系统的时候最好把开发工具的选项给勾上,出现“Successfully installed pip-6.0.8 setuptools-14.3.1为安装成功”)
5、安装cuda-6.5及驱动
GTX 660显卡装cuda后会导致Xorg狂奔,直至系统死机,需要将/etc/inittab中的启动级别改为3注,驱动包文件结构不对,导致nvidia_uvm.ko模块无法编译,需手动解决
1 2 | cd/var/lib/dkms/nvidia/346.46 cp-rv/usr/src/nvidia-346.46build |
如果使用yum 方式安装的使用下载下的驱动包升级下
1 2 | chmod+xNVIDIA-Linux-x86_64-346.72.run ./NVIDIA-Linux-x86_64-346.72.run |
重启后,dkms会在开机时完成nvidia_uvm.ko的编译
/lib/modules/版本号/extra/下有两个包:nvidia.ko nvidia_uvm.ko
1 2 3 | lsmod|grep nvidia vi/etc/rc.local#编辑该文件 modprobe nvidia_uvm#添加该条 |
5.1 run包安装方式
1 2 | chmod+xcuda_6.5.19_linux_64.run ./cuda_6.5.19_linux_64.run |
6、安装blas
yum -y install blas.x86_64 blas-devel.x86_64 \atlas.x86_64 atlas-devel.x86_64 atlas-sse3.x86_64 atlas-sse3-devel.x86_64
7、安装opencv
1 2 | yum-yinstall ant.x86_64 gcc.x86_64 gcc-c++.x86_64 cmake.x86_64 git.x86_64 pkgconfig.x86_64 gtk2.x86_64 gtk2-devel.x86_64 libdc1394.x86_64 libdc1394-devel.x86_64 libjpeg-turbo.x86_64 libjpeg-turbo-devel.x86_64 libpng.x86_64 libpng-devel.x86_64 libtiff.x86_64 libtiff-devel.x86_64 jasper.x86_64 jasper-libs.x86_64 jasper-devel.x86_64 yasm.x86_64 yasm-devel.x86_64 pip install numpy |
安装ffmpeg: #此包不需要通过yum安装,yum安装版本不对
1 2 3 4 5 6 7 | tar-xf ffmpeg-2.6.1.tar.bz2-C/usr/src cd/usr/src/ffmpeg-2.6.1/ ./configure--enable-shared#要以共享库方式配置,否则opencv编译时链接静态库会出错 make-j12&&make install unzip opencv-2.4.9 cd opencv-2.4.9 mkdir release&&cd release |
修改源文件NCVPixelOperations.hpp,文件替换到opencv路径下的modules/gpu/src/nvidia/core/NCVPixelOperations.hpp配置环境变量:
1 2 3 4 5 6 7 8 9 10 11 12 | vim/etc/profile.d/custom.sh配置完成source/etc/profile.d/custom.sh #!/bin/bash export PATH=/usr/local/MATLAB/R2014a/bin:/usr/local/cuda-6.5/bin:$PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/boost-1.55.0/lib:/usr/local/cuda-6.5/lib64:/opt/caffe-master/build/lib:/usr/lib64/atlas export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/boost-1.55.0/lib:/usr/local/cuda-6.5/lib64:/opt/caffe-master/build/lib:/usr/lib64/atlas export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/boost-1.55.0/include:/usr/local/cuda-6.5/include:/opt/caffe-master/build/src:/opt/caffe-master/include export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/boost-1.55.0/include:/usr/local/cuda-6.5/include:/opt/caffe-master/build/src:/opt/caffe-master/include export PYTHONPATH=$PYTHONPATH:/opt/caffe-master/python export HISTTIMEFORMAT="%F %T " cmake-DCMAKE_BUILD_TYPE=RELEASE-DCMAKE_INSTALL_PREFIX=/usr/local.. make–j12 make install |
8、安装boost-1.55(1.56不兼容)
1 2 3 4 5 | yum-yinstall libicu.x86_64 libicu-devel.x86_64 bzip2-libs.x86_64 bzip2-devel.x86_64 tar–xf boost_1_55_0.tar.gz&&cd boost_1_55_0 ./bootstrap.sh ./b2 ./b2 install |
运行./b2 install命令,默认安装在/usr/local/lib目录下,头文件在/usr/local/include/boost目录下
9、安装caffe其他依赖:
1 2 3 4 5 6 7 8 9 | yum-yinstall snappy.x86_64 snappy-devel.x86_64 hdf5.x86_64 hdf5-devel.x86_64 epel-release leveldb.x86_64 leveldb-devel.x86_64 libgfortran.x86_64 ------编译安装protobuf-2.5.0protobuf-2.5.0 ------tar-xvf protobuf-2.5.0.tar.gz ------cd/usr/src/protobuf-2.5.0 ./configure make make check make install ------export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH |
10、编译安装caffe其他依赖包
11、将matlab上传至服务器,通过图形方式安装
安装秘钥12345-67890-12345-67890安装完成后导入lic文件,然后替换libmwservices.so到/usr/local/MATLAB/R2014a/bin/glnxa64/进行覆盖,结束安装。
12、解决python依赖
1 2 3 | pip install'six>=1.3' easy_install-Udistribute pip2.7install PIL--allow-external PIL--allow-unverified PIL |
解包caffe-master.zip,并将该包移至opt目录
1 2 | cd/opt/caffe-master/python foriin$(cat requirements.txt);dopip install$i;done#需要多执行几遍 |
注:会出现一个报错,关于PIL.Image >= 1.1.7,则可使用命令pip install 'PIL' 进行安装后再次执行以上的for循环语句,需要将python升级至2.7以上版本(安装及注意事项下:)
13、安装caffe
修改caffe-master/Makefile.config文件,增加如下几句
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | cp/opt/caffe-master/Makefile.config.example Makefile.config vim Makefile.config MATLAB_DIR:=/usr/local/MATLAB/R2014a/ BLAS:=atlas BLAS_LIB:=/usr/lib64/atlas PYTHON_INCLUDE:=/usr/include/python2.7\ /usr/local/lib/python2.7/site-packages/numpy/core/include\ /usr/local/include/python2.7 执行ldconfig make all-j12 make–j12 pycaffe make–j12 matcaffe make test–j12 make runtest–j12 |
如果matlab要使用静态编译libprotobuf.a的话,修改Makefile在MATLAB_CXXFLAGS项上添加-static参数即可但使用动态库的matlab模型可能不可用
若一切没有问题,至此caffe环境安装结束,待测试。
以下为可选部分
编译安装protobuf-2.5.0 protobuf-2.5.0
1 2 3 4 5 6 7 | tar-xvf protobuf-2.5.0.tar.gz cd/usr/src/protobuf-2.5.0 ./configure make make check make install export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH |
继续安装protobuf的python模块(如果不用python,可跳过这一步)
1 2 3 4 | #cd ./python #python setup.py build #python setup.py test #python setup.py install |
安装cudnnLINUX
a. 编辑确保Makefile.config,启用GPU “# CPU_ONLY := 1”,并设置 “USE_CUDNN := 1”。
b. 安装cuDNN
1 2 3 4 5 6 7 8 9 10 | tar-xzvf cudnn-6.5-linux-R1.tgz cd cudnn-6.5-linux-R1 cp lib*/usr/local/cuda-6.5/lib64/ cp cudnn.h/usr/local/cuda-6.5/include/ cd/usr/local/cuda-6.5/lib64/ rm-rf libcudnn.so libcudnn.so.6.5 chmodu=rwx,g=rx,o=rx libcudnn.so.6.5.18 ln-slibcudnn.so.6.5.18libcudnn.so.6.5 ln-slibcudnn.so.6.5libcudnn.so ldconfig |
注1:将相关的头文件,库文件放到profile中定义的系统路径里即可,matlab的mex运行时需要加载对应库
caffe编译时也可在Makefile.config中修改,添加cuDNN的路径/cache/INSTALL_cuDNN/cudnn-6.5-linux-R1
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /cache/INSTALL_cuDNN/cudnn-6.5-linux-R1
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /cache/INSTALL_cuDNN/cudnn-6.5-linux-R1
注2:在使用tesla-c2050显卡时,需要在Makefile.config里改如下几个地方:
PYTHON_LIB := /usr/lib64 #原为PYTHON_LIB := /usr/libLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib64 /usr/lib64 #原为如下:LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
注3:protobuf手动安装,不需要通过yum,yum安装版本不对,make runtest会报错,使用protobuf2.5的版本,安装方式见上,在编译caffe前安装好后再进行编译。
包:咖啡环境需要上传的包:gflags-master.zip、opencv-2.4.9.zip、boost_1_55_0.tar.gz、caffe-master.zip、glog-0.3.3.tar.gz、protobuf-2.5.0.tar.gz、cuda-repo-rhel6-6.5-14.x86_64.rpm、jdk-7u25-linux-x64.tar.gz、lmdb.tar、Python-2.7.9.tgz、 ffmpeg-2.6.1.tar.bz2、rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm、NVIDIA-Linux-x86_64-346.72.run、NCVPixelOperations.hpp、matlab文件夹
作者:峥叔、小葱 (③群),感谢两位投稿!
发表评论
评论列表