How to verify CuDNN installation?

前端 未结 9 935
余生分开走
余生分开走 2020-11-29 15:02

I have searched many places but ALL I get is HOW to install it, not how to verify that it is installed. I can verify my NVIDIA driver is installed, and that CUDA is installe

9条回答
  •  粉色の甜心
    2020-11-29 15:29

    My answer shows how to check the version of CuDNN installed, which is usually something that you also want to verify. You first need to find the installed cudnn file and then parse this file. To find the file, you can use:

    whereis cudnn.h
    CUDNN_H_PATH=$(whereis cudnn.h)
    

    If that doesn't work, see "Redhat distributions" below.

    Once you find this location you can then do the following (replacing ${CUDNN_H_PATH} with the path):

    cat ${CUDNN_H_PATH} | grep CUDNN_MAJOR -A 2
    

    The result should look something like this:

    #define CUDNN_MAJOR 7
    #define CUDNN_MINOR 5
    #define CUDNN_PATCHLEVEL 0
    --
    #define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
    

    Which means the version is 7.5.0.

    Ubuntu 18.04 (via sudo apt install nvidia-cuda-toolkit)

    This method of installation installs cuda in /usr/include and /usr/lib/cuda/lib64, hence the file you need to look at is in /usr/include/cudnn.h.

    CUDNN_H_PATH=/usr/include/cudnn.h
    cat ${CUDNN_H_PATH} | grep CUDNN_MAJOR -A 2
    

    Debian and Ubuntu

    From CuDNN v5 onwards (at least when you install via sudo dpkg -i .deb packages), it looks like you might need to use the following:

    cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
    

    For example:

    $ cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2                                                         
    #define CUDNN_MAJOR      6
    #define CUDNN_MINOR      0
    #define CUDNN_PATCHLEVEL 21
    --
    #define CUDNN_VERSION    (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
    
    #include "driver_types.h"
                          
    

    indicates that CuDNN version 6.0.21 is installed.

    Redhat distributions

    On CentOS, I found the location of CUDA with:

    $ whereis cuda
    cuda: /usr/local/cuda
    

    I then used the procedure about on the cudnn.h file that I found from this location:

    $ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
    

提交回复
热议问题