From: Balint Cristian Date: Fri, 13 Nov 2015 11:58:49 +0000 (+0200) Subject: Display and store cuDNN version numbers during cmake. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6f14f6e3d03caf8242ed5aa7e224a9ea8ef740d;p=platform%2Fupstream%2Fcaffe.git Display and store cuDNN version numbers during cmake. --- diff --git a/cmake/Cuda.cmake b/cmake/Cuda.cmake index 98aef26..286a428 100644 --- a/cmake/Cuda.cmake +++ b/cmake/Cuda.cmake @@ -183,12 +183,41 @@ function(detect_cuDNN) set(HAVE_CUDNN TRUE PARENT_SCOPE) set(CUDNN_FOUND TRUE PARENT_SCOPE) + file(READ ${CUDNN_INCLUDE}/cudnn.h CUDNN_VERSION_FILE_CONTENTS) + + # cuDNN v3 and beyond + string(REGEX MATCH "define CUDNN_MAJOR * +([0-9]+)" + CUDNN_VERSION_MAJOR "${CUDNN_VERSION_FILE_CONTENTS}") + string(REGEX REPLACE "define CUDNN_MAJOR * +([0-9]+)" "\\1" + CUDNN_VERSION_MAJOR "${CUDNN_VERSION_MAJOR}") + string(REGEX MATCH "define CUDNN_MINOR * +([0-9]+)" + CUDNN_VERSION_MINOR "${CUDNN_VERSION_FILE_CONTENTS}") + string(REGEX REPLACE "define CUDNN_MINOR * +([0-9]+)" "\\1" + CUDNN_VERSION_MINOR "${CUDNN_VERSION_MINOR}") + string(REGEX MATCH "define CUDNN_PATCHLEVEL * +([0-9]+)" + CUDNN_VERSION_PATCH "${CUDNN_VERSION_FILE_CONTENTS}") + string(REGEX REPLACE "define CUDNN_PATCHLEVEL * +([0-9]+)" "\\1" + CUDNN_VERSION_PATCH "${CUDNN_VERSION_PATCH}") + + if(NOT CUDNN_VERSION_MAJOR) + set(CUDNN_VERSION "???") + else() + set(CUDNN_VERSION "${CUDNN_VERSION_MAJOR}.${CUDNN_VERSION_MINOR}.${CUDNN_VERSION_PATCH}") + endif() + + message(STATUS "Found cuDNN: ver. ${CUDNN_VERSION} found (include: ${CUDNN_INCLUDE}, library: ${CUDNN_LIBRARY})") + + string(COMPARE LESS "${CUDNN_VERSION_MAJOR}" 3 cuDNNVersionIncompatible) + if(cuDNNVersionIncompatible) + message(FATAL_ERROR "cuDNN version >3 is required.") + endif() + + set(CUDNN_VERSION "${CUDNN_VERSION}" PARENT_SCOPE) mark_as_advanced(CUDNN_INCLUDE CUDNN_LIBRARY CUDNN_ROOT) - message(STATUS "Found cuDNN (include: ${CUDNN_INCLUDE}, library: ${CUDNN_LIBRARY})") + endif() endfunction() - ################################################################################################ ### Non macro section ################################################################################################ diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake index 6984f41..557a6f0 100644 --- a/cmake/Summary.cmake +++ b/cmake/Summary.cmake @@ -142,7 +142,7 @@ function(caffe_print_configuration_summary) caffe_status(" Target GPU(s) : ${CUDA_ARCH_NAME}" ) caffe_status(" GPU arch(s) : ${NVCC_FLAGS_EXTRA_readable}") if(USE_CUDNN) - caffe_status(" cuDNN : " HAVE_CUDNN THEN "Yes" ELSE "Not found") + caffe_status(" cuDNN : " HAVE_CUDNN THEN "Yes (ver. ${CUDNN_VERSION})" ELSE "Not found") else() caffe_status(" cuDNN : Disabled") endif()