您的位置:新葡亰496net > 电脑系统 > Centos配置深度学习开发环境,Caffe安装教程

Centos配置深度学习开发环境,Caffe安装教程

发布时间:2019-06-17 11:23编辑:电脑系统浏览(84)

    目录

    新葡亰496net 1

    1.本课程对应的条件

    system:ubuntu-16.04-desktop-amd64.iso
    cuda:cuda_8.0.44_linux-16.04.run
    cudnn:cudnn-8.0-linux-x64-v5.1.tgz
    caffe:

    设置显卡驱动

    系统安装→软件和更新→附加驱动
    选择使用NVIDIA binary driver - version 375.66 来自 nvidia-375 应用改造
    安装完毕后重启
    在终端中输入nvidia-smi

    一、安装 TensorFlow GPU 版本

            安装 TensorFlow-GPU 版的关键点在于 cuda 和 cudnn 的安装和配备,注意它们的本子是还是不是和 TensorFlow 的本子匹配。以下,以安装 TensorFlow 1.5.0 为例,个中格外的 cuda/cudnn 的版本分别为 cuda 9.0 和 cudnn 7.0。

    • 1. 设置显卡驱动
    • 2. 安装CUDACUDNN
    • 3. 安装TensorFlow-gpu
    • 测试

      紧接着上一篇的小说《深度学习(TensorFlow)意况搭建:(二)Ubuntu16.04 1080Ti显卡驱动》,那篇小说,首要教学如何设置CUDA CUDNN,但是前提是大家是曾经把NVIDIA显卡驱动装置好了

    2.安装Ubuntu-16.04

    略。安装基本更新。

    sudo apt-get update
    sudo apt-get upgrade
    

    CUDA

    官网下载
    PyTorch 0.3 支持 cuda9.0

    新葡亰496net 2

    CUDA下载

    运行
    cuda8.0
    sudo sh cuda_8.0.61_375.26_linux.run
    cuda9.0
    sudo sh cuda_9.0.176_384.81_linux.run

    显卡驱动装置采取n
    别的选拔y

    增加处境变量

    sudo gedit /etc/profile
    

    终极增添
    cuda8.0

    export PATH=/usr/local/cuda-8.0/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64$LD_LIBRARY_PATH
    

    cuda9.0

    export PATH=/usr/local/cuda-9.0/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH
    

    运行

    source /etc/profile
    

    测试

    cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
    sudo make
    ./deviceQuery
    

    新葡亰496net 3

    安装成功

    1.安装 NVIDIA 显卡驱动

            首先在顶峰查看显卡新闻:

    $ sudo lshw -numeric -C display
    

    也足以采纳命令:

    $ lspci | grep -i nvidia
    

    分明显卡消息。

            知道显卡消息之后,在 NVIDIA 官方网站搜索对应的显卡驱动,譬如 TITAN X(帕斯Carl)/GTX 1080Ti 等显卡查到的驱动为384。此外,使用

    $ ubuntu-drivers devices
    

    能够直接查看系统推荐的 NVIDIA 显卡驱动(在回去的新闻中找到 recommended 对应的 driver,比如英伟达-384)。一般的话,就算查询到的(及后续安装的)驱动不是流行版的,在安装时也会活动安装新型的(与系统适配)的显卡驱动。

            查询到显卡驱动之后,使用命令

    $ sudo apt-get install nvidia-xxx
    

    设置驱动。如要安装显卡驱动的本子为384,则附和的吩咐为:

    $ sudo apt-get install nvidia-384
    

            安装完毕现在,使用

    $ nvidia-smi
    

    翻看驱动是或不是安装成功。若重回一个关于驱动的报表表达安装成功。(只怕必要重启计算机)

    1. 装置显卡驱动

    • 检验显卡驱动及型号
    $ sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    
    • 添加ELPepo源
    $ sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
    
    • 安装NVIDIA驱动物检疫查测试
    $ sudo yum install nvidia-detect
    $ nvidia-detect -v
    
    $ yum -y install kmod-nvidia
    

    3.安装cuda-8.0

    cuDNN

    官方网站注册后下载
    选择cuDNN5.1或者cuDNN6(TensorFlow 1.3需要cuDNN6.0),下载cuDNN后解压,

    Download cuDNN v5.1 (Jan 20, 2017), for CUDA 8.0→cuDNN v5.1 Library for Linux
    Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0→cuDNN v6.0 Library for Linux
    [Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 9.0]→cuDNN v7.0.5 Library for Linux

    cuda8.0

    sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
    sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
    sudo chmod a r /usr/local/cuda/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*
    

    cuda9.0

    sudo cp cuda/include/cudnn.h /usr/local/cuda-9.0/include
    sudo cp cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64
    sudo chmod a r /usr/local/cuda/include/cudnn.h /usr/local/cuda-9.0/lib64/libcudnn*
    

    2.安装 CUDA 9.0

            在 NVIDIA 官网直接搜索 cuda,下载与操作系统相配的 runfile 文件,如 cuda_9.0.176_384.81_linux.run,进入该文件所在目录,实施

    $ sudo sh xxx.run --override
    

    如,以安装 cuda_9.0.176_384.81_linux.run 为例,试行命令

    $ sudo sh cuda_9.0.176_384.81_linux.run --override
    

    下一场按 Ctrl C 跳过more(0%),输入 accept,采用no(因为早已设置过显卡驱动了),前面根据必要采用 y/n 可顺遂实现安装。

            接下去为 cuda 配置境况变量:

    $ sudo gedit ~/.bashrc
    

    在开荒的文件末尾到场两行:

    export PATH=”$PATH:/usr/local/cuda-9.0/bin”
    export PATH=”$PATH:/usr/local/cuda-9.0/lib64”
    

    保留之后实行 $ source ~/.bashrc 使改换立时生效。(依照使用版本修改 cuda-9.0 对应项)

            在巅峰输入 $ nvcc --version 查看是不是安装成功,如输出版本音讯则意味安装成功。若提醒 nvcc 是船到江心补漏迟的下令,使用

    $ sudo apt install nvidia-cuda-toolkit
    

    设置,然后再确认。

            若要卸载 cuda,进入 cuda 安装路线,比方文件夹 /usr/local/cuda-9.0/bin 试行:

    $ sudo ./uninstall_cuda_9.0.pl
    

    2. 安装CUDACUDNN

    一、安装CUDA

      CUDA(Compute Unified Device Architecture),是英特尔集团生产的一种基于新的并行编程模型和指令集架构的通用总括框架结构,它能应用英特尔GPU的并行计算引擎,比CPU更敏捷的化解广大繁杂总计义务,想行使GPU就须求求使用CUDA。

    3.1 安装显卡驱动

    sudo add-apt-repository ppa:graphics-drivers/ppa
    sudo apt-get update
    sudo apt-get install nvidia-367
    

    新葡亰496net 4

    重启系统,使新驱动生效。使用AMD-smi测试是不是安装成功。
    新葡亰496net 5

    参考资料

    Ubuntu 16.04 CUDA 8 cuDNN 5.1安装

    3.布署 NVIDIA 深度学习库 cuDNN 7.0

            在 NVIDIA 官网寻觅 cudnn,注册开荒者账号,然后下载与 cuda 版本相配的 cudnn 文件,如与 cuda9.0 相称的 cudnn7.0 文件为:cudnn-9.0-linux-x64-v7.tgz 。进入该文件所在目录,实行

    $ tar -zxvf cudnn-9.0-linux-x64-v7.tgz
    $ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
    $ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
    

    退到根目录,施行:

    $ sudo chmod a r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
    

    2.1 cuda

    • 官方网址下载cuda,最佳下载9.0版本:
    • 慎选适合自身机器的设置,采取runfile(local)下载到centos中:
      新葡亰496net 6
    • 急需下载全数补丁,下载后装置cuda:
    $ sudo sh cuda_9.0.176_384.81_linux.run
    
    • 测试cuda是不是安装
    $ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
    $ sudo make
    $ ./deviceQuery
    

    结果:
    新葡亰496net 7

    1.1、下载CUDA

      首先在官方网站()下载对应的CUDA,如图所示:

    新葡亰496net 8

    只顾请务必下载runfile文件(后缀为.run),无法是任何文件。抑或间接通过wget命令下载:

    wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
    

     如图所示:

    新葡亰496net 9

    3.2 安装cuda-Toolkit

    4.安装 TensorFlow GPU 版

            使用如下指令直接设置 TensorFlow GPU 版:

    $ sudo pip/pip3 install tensorflow-gpu
    

    接下来,还索要将 2 中的意况变量修改为 TensorFlow 供给的格式:

    export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda-9.0/extras/CUPTI/lib64”
    export CUDA_HOME=/usr/local/cuda-9.0
    

    (注意将 cuda-9.0 修改为协和安装的照看版本)

    新葡亰496net,        最后,在 Python2.7/Python3.5 中使用

    >>> import tensorflow
    

    表明是或不是安装成功。

    2.2 cudnn

    • 下载cudnn文件,要求登记账号。
    • 安装下载好的cuDNN安装包,倘若您安装cuda的目录为暗中同意目录,就足以一直使用如下指令安装:
    tar -xvf cudnn-9.0-linux-x64-v7.1.tgz -C /usr/local/
    

    1.2、安装CUDA(一定要按顺序施行)

      下载实现后先实践安装相关注重的通令,纵然不先实施安装注重包,后边安装CUDA会以下错误报错:

    -------------------------------------------------------------
    Do you accept the previously read EULA?
    accept/decline/quit: accept
    
    Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
    (y)es/(n)o/(q)uit: n
    
    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
     [ default is /home/cmfchina ]: 
    
    Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
    Missing recommended library: libGLU.so
    Missing recommended library: libX11.so
    Missing recommended library: libXi.so
    Missing recommended library: libXmu.so
    
    Installing the CUDA Samples in /home/cmfchina ...
    Copying samples to /home/cmfchina/NVIDIA_CUDA-8.0_Samples now...
    Finished copying samples.
    
    ===========
    = Summary =
    ===========
    
    Driver:   Not Selected
    Toolkit:  Installed in /usr/local/cuda-8.0
    Samples:  Installed in /home/cmfchina, but missing recommended libraries
    
    Please make sure that
     -   PATH includes /usr/local/cuda-8.0/bin
     -   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
    
    To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
    
    Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.
    
    ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
    To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
        sudo <CudaInstaller>.run -silent -driver
    

      全部大家一定要安装顺序进行设置,先安装信赖的库文件。

    (1)安装缺点和失误的依赖库文件

    命令如下:

    sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-devlibgl1-mesa-glx libglu1  #安装依赖库
    

     

    新葡亰496net 10

    (2)安装实施文书

    sudo sh cuda_8.0.61_375.26_linux.run  #执行安装文件
    

      注意:安装进程中会提醒您实香港行政局部认可操作,首先是经受劳动条约,输入accept确认,然后会提醒是或不是安装cuda tookit、cuda-example等,均输入Y举办分明。但请留心,当领悟是还是不是安装附带的驱动时,一定要选N!

    新葡亰496net 11

      因为后边我们早就设置好新型的驱动NVIDIA381,附带的驱动是旧版本的还要会有标题,所以不要选拔设置驱动。其他的都直接暗许只怕选择是就能够。

    (3)设置情状变量

    •   输入指令,编辑情状变量配置文件

      sudo vim ~/.bashrc

    •   在文书末端追加以下两行代码(按钮“i”实行编写制定操作)

      export PATH=/usr/local/cuda-8.0/bin:$PATH
      export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH export CUDA_HOME=/usr/local/cuda

    •   保存退出(按“!wq”),实施上边发号施令,使意况变量立时见效

      #景况变量立刻生效 sudo source ~/.bashrc
      sudo ldconfig

     如图所示:

    新葡亰496net 12

    (4)检查cuda是还是不是配备不错

      到这一步,基本的CUDA已经安装完结了,大家得以经过以下命令查看CUDA是或不是配备不错:

    nvcc --version
    

      如图所示:

    新葡亰496net 13

    (5)测试CUDA的sammples

      为啥要求设置cuda samples?一方面为了后边学习cuda使用,另一方面,能够查证cuda是还是不是确实安装成功。假设cuda samples全体编写翻译通过,未有三个Error音信(Warning忽略),那么就证实成功地设置了cuda。假使最终一行即使显示PASS,不过编写翻译进程中有E奇骏RO卡宴,请自行互连网搜索相关错误新闻消除现在。

    # 切换到cuda-samples所在目录
    cd /usr/local/cuda-8.0/samples 或者 cd /home/NVIDIA_CUDA-8.0_Samples 
    
    # 没有make,先安装命令 sudo apt-get install cmake,-j是最大限度的使用cpu编译,加快编译的速度
    make –j
    
    # 编译完毕,切换release目录(/usr/local/cuda-8.0/samples/bin/x86_64/linux/release完整目录)
    cd ./bin/x86_64/linux/release
    
    # 检验是否成功,运行实例
    ./deviceQuery 
    
    # 可以认真看看自行结果,它显示了你的NVIDIA显卡的相关信息,最后能看到Result = PASS就算成功。
    

    如图所示:

    新葡亰496net 14

    新葡亰496net 15

     输出结果来看显卡相关音讯,并且最后Result = PASS ,那表明CUDA才真正完全安装成功了


    3.2.1 试行安装文件

    ./cuda_8.0.44_linux-16.04.run --override
    
    安装过程如下:
    
    Do you accept the previously read EULA? (accept/decline/quit): accept
    You are attempting to install on an unsupported configuration. Do you wish to continue? ((y)es/(n)o) [ default is no ]: y
    Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48? ((y)es/(n)o/(q)uit): n
    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 [ default is /home/kinghorn ]: /usr/local/cuda-8.0
    Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
    Finished copying samples.
    ===========
    = Summary =
    ===========
    Driver:   Not Selected
    Toolkit:  Installed in /usr/local/cuda-8.0
    Samples:  Installed in /usr/local/cuda-8.0
    

    新葡亰496net 16

    二、配置OpenCV(针对Python)

            以安插 OpenCV3.3.0 为例,别的版本类似。

    注意:到这段日子停止,直接运用:

    $ sudo pip/pip3 install opencv-python
    

    设置的 OpenCV 不辅助录制类操作。

    2.3 碰着变量设置

    • 情状变量
    $ vim ~/.bashrc
    在其最后添加:
    export PATH=/usr/local/cuda/bin${PATH: :${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH: :${LD_LIBRARY_PATH}}
    export CUDA_HOME=/usr/local/cuda
    
    • cuDNN构建连接
    $ cd /usr/local/cuda/lib64
    $ sudo rm -rf libcudnn.so libcudnn.so.7         #删除原有版本号,版本号在cudnn/lib64中查询
    $ sudo ln -s libcudnn.so.7.0.5 libcudnn.so.7    #生成软连接,注意自己下载的版本号
    $ sudo ln -s libcudnn.so.7 libcudnn.so 
    $ sudo ldconfig     #立即生效
    

    二、安装cuDNN

    ②装置情形变量

    vi /home/xxx/.bashrc
    

    情节如下:

    export PATH=/usr/local/cuda-8.0/bin:$PATH
    

    使情形变量生效

    source /home/xxx/.bashrc
    

    ③将cuda库加多到系统动态库管理器

    sudo vi /etc/ld.so.conf.d/cuda.conf
    

    添加:

    /usr/local/cuda/lib64
    

    施行ldconfig使新加的库生效

    sudo ldconfig
    

    1.装置重视项

    (1)更新安装包管理工科具

    $ sudo apt-get update
    $ sudo apt-get upgrade
    

    (2)安装编写翻译工具

    $ sudo apt-get install build-essential cmake pkg-config
    

    (3)安装倚重的图像库

    $ sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
    

    (4)安装正视的录制解码库

    $ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
    $ sudo apt-get install libv4l-dev libxvidcore-dev libx264-dev
    

    (5)安装 highgui 依赖的 GTK 库

    $ sudo apt-get install libgtk-3-dev
    

    (6)安装提醒矩阵运算的库

    $ sudo apt-get install libatlas-base-dev gfortran
    

    (7)安装 Python 开发库

    $ sudo apt-get install python2.7-dev python3.5-dev
    

    3. 安装TensorFlow-gpu

    • 安装anaconda,能够用来创立python3和TensorFlow的一对来讲蒙受。
    $ wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh    #下载anaconda
    $ bash anaconda.sh      #安装anaconda
    $ vim /root/.bashrc     #加入环境变量
        # 最后一行添加:
        export PATH="/root/anaconda3/bin:$PATH"
    $ source /root/.bashrc
    
    • 安装TensorFlow
    pip install tensorflow-gpu
    

    2.1、下载cuDNN

    cuDNN是GPU加快总括深层神经网络的库。首先去官方网站()下载cuDNN,须求登记一个账号才能下载,未有的话自身注册三个。由于自己的显卡是GTX1080Ti,所以下载版本号如图所示,最新的本子是v7: 

    新葡亰496net 17

    ④编写翻译cuda例子与测试

    进入到/usr/local/cuda/NVIDIA_CUDA-8.0_Samples/1_Utilities/deviceQuery目录推行:

    sudo make
    ./deviceQuery
    

    打字与印刷出临近如下新闻,表明装成功

    ./deviceQuery Starting...
     CUDA Device Query (Runtime API) version (CUDART static linking)
    Detected 2 CUDA Capable device(s)
    Device 0: "GeForce GTX 1080"
      CUDA Driver Version / Runtime Version          8.0 / 8.0
      CUDA Capability Major/Minor version number:    6.1
      Total amount of global memory:                 8110 MBytes (8504279040 bytes)
      (20) Multiprocessors, (128) CUDA Cores/MP:     2560 CUDA Cores
      GPU Max Clock rate:                            1772 MHz (1.77 GHz)
      Memory Clock rate:                             5005 Mhz
      Memory Bus Width:                              256-bit
      L2 Cache Size:                                 2097152 bytes
      Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
      Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
      Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
      Total amount of constant memory:               65536 bytes
      Total amount of shared memory per block:       49152 bytes
      Total number of registers available per block: 65536
      Warp size:                                     32
      Maximum number of threads per multiprocessor:  2048
      Maximum number of threads per block:           1024
      Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
      Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
      Maximum memory pitch:                          2147483647 bytes
      Texture alignment:                             512 bytes
      Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
      Run time limit on kernels:                     Yes
      Integrated GPU sharing Host Memory:            No
      Support host page-locked memory mapping:       Yes
      Alignment requirement for Surfaces:            Yes
      Device has ECC support:                        Disabled
      Device supports Unified Addressing (UVA):      Yes
      Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
      Compute Mode:
         < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
    

    2.编译 OpenCV

    (1)直接从 OpenCV 官方网址下载辅助全平台的 .zip 文件 3.3.0 安装包;
    (2)unzip 解压,并跻身文件夹:$ cd opencv-3.3.0
    (3)$ mkdir build && cd build
    (4)编译 OpenCV

    cmake -D CMAKE_BUILD_TYPE=RELEASE 
     -D CMAKE_INSTALL_PREFIX=/usr/local 
     -D INSTALL_PYTHON_EXAMPLES=ON 
     -D PYTHON2_EXCUTABLE=/usr/bin/python2 
     -D PYTHON3_EXCUTABLE=/usr/bin/python3 
     -D BUILD_EXAMPLES=ON ..  (两点不可少)
    

    注意:配置 OpenCV 需求在设置 CUDA 此前,不然这一步会停业。

    (5)$ make -j4
    (6)$ sudo make install
    (7)$ sudo ldconfig

    测试

    输入:

    $ python
    >>> import tensorflow
    

    显示:

    >>> import tensorflow
    /root/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
      from ._conv import register_converters as _register_converters
    >>> 
    

    未报错,安装成功。

    转发请评释出处。

    2.2、安装cuDNN

    安装cudnn比较轻松,轻松地说,正是复制多少个文本:库文件和头文件。将cudnn的头文件复制到cuda安装路线的include路径下,将cudnn的库文件复制到cuda安装路线的lib64路线下。具体操作如下

     1 #解压文件
     2 tar -zxvf cudnn-8.0-linux-x64-v7.tgz
     3 
     4 #切换到刚刚解压出来的文件夹路径
     5 cd cuda 
     6 #复制include里的头文件(记得转到include文件里执行下面命令)
     7 sudo cp /include/cudnn.h  /usr/local/cuda/include/
     8 
     9 #复制lib64下的lib文件到cuda安装路径下的lib64(记得转到lib64文件里执行下面命令)
    10 sudo cp lib*  /usr/local/cuda/lib64/
    11 
    12 #设置权限
    13 sudo chmod a r /usr/local/cuda/include/cudnn.h 
    14 sudo chmod a r /usr/local/cuda/lib64/libcudnn*
    15 
    16 #======更新软连接======
    17 cd /usr/local/cuda/lib64/ 
    18 sudo rm -rf libcudnn.so libcudnn.so.7   #删除原有动态文件,版本号注意变化,可在cudnn的lib64文件夹中查看   
    19 sudo ln -s libcudnn.so.7.0.2 libcudnn.so.7  #生成软衔接(注意这里要和自己下载的cudnn版本对应,可以在/usr/local/cuda/lib64下查看自己libcudnn的版本)
    20 sudo ln -s libcudnn.so.7 libcudnn.so #生成软链接
    21 sudo ldconfig -v #立刻生效
    

     

    备注:上边的软连接的版本号要基于自身其实下载的cudnn的lib版本号

    如图所示:

    新葡亰496net 18

    最后大家看看验证安装cudnn后cuda是不是依然可用

    nvcc --version  # or nvcc -V 
    

    (3)安装cudnn-v5.1库

    3.认证是或不是安装成功

            在 Python2.7 和 Python3.5 内试行(需求摄像头):

    >>> import cv2
    >>> cap = cv2.VideoCapture(0)
    >>> print(cap.isOpened())
    

    翻开是还是不是足以打开录像头。

    2.3、核实cuDNN是或不是安装成功

      到最近停止,cuDNN已经安装完了,可是,是还是不是中标安装,我们能够透过cuDNN sample测试一下( 页面中找到呼应的cudnn版本,里面有 cuDNN v5 Code Samples,点击该链接下载就可以,版本或然不均等,下载最新的就行)

      下载完,转到解压出的目录下的mnistCUDNN,如图所示:

    新葡亰496net 19

      通过上边发号施令,举办校验

    #运行cudnn-sample-v5
    tar –zxvf cudnn-sample-v5.tgz  #解压压缩包
    cd mnistCUDNN  #转到解压的mnistCUDNN目录下
    make  #make 命令下
    ./mnistCUDNN   #在mnistCUDNN目录下执行./mnistCUDNN
    #改程序运行成功,如果结果看到Test passed!说明cudnn安装成功。
    

     若是结果来看Test passed!表达cudnn安装成功

    新葡亰496net 20

     至此、cuDNN已经打响安装了


     

    ①解压

    tar xzvf cudnn-8.0-linux-x64-v5.1.tgz
    

    获取cuda文件夹里面富含lib64和include三个文件夹

    三、安装Anaconda

      Anaconda是python的叁个科学总计发行版,内置了数百个python平日会利用的库,也席卷广大做机械学习或数量发现的库,这么些库多数是TensorFlow的依赖库。安装好Anaconda能够提供叁个好的条件一向设置TensorFlow。

      去Anaconda官网()下载须求版本的Anaconda

    新葡亰496net 21

      下载完后实行如下命令

    sudo bash Anaconda3-4.4.0-Linux-x86_64.sh
    

      如图所示:

    新葡亰496net 22

      安装anaconda,回车的前边,是认同文件,接收许可。直接回车就能够。最终会理解是还是不是把anaconda的bin增添到用户的碰到变量中,选取yes。在巅峰输入python开掘依旧是系统自带的python版本,那是因为景况变量的更新还并未有奏效,命令行输入如下命令是安装的anaconda生效。即便conda --version未有找到其余消息,表达未有加入到遭逢变量未有,必要手动参与,如图所示:

    新葡亰496net 23

      刷新情况变量

    source /etc/profile 或者 source ~/.bashrc #(全局的环境变量)
    

    ②拷贝到cuda安装目录

    sudo cp cuda/cudnn.h /usr/local/cuda/include/
    sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
    

    拷贝后将链接删除重新树立链接,不然,拷贝是多少个多少个例外名字的同样文件,链接关系选取ls -l查看cudnn解压后的lib64文件夹。也足以分级拷贝每一个文件,链接文件拷贝使用cp -d命令。

    三、安装TensorFlow

      我们能够参照TensorFlow的法定安装教程(),官方网址提供的了 Pip, Docker, Virtualenv, Anaconda 或 源码编写翻译的主意安装 TensorFlow,大家那边最首要介绍以Anaconda安装。其余装置情势,大家可以到法定安装教程查看。

    4.安装opencv3.1.0

    3.1安装TensorFlow

      通过Anaconda安装TensorFlow CPU,TensorFlow 的官方下载源今后早已在GitHub上提供了(),找到呼应的本子号,如图所示:

    新葡亰496net 24

    (1)解压,创建build目录

    unzip opencv-3.1.0.zip
    cd opencv-3.1.0
    mkdir build
    

    (2)修改opencv源码,使其包容cuda8.0

    vi opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp
    

    修改如下:
    新葡亰496net 25
    将:

    #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)```
    

    改为:

    #if !defined(HAVE_CUDA)||defined(CUDA_DISABLER)||(CUDART_VERSION>=8000)
    

    (3)配置opencv,生成Makefile

    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    

    要是因为ippicv_linux_20161201.tgz包下载失利而招致Makefile生成战败,可透过手动下载ippicv_linux_20141201.tgz安装包,将其拷贝至
    opencv-3.1.0/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b目录内,重新试行配置命令就能够。

    (1)、创设二个名字为tensorflow的conda意况Python 3.6

    #Python 2.7
    conda create -n tensorflow python=2.7
    
    #Python 3.4
    conda create -n tensorflow python=3.4
    
    #Python 3.5
    conda create -n tensorflow python=3.5
    
    #Python 3.6
    conda create -n tensorflow python=3.6   #我下的TensorFlow对应的Python是3.6版本,那么我就使用这行
    
    备注:(根据TensorFlow版本号,一定要设置Python版本号,切记切记切记!!!!!重要的事情说三遍!否则后面会报各种错的)
    

    (4)编译

    make -j8
    

    编写翻译进程中只要出现如下错误:

    /usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char *) memcpy (__dest, __src, __n)   __n;
    

    那是因为ubuntu的g 版本过高以至的,只须要在opencv-3.1.0目录下的CMakeList.txt 文件的启幕参预:

    set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -D_FORCE_INLINES”)
    

    丰裕其后重新进行编写翻译就能够。

    (2)、激活 conda 环境

    source activate tensorflow
    

    (5)安装

    sudo make install
    

    (3)、TensorFlow 各样版本(最新的貌似是1.3的版本了)

      然后依据要安装的不一致tensorflow版本选用相应的一条下载链接(操作系统,Python版本,CPU版本如故CPU GPU版本),官方文档都有有关音信。

    Python 2.7
    
    CPU:
    https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp27-none-linux_x86_64.whl
    
    GPU:
    https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl
    ===============================================================================================
    
    Python 3.4
    
    CPU:
    https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl
    
    GPU:
    https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp34-cp34m-linux_x86_64.whl
    ===============================================================================================
    
    Python 3.5
    
    CPU:
    https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp35-cp35m-linux_x86_64.whl
    
    GP:
    https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp35-cp35m-linux_x86_64.whl
    ===============================================================================================
    
    Python 3.6
    
    CPU:
    https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl
    
    GPU:
    https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
    

    (6)查看版本号

    pkg-config --modversion opencv
    

    (4)、在conda境遇中设置TensorFlow GPU版(本文首要以安装GPU版疏解)

    5.安装caffe

      因为大家前面选用了conda情形为Python3.6的,所以大家选择Python3.6版本的GPU链接地址,实行设置

    #如何进行安装,我们这里安装Python版本为3.6的TensorFlow
    
    sudo pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
    
    备注:连接里的cpxx和cpxxm的xx是对应Python的版本号
    

    荒谬归结-重视关注!!!:

      安装whl包的时候出现“tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform”的主题材料。大家须求下载GPU版的安装包,在设置包下载之后,然后手动进入境况,安装TensorFlow。

    具体操作如下(因为笔者遇见那样难题,只好用上边这种艺术安装了):

    source activate tensorflow    #激活tensorflow环境(这步操作了,就忽略)
    cd /Downloads    #切换到whl文件所在文件夹
    pip install --ignore-installed --upgrade tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl   #切记,不要用sudo pip,也不要用pip3,然后--ignore-installed --upgrade等参数也不能省略,否则会出错。
    

       如图所示,TensorFlow安装成功了:

    新葡亰496net 26

    新葡亰496net 27

    一体化日志:

    cmfchina@cmfchina:~$ conda create -n tensorflow python=3.6
    Fetching package metadata .........
    Solving package specifications: .
    
    Package plan for installation in environment /home/cmfchina/.conda/envs/tensorflow:
    
    The following NEW packages will be INSTALLED:
    
        certifi:    2016.2.28-py36_0
        openssl:    1.0.2l-0        
        pip:        9.0.1-py36_1    
        python:     3.6.2-0         
        readline:   6.2-2           
        setuptools: 36.4.0-py36_1   
        sqlite:     3.13.0-0        
        tk:         8.5.18-0        
        wheel:      0.29.0-py36_0   
        xz:         5.2.3-0         
        zlib:       1.2.11-0        
    
    Proceed ([y]/n)? y
    
    #
    # To activate this environment, use:
    # > source activate tensorflow
    #
    # To deactivate this environment, use:
    # > source deactivate tensorflow
    #
    
    cmfchina@cmfchina:~$ source activate tensorflow
    (tensorflow) cmfchina@cmfchina:~$ wget https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
    --2017-09-26 10:06:45--  https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
    Resolving storage.googleapis.com (storage.googleapis.com)... 216.58.200.48, 2404:6800:4008:801::2010
    Connecting to storage.googleapis.com (storage.googleapis.com)|216.58.200.48|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 159078494 (152M) [application/octet-stream]
    Saving to: ‘tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl.1’
    
    tensorflow_gpu-1.3. 100%[===================>] 151.71M  2.99MB/s    in 52s     
    
    2017-09-26 10:07:38 (2.89 MB/s) - ‘tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl.1’ saved [159078494/159078494]
    
    (tensorflow) cmfchina@cmfchina:~$ pip install --ignore-installed --upgrade tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
    Processing ./tensorflow_gpu-1.3.0-cp36-cp36m-linux_x86_64.whl
    Collecting six>=1.10.0 (from tensorflow-gpu==1.3.0)
      Using cached six-1.11.0-py2.py3-none-any.whl
    Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow-gpu==1.3.0)
      Downloading tensorflow_tensorboard-0.1.6-py3-none-any.whl (2.2MB)
        100% |████████████████████████████████| 2.2MB 345kB/s 
    Collecting numpy>=1.11.0 (from tensorflow-gpu==1.3.0)
      Downloading numpy-1.13.1-cp36-cp36m-manylinux1_x86_64.whl (17.0MB)
        100% |████████████████████████████████| 17.0MB 93kB/s 
    Collecting protobuf>=3.3.0 (from tensorflow-gpu==1.3.0)
      Downloading protobuf-3.4.0-cp36-cp36m-manylinux1_x86_64.whl (6.2MB)
        100% |████████████████████████████████| 6.2MB 203kB/s 
    Collecting wheel>=0.26 (from tensorflow-gpu==1.3.0)
      Using cached wheel-0.30.0-py2.py3-none-any.whl
    Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
      Downloading bleach-1.5.0-py2.py3-none-any.whl
    Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
      Downloading Markdown-2.6.9.tar.gz (271kB)
        100% |████████████████████████████████| 276kB 834kB/s 
    Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
      Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
        100% |████████████████████████████████| 317kB 985kB/s 
    Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
      Downloading html5lib-0.9999999.tar.gz (889kB)
        100% |████████████████████████████████| 890kB 673kB/s 
    Collecting setuptools (from protobuf>=3.3.0->tensorflow-gpu==1.3.0)
      Using cached setuptools-36.5.0-py2.py3-none-any.whl
    Building wheels for collected packages: markdown, html5lib
      Running setup.py bdist_wheel for markdown ... done
      Stored in directory: /home/cmfchina/.cache/pip/wheels/bf/46/10/c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
      Running setup.py bdist_wheel for html5lib ... done
      Stored in directory: /home/cmfchina/.cache/pip/wheels/6f/85/6c/56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
    Successfully built markdown html5lib
    Installing collected packages: six, html5lib, bleach, markdown, numpy, werkzeug, setuptools, protobuf, wheel, tensorflow-tensorboard, tensorflow-gpu
    Successfully installed bleach-1.5.0 html5lib-0.9999999 markdown-2.6.9 numpy-1.13.1 protobuf-3.4.0 setuptools-36.5.0 six-1.11.0 tensorflow-gpu-1.3.0 tensorflow-tensorboard-0.1.6 werkzeug-0.12.2 wheel-0.30.0
    

    (1)安装必要的依赖库

    sudo apt-get install build-essential
    sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev 
    sudo apt-get libopencv-dev libhdf5-serial-dev protobuf-compiler
    sudo apt-get install --no-install-recommends libboost-all-dev
    sudo apt-get install libatlas-base-dev
    sudo apt-get install python-dev
    sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
    

    (2)解压修改配置文件

    unzip caffe-master.zip
    cp Makefile.config.example Makefile.config
    vi Makefile.config
    

    首要布局修改如下:

    USE_CUDNN := 1
    OPENCV_VERSION := 3
    CUDA_DIR :=/usr/local/cuda-8.0
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
    /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
    WITH_PYTHON_LAYER := 1
    USE_PKG_CONFIG := 1
    

    (3)编译caffe

    make -j8
    

    大概遇见的一无是处1:src/caffe/net.cpp:8:18: fatal error: hdf5.h: No such file or directory
    赶尽杀绝办法:

    cd /usr/lib/x86_64-linux-gnu
    sudo ln -s libhdf5_serial.so.10.1.0 libhdf5_serial.so
    sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_serial_hl.so
    

    只怕碰着的失实2:error – unsupported GNU version! gcc versions later than 5.3 are not supported!
    消除办法:修改/usr/local/cuda/include/host_config.h文件

    #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 3)
    #error -- unsupported GNU version! gcc versions later than 5.3 are not supported!
    

    改为:

     #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 4)
     #error -- unsupported GNU version! gcc versions later than 5.4 are not supported!
    

    恐怕遇到的不当3:

    /usr/include/string.h: In function ‘void* **__mempcpy_inline(void*, const void*, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char *) memcpy (__dest, __src, __n)   __n;**
    

    化解办法:修改caffe-master的Makefile

    NVCCFLAGS  =-ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
    

    改为:

    NVCCFLAGS  =-D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
    

    莫不蒙受的荒唐4:

    caffe/proto/caffe.pb.h: No such file or directory
    

    使用如下方法生成caffe.pb.h

    protoc src/caffe/proto/caffe.proto --cpp_out=.  
    mkdir include/caffe/proto  
    mv src/caffe/proto/caffe.pb.h include/caffe/proto 
    

    (5)、在conda境况中设置TensorFlow CPU版

    (4)编译caffe的python接口

    make pycaffe
    

      因为大家眼下选取了conda遇到为Python3.6的,所以大家挑选Python3.6本子的CPU链接地址,实行安装

    #如何进行安装,我们这里安装Python版本为3.6的TensorFlow
    
    sudo pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl
    
    备注:连接里的cpxx和cpxxm的xx是对应Python的版本号
    

    似是而非归结:

      安装whl包的时候出现“tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform”的难点,和位置安装GPU同样的失实。大家需求下载CPU版的安装包,在设置包下载之后,注意!!!今年大家须要将whl文件重命名叫tensorflow-1.3.0-py3-none-linux_x86_64.whl,然后手动进入情状,安装TensorFlow。

    具体操作如下:

    source activate tensorflow   #激活tensorflow环境(这步操作了,就忽略)
    cd /Downloads   #切换到whl文件所在文件夹
    pip install --ignore-installed --upgrade tensorflow-1.3.0-py3-none-linux_x86_64.whl   #切记,不要用sudo pip,也不要用pip3,然后--ignore-installed --upgrade等参数也不能省略,否则会出错。
    

    其余的和GPU安装是均等的,具体不做讲授。

    (5)运行caffe runtest

    make runtest
    

    此间时间有一些长。

    (6)、当你不要 TensorFlow 的时候,关闭意况

    source deactivate tensorflow
    

    6.运维手写体例程

    进入到caffe根目录下,运转脚本

    (7)、安装成功后,每回使用 TensorFlow 的时候要求激活 conda 景况(操作步骤2就足以了)

    (1)获取数据

    sh data/mnist/get_mnist.sh
    

    3.2、常见问题以及错误

    标题一、要是设置后,运营实例提醒ModuleNotFoundError: No module named ‘tensorflow’的话

    import tensorflow as tf
    Traceback (most recent call last):
    File “”, line 1, in
    ModuleNotFoundError: No module named ‘tensorflow’
    

      消除办法:下载的TensorFlow对应的Python版本一定要和conda create -n tensorflow python=x.x的版本一样才行,所以TensorFlow版本有的时候候太高反而倒霉,低版本包容性越来越好,这么些看个人愿望。

    难点二、出现“ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory”错误音信

    Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    Traceback (most recent call last):
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 342, in load_dynamic
        return _load(spec)
    ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
        from tensorflow.python import *
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "/home/cmfchina/.conda/envs/tensorflow/lib/python3.6/imp.py", line 342, in load_dynamic
        return _load(spec)
    ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
    

     那些都是有套路的,化解方法:

    • 先是检查是否存在libcundnn.so.*

      Centos配置深度学习开发环境,Caffe安装教程。find / -name libcudnn.so.*

    找到文件就下一步,没找到,检查下cudnn的重视库,就是眼下的处境变量做对了没

    • 确立硬连接

      sudo ln -s libcudnn.so.7.* libcudnn.so.6  #path便是libcudnn.so.7的四面八方目录

      或者

      sudo ln -s libcudnn.so.7.* libcudnn.so.6  #cd 到 libcudnn.so.7的到处目录    

    本条理应是没反常

    (2)将标签数据转变到caffe使用的LMDB数据格式

    sh examples/mnist/create_mnist.sh
    

    Centos配置深度学习开发环境,Caffe安装教程。3.3、卸载TensorFlow

      假设我们必要卸载TensorFlow的话,使用下边发号施令

    sudo pip uninstall tensorflow   #Python2.7
    
    sudo pip3 uninstall tensorflow   #Python3.x
    

    (3)推行练习脚本

    sh examples/mnist/train_lenet.sh
    

    陶冶时间各异的显卡练习时间差别,gtx1080迭代一千0次大致须要20s,最后结果如下所示:

    I0716 14:46:01.360709 27985 solver.cpp:404]     Test net output #0: accuracy = 0.9908
    I0716 14:46:01.360750 27985 solver.cpp:404]     Test net output #1: loss = 0.0303895 (* 1 = 0.0303895 loss)
    I0716 14:46:01.360755 27985 solver.cpp:322] Optimization Done.
    I0716 14:46:01.360757 27985 caffe.cpp:222] Optimization Done.
    

    新葡亰496net 28

    模型精度在0.99上述。至此,在ubuntu16.04种类下利用gtx1080显卡 cudnn-v5的花费情状就搭建实现了。

    Ubuntu 14.04 安装配置CUDA  http://www.linuxidc.com/Linux/2014-10/107501.htm

    Ubuntu 14.04下CUDA8.0 cuDNN v5 Caffe  设置配置  http://www.linuxidc.com/Linux/2017-01/139300.htm

    Caffe配置简明教程 ( Ubuntu 14.04 / CUDA 7.5 / cuDNN 5.1 / OpenCV 3.1 ) http://www.linuxidc.com/Linux/2016-09/135016.htm

    Ubuntu 16.04 安装配置MATLAB Python CUDA8.0 cuDNN OpenCV3.1的Caffe意况  http://www.linuxidc.com/Linux/2017-06/145087.htm

    在Ubuntu 14.04上配置CUDA Caffe cuDNN Anaconda DIGITS  http://www.linuxidc.com/Linux/2016-11/136775.htm

    深度学习条件安排Ubuntu16.04 CUDA8.0 CUDNN5  http://www.linuxidc.com/Linux/2017-09/147180.htm

    本文永恒更新链接地址:http://www.linuxidc.com/Linux/2017-10/147609.htm

    新葡亰496net 29

    3.4、测试TensorFlow

      在python的条件中,运营轻松的TensorFlow程序测试(官方demo)

    >>> import tensorflow as tf
    >>> hello = tf.constant('Hello, TensorFlow!')
    >>> sess = tf.Session()
    >>> sess.run(hello)
    'Hello, TensorFlow!'
    >>> a = tf.constant(10)
    >>> b = tf.constant(32)
    >>> sess.run(a   b)
    42
    >>> sess.close()
    

     运行如图所示:

    新葡亰496net 30

    时至明天,TensorFlow安装成功,进程充满了勤奋..(。•ˇ‸ˇ•。)…所以大家安装的时候每一步都珍视~

     

    PS:如有疑问,请留言,未经同意,不得不合法转发,转发请评释出处: 

    新葡亰496net 31

    新葡亰496net 32

    本文由新葡亰496net发布于电脑系统,转载请注明出处:Centos配置深度学习开发环境,Caffe安装教程

    关键词: