【亲测】centos 7 下安装cuDNN

来源:互联网 发布:java写的桌面程序 编辑:程序博客网 时间:2024/06/11 04:02

【亲测】centos 7 下安装cuDNN

【参考】

  1. http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html

【文件准备】

  1. cuda_8.0.61_375.26_linux.run
  2. cudnn-8.0-linux-x64-v5.1.tgz

【步骤】

  1. 切换到压缩包所在位置,解压
    $ tar -xzvf cudnn-8.0-linux-x64-v5.1.tgz

  2. 复制相关文件到cuda特定目录下(我的cuda安装目录为/usr/local/cuda/)

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

  3. 修改文件权限
    $ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

  4. 使用
    这个时候编译caffe可以将Makefile.config中的USE_CUDNN不注释,从而使用cuDNN加速
    # cuDNN acceleration switch (uncomment to build with cuDNN).
    USE_CUDNN := 1

【附录】

来源: http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html

2.3. Installing cuDNN on Linux
The following steps describe how to build a cuDNN dependent program. Choose the installation method that meets your environment needs. For example, the tar file installation applies to all Linux platforms. The debian installation package applies to Ubuntu 14.04 and 16.04.
In the following sections:

> your CUDA directory path is referred to as /usr/local/cuda/> your cuDNN download path is referred to as <cudnnpath>

2.3.1. Installing from a Tar File

  1. Navigate to your directory containing the cuDNN Tar file.
  2. Unzip the cuDNN package.
    $ tar -xzvf cudnn-9.0-linux-x64-v7.tgz

  3. Copy the following files into the CUDA Toolkit directory.

$ 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.3.2. Installing from a Debian File

1. Navigate to your <cudnnpath> directory containing cuDNN Debian file.2. Install the runtime library, for example:   sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb3. Install the developer library, for example:   sudo dpkg -i libcudnn7-dev_7.0.3.11-1+cuda9.0_amd64.deb4. Install the code samples and the cuDNN Library User Guide, for example:sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb

2.4. Verifying
To verify that cuDNN is installed and is running properly, compile the mnistCUDNN sample located in the /usr/src/cudnn_samples_v7 directory in the debian file.

  1. Copy the cuDNN sample to a writable path.
    $ cp -r /usr/src/cudnn_samples_v7/ $HOME

  2. Go to the writable path.
    $ cd $HOME/cudnn_samples_v7/mnistCUDNN

  3. Compile the mnistCUDNN sample.
    $make clean && make
  4. Run the mnistCUDNN sample.
    $ ./mnistCUDNN

If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:
Test passed!

Read more at: http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#ixzz4y6gZeDaA
Follow us: @GPUComputing on Twitter | NVIDIA on Facebook