GPU+Cuda8.0+cudnn8+OpenCv2.4.13+Caffee 安装教程嘎嘎
2017-11-13 18:29
429 查看
1 安装CUDA准备工作
1.1.检查自己的GPU是否是CUDA-capable在终端中输入:
lspci| grep -i nvidia
,会显示自己的NVIDIA GPU版本信息
去CUDA的官网查看自己的GPU版本是否在CUDA的支持列表中
https://developer.nvidia.com/cuda-gpus
2、查看Linux发行版本,x86_64(64位)??
# uname--help /**或 uname -m && cat/etc/*release **/
3、检查gcc是否安装
# gcc -version
如果没有安装需要 # yum install gccgcc-c++
4、检查是否正确安装kernel headers。
#uname -r /**这是Kernelheaders的版本,必须在安装cuda驱动之前安装完成**/
#yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
在安装之前。注意:安装过程需要root用户权限。
1.2, 安装
下载run 文件
chmod +x XX.runinit 3
sh ./xx.run
选择
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64
361.62?
(y)es/(n)o/(q)uit: y
Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
安装完成,但是缺少一些库。
2) 安装所缺少的库
sudo apt-get install freeglut3-dev build-essential libx11-dev
libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa
libglu1-mesa-dev
安装完成。
Missingrecommended library: libGLU.so
yum install freeglut-devel
Missing recommended library: libX11.so
yum install libXqq-devel--nogpg
Missing recommended library: libXi.so
yum install libXi-devel.x86_64
Missing recommended library: libXmu.so
yum install libXmu-devel
libXilibXmu 安装失败,可忽略
查询网址:
http://rpmfind.net/linux/rpm2html/search.php?query=libXmu&submit=Search+...&system=&arch=
Issue1: Onno!Something
has gone wrong!
解决:安装run时没有选Install
NVIDIA AcceleratedGraphics Driver for Linux-x86_64 Y
1.检查路径 ~/dev下 有无存在名为 nvidia*
(以nvidia开头)的多个文件(device files)
若无,安装错误,见解决篇。
2.检查 CUDA Toolkit是否安装成功
终端输入 :
nvcc -V
会输出CUDA的版本信息(V要大写)
3.编译samples例子
进入到Samples安装目录,然后在该目录下终端输入make,等待十来分钟。
4.编译完成后测试
可以在Samples里面找到bin/x86_64/linux/release/目录,并切换到该目录
运行deviceQuery程序,sudo./deviceQuery
查看输出结果,重点关注最后一行,Pass表示通过测试
1.3安装后设置环境变量 PATH与添加库
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> /etc/bashrcecho 'exportLD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> /etc/bashrc
source /etc/bashrc
2安装cudnn6.5/8.0
· 安装cudnn比较简单,简单地说,就是复制几个文件:库文件和头文件。将cudnn的头文件复制到cuda安装路径的include路径下,将cudnn的库文件复制到cuda安装路径的lib64路径下。#解压文件 tar -zxvf cudnn-6.5-linux-x64-v2.tgz
#切换路径 cd cudnn-6.5-linux-x64-v2
#复制lib文件到cuda安装路径下的lib64/ sudo cp lib* /usr/local/cuda/lib64/
#复制头文件 sudo cp cudnn.h /usr/local/cuda/include/
#更新软连接 cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.6.5
sudo ln -s libcudnn.so.6.5.48 libcudnn.so.6.5
sudo ln -s libcudnn.so.6.5 libcudnn.so
· 到目前为止,cudnn已经安装完了
文件位置
· https://developer.nvidia.com/rdp/cudnn-archive页面中搜索 cuDNN v2 Library for Linux,
点击该链接下载
· 测试
· #运行cudnn-sample-v2 tar –zxvf cudnn-sample-v2.tgz
· cd cudnn-sample-v2
· make
· ./mnistCUDNN
· #改程序运行成功,说明cudnn安装成功。
·
·
·
文件位置
· https://developer.nvidia.com/rdp/cudnn-archive页面中搜索 cuDNN v2 Code Samples, 点击该链接下载
注意: 有可能cudnn与 caffe
版本出现不兼容,表现为编译caffe时出现未声明的变量
查看/usr/local/cudn/include/cudnn.h 检查
3 centos7 下opencv2.4.13安装
以管理员身份运行su root
输入密码
安装依赖包
yum install gcc gcc-c++ gtk2-devel cmakegimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devellibjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devellibdc1394-devel
jasper-devel jasper-utils swig python libtool nasm
官网下载opencv2.4.13.zip到usr/local
cd /usr/local
unzip opencv-2.4.13.zip
cd opencv-2.4.13/
cmake CMakeLists.txt
make
make install
cp /usr/local/opencv-2.4.13/unix-install/opencv.pc/usr/lib64/pkgconfig/
gedit /etc/ld.so.conf.d/opencv.conf
将以下内容添加到最后:
/usr/local/lib
保存关闭
ldconfig
gedit /etc/bash.bashrc
在文件后添加:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
保存关闭
重启终端
【测试】
cd/usr/local/opencv-2.4.13/samples/c
chmod +x build_all.sh
./build_all.sh
./facedetect --cascade="/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml"--scale=1.5lena.jpg
4 centos7 下caffe安装
我是从github下载最新的
安装依赖库
http://caffe.berkeleyvision.org/installation.html
· CUDA
is required for GPUmode.
o libraryversion 7+ and the latest driver version are recommended, but 6.* is fine too
o 5.5,and 5.0 are compatible but considered legacy
· BLASvia
ATLAS, MKL, or OpenBLAS.
· Boost>= 1.55
·
protobuf,
glog,
gflags,
hdf5
Optionaldependencies:
· OpenCV>= 2.4
including 3.0
· IO libraries:
lmdb,
leveldb
(note:leveldb requires
snappy)
· cuDNN for GPU acceleration (v6)
Pycaffeand Matcaffe interfaces have their own natural needs.
· For Python Caffe:
Python 2.7or
Python 3.3+,
numpy (>= 1.7),boost-provided
boost.python
· For MATLAB Caffe: MATLAB with the
mexcompiler.
General dependencies
sudo yum install protobuf-develleveldb-devel snappy-devel opencv-devel python-devel boost-devel hdf5-devel
Remaining dependencies, recent OS
sudo yum install gflags-devel glog-devellmdb-devel
注意:
如果自带低版本boost,卸载它, yum remove boost再用rpm
-qa boost不会输出任何信息,说明卸载成功.
发现安装的boost版本是1.53,要求>=1.55 所以卸载后安装1.55
CentOS 7.2安装Boost 1.55.0
boost安装
wget http:// href="http://www.mirrorservice.org/sites/dl.sourceforge.net/pub/sourceforge/b/bo/boost/boost/1.55.0/boost_1_55_0.tar.bz2" target=_blank>www.mirrorservice.org/sites/dl.sourceforge.net/pub/sourceforge/b/bo/boost/boost/1.55.0/boost_1_55_0.tar.bz2
1.
源博客中的链接地址一直出错,所以在网上找了上面的地址
2. $ tar jxvf boost_1_55_0.tar.bz2
3.
$ cd boost_1_55_0
4. $ ./bootstrap.sh
5.
$ ./b2
6. $ sudo ./b2 install
注意
Boost 前确认安装了Python
yum install python-devel
1、查看python版本
方法一:
python –V
2、查看Numpy版本
python -c"import numpy; print numpy.version.version"
3. 问题:
libs/iostreams/src/bzip2.cpp:20:56:致命错误:bzlib.h:没有那个文件或目录
yum -y install bzip2-devel
//验证开发环境
1. 测试代码
$ cat test_boost.cpp
#include <boost/version.hpp>
#include <boost/config.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
int main()
{
using boost::lexical_cast;
int a= lexical_cast<int>("123456");
double b = lexical_cast<double>("123.456");
std::cout << a << std::endl;
std::cout << b << std::endl;
return 0;
}
2.编译,运行
$ g++ -Wall -o test_boost test_boost.cpp
$ ls
test_boost test_boost.cpp
$ ./test_boost
123456
123.456
[root@localhostAIRelated]# cmake --version
cmakeversion 2.8.12.
In lieu of manually editingMakefile.config
to configurethe build, Caffe offers an unofficial CMake build thanks to @Nerei, @akosiorek,and other members of the community. It requires CMake version >= 2.8.7. Thebasic steps are as follows:
mkdir build
cd build
cmake ..
make all
make install
make runtest
还要安装blas
sudoyum install atlas-devel
这里需要注意的是,在caffe的Makefile.config中需要加入altas的路径,因为我在这里遇到了路径找不到的错误,配置之后就没有了:
BLAS_INCLUDE :=/usr/include/atlas
BLAS_LIB := /usr/lib64/atlas
如果还是有这个问题是因为 ATLAS现在的名称变了,要新建一下软链接
Cd /usr/lib64/atlas
sudo ln -svlibsatlas.so.3.10 libcblas.so
sudo ln -svlibsatlas.so.3.10 libatlas.so
问题:
1. Cudnn与 caffe
版本不兼容 换cudnn
头文件与库文件
2.
/bin/ld: cannot find -lcblas
/bin/ld: cannot find –latlas
解决方案
1,
先确定Makefile.config里面是否有配置了BLAS_LIB 和BLAS_INCLUDE,去掉前面的#号。
如果还是有这个问题是因为 ATLAS现在的名称变了,要新建一下软连
sudo ln -svlibsatlas.so.3.10 libcblas.so
sudo ln -svlibsatlas.so.3.10 libatlas.so
2,
改用openblas:
yum install openblas-devel
MakeFile.config配置如下:
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/include/atlas
#BLAS_LIB := /usr/lib64/atlas
后续一切成功。 done。
Cmake 时出错:
CMakeError at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108(message):
Could NOT find Atlas (missing:Atlas_LAPACK_LIBRARY)Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315(_FPHSA_FAILURE_MESSAGE)cmake/Modules/FindAtlas.cmake:43 (find_package_handle_standard_args)
cmake/Dependencies.cmake:113
1安装lapack:
[root@s011805161450~]#yum install lapack lapack-develblas blas-devel
2//改变BLAS
库名称
cmake -DBLAS=open ..
相关文章推荐
- Ubuntu16.04 64位机上安装OpenCV2.4.13 (CUDA8.0)版操作步骤
- Ubuntu 16.04 + cuda8.0 + opencv3 + caffe的安装,tensorflow-gpu的安装
- Tensorflow(GPU) 在Win10+Cuda8.0环境下安装以及Cudnn包配置 图文详细教程
- ubuntu16.04安装N卡驱动,cuda toolkit7.5,opencv 2.4.13 with module gpu
- ubuntu14.04下CUDA8.0+cuDNN+tensorflow(with gpu support)安装教程
- Ubuntu16.04+cuda-8.0+cudnn-v5.1+tensorflow0.8-gpu/tensorflow1.0-gpu安装教程
- OpenCV2.4.13+CUDA8.0+SSBA3.0+VS2010编译安装
- [置顶] Ubuntu14.04安装cuda8.0+cudnn5.1+Tensorflow1.0.0(GPU)教程
- win10下Visual Studio2015+cuda8.0+cudnn v5.1+Anaconda4.4.0+tensorflow+Keras+Pycharm+OpenCV3.2.0安装教程
- windows10+GeForce940M+cuda8.0+Anaconda3.4.2.0 + tensorflow-gpu(0.12.0rcl)安装教程
- Ubuntu16.04 / Windows10 安装 Tensorflow GPU版教程 CUDA9.0 - 请转CDA8.0
- 超详细 Ubuntu / Ubuntu Kylin 16.04 + OpenCV 2.4 + CUDA 8.0 + cuDNN 5.0 + Caffe_SSD 安装教程
- Caffe安装:Ubuntu16.04 + GPU + CUDA-8.0 + cuDNN v5.1 + OpenCV 3.0.0 + Anaconda2
- ubuntu16 安装OpenCV2.4.13 (CUDA8.0)
- Ubuntu 14.04 + Caffe + Cuda8.0 +Python2.7(GPU版)安装配置教程(傻瓜式)
- Ubuntu14.04 64位机上安装OpenCV2.4.13(CUDA8.0)版操作步骤
- CAFFE+1080Ti+CUDA8.0+CUDNN8.0+OPENCV3.0+MATLAB安装教程
- Ubuntu14.04 64位机上安装OpenCV2.4.13(CUDA8.0)版操作步骤
- 0-0不走坑路, 手把手教你Linux16.04, Anaconda3, CUDA8.0, cudnn v5.1 tensorflow GPU版, opencv3安装
- Ubuntu 14.04 64位系统安装cuda8.0+cudnn7.5+opencv+caffe 血泪教程