2021-04-14 06:15:32 +08:00
set ( MINIMUM_CUDNN_VERSION "7.6.5" )
2019-09-25 03:58:38 +08:00
2021-04-20 02:22:14 +08:00
vcpkg_find_cuda ( OUT_CUDA_TOOLKIT_ROOT CUDA_TOOLKIT_ROOT OUT_CUDA_VERSION CUDA_VERSION )
2020-11-24 07:25:27 +08:00
# Try to find CUDNN if it exists; only download if it doesn't exist
2021-04-14 06:15:32 +08:00
find_path ( CUDNN_INCLUDE_DIR NAMES cudnn.h cudnn_v8.h cudnn_v7.h
2024-08-21 03:36:01 +08:00
H I N T S $ { C U D A _ T O O L K I T _ R O O T } $ E N V { C U D A _ P A T H } $ E N V { C U D A _ T O O L K I T _ R O O T _ D I R } $ E N V { c u d n n } $ E N V { C U D N N } $ E N V { C U D N N _ R O O T _ D I R } $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 0 $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 1 $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 2 $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 3 / u s r / i n c l u d e / u s r / i n c l u d e / x 8 6 _ 6 4 - l i n u x - g n u / / u s r / i n c l u d e / a a r c h 6 4 - l i n u x - g n u /
P A T H _ S U F F I X E S c u d a / i n c l u d e i n c l u d e i n c l u d e / 1 1 . 8 i n c l u d e / 1 2 . 0 i n c l u d e / 1 2 . 1 i n c l u d e / 1 2 . 2 i n c l u d e / 1 2 . 3 i n c l u d e / 1 2 . 4 i n c l u d e / 1 2 . 5 i n c l u d e / 1 2 . 6 )
2021-04-20 02:22:14 +08:00
message ( STATUS "CUDNN_INCLUDE_DIR: ${CUDNN_INCLUDE_DIR}" )
2021-04-14 06:15:32 +08:00
find_library ( CUDNN_LIBRARY NAMES cudnn cudnn8 cudnn7
2024-08-21 03:36:01 +08:00
H I N T S $ { C U D A _ T O O L K I T _ R O O T } $ E N V { C U D A _ P A T H } $ E N V { C U D A _ T O O L K I T _ R O O T _ D I R } $ E N V { c u d n n } $ E N V { C U D N N } $ E N V { C U D N N _ R O O T _ D I R } $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 0 $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 1 $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 2 $ E N V { C U D A _ P A T H } / . . / . . / . . / N V I D I A / C U D N N / v 9 . 3 / u s r / l i b / x 8 6 _ 6 4 - l i n u x - g n u / / u s r / i n c l u d e / a a r c h 6 4 - l i n u x - g n u / / u s r /
P A T H _ S U F F I X E S l i b l i b 6 4 c u d a / l i b c u d a / l i b 6 4 l i b / x 6 4 c u d a / l i b / x 6 4 l i b / 1 1 . 8 / x 6 4 l i b / 1 2 . 0 / x 6 4 l i b / 1 2 . 1 / x 6 4 l i b / 1 2 . 2 / x 6 4 l i b / 1 2 . 3 / x 6 4 l i b / 1 2 . 4 / x 6 4 l i b / 1 2 . 5 / x 6 4 l i b / 1 2 . 6 / x 6 4 )
2021-04-20 02:22:14 +08:00
message ( STATUS "CUDNN_LIBRARY: ${CUDNN_LIBRARY}" )
2020-11-24 07:25:27 +08:00
if ( EXISTS "${CUDNN_INCLUDE_DIR}/cudnn.h" )
file ( READ ${ CUDNN_INCLUDE_DIR } /cudnn.h CUDNN_HEADER_CONTENTS )
2021-04-14 06:15:32 +08:00
elseif ( EXISTS "${CUDNN_INCLUDE_DIR}/cudnn_v8.h" )
file ( READ ${ CUDNN_INCLUDE_DIR } /cudnn_v8.h CUDNN_HEADER_CONTENTS )
elseif ( EXISTS "${CUDNN_INCLUDE_DIR}/cudnn_v7.h" )
file ( READ ${ CUDNN_INCLUDE_DIR } /cudnn_v7.h CUDNN_HEADER_CONTENTS )
endif ( )
if ( EXISTS "${CUDNN_INCLUDE_DIR}/cudnn_version.h" )
file ( READ "${CUDNN_INCLUDE_DIR}/cudnn_version.h" CUDNN_VERSION_H_CONTENTS )
string ( APPEND CUDNN_HEADER_CONTENTS "${CUDNN_VERSION_H_CONTENTS}" )
unset ( CUDNN_VERSION_H_CONTENTS )
elseif ( EXISTS "${CUDNN_INCLUDE_DIR}/cudnn_version_v8.h" )
file ( READ "${CUDNN_INCLUDE_DIR}/cudnn_version_v8.h" CUDNN_VERSION_H_CONTENTS )
string ( APPEND CUDNN_HEADER_CONTENTS "${CUDNN_VERSION_H_CONTENTS}" )
unset ( CUDNN_VERSION_H_CONTENTS )
elseif ( EXISTS "${CUDNN_INCLUDE_DIR}/cudnn_version_v7.h" )
file ( READ "${CUDNN_INCLUDE_DIR}/cudnn_version_v7.h" CUDNN_VERSION_H_CONTENTS )
string ( APPEND CUDNN_HEADER_CONTENTS "${CUDNN_VERSION_H_CONTENTS}" )
unset ( CUDNN_VERSION_H_CONTENTS )
endif ( )
if ( CUDNN_HEADER_CONTENTS )
string ( REGEX MATCH "define CUDNN_MAJOR * +([0-9]+)"
_ C U D N N _ V E R S I O N _ M A J O R " $ { C U D N N _ H E A D E R _ C O N T E N T S } " )
string ( REGEX REPLACE "define CUDNN_MAJOR * +([0-9]+)" "\\1"
_ C U D N N _ V E R S I O N _ M A J O R " $ { _ C U D N N _ V E R S I O N _ M A J O R } " )
string ( REGEX MATCH "define CUDNN_MINOR * +([0-9]+)"
_ C U D N N _ V E R S I O N _ M I N O R " $ { C U D N N _ H E A D E R _ C O N T E N T S } " )
string ( REGEX REPLACE "define CUDNN_MINOR * +([0-9]+)" "\\1"
_ C U D N N _ V E R S I O N _ M I N O R " $ { _ C U D N N _ V E R S I O N _ M I N O R } " )
string ( REGEX MATCH "define CUDNN_PATCHLEVEL * +([0-9]+)"
_ C U D N N _ V E R S I O N _ P A T C H " $ { C U D N N _ H E A D E R _ C O N T E N T S } " )
string ( REGEX REPLACE "define CUDNN_PATCHLEVEL * +([0-9]+)" "\\1"
_ C U D N N _ V E R S I O N _ P A T C H " $ { _ C U D N N _ V E R S I O N _ P A T C H } " )
2020-11-24 07:25:27 +08:00
if ( NOT _CUDNN_VERSION_MAJOR )
set ( _CUDNN_VERSION "?" )
else ( )
set ( _CUDNN_VERSION "${_CUDNN_VERSION_MAJOR}.${_CUDNN_VERSION_MINOR}.${_CUDNN_VERSION_PATCH}" )
endif ( )
endif ( )
2021-04-14 06:15:32 +08:00
if ( CUDNN_INCLUDE_DIR AND CUDNN_LIBRARY AND _CUDNN_VERSION VERSION_GREATER_EQUAL MINIMUM_CUDNN_VERSION )
message ( STATUS "Found CUDNN ${_CUDNN_VERSION} located on system: (include ${CUDNN_INCLUDE_DIR} lib: ${CUDNN_LIBRARY})" )
2020-11-24 07:25:27 +08:00
set ( VCPKG_POLICY_EMPTY_PACKAGE enabled )
2021-04-27 01:27:45 +08:00
elseif ( VCPKG_TARGET_IS_WINDOWS )
2024-08-21 03:36:01 +08:00
message ( FATAL_ERROR "Please download CUDNN from official sources (https://developer.nvidia.com/cudnn) and install it" )
2021-04-27 01:27:45 +08:00
else ( )
message ( FATAL_ERROR "Please install CUDNN using your system package manager (the same way you installed CUDA). For example: apt install libcudnn8-dev." )
2021-04-14 06:15:32 +08:00
endif ( )
2021-05-18 15:28:38 +08:00
2022-06-18 06:48:09 +08:00
file ( INSTALL "${CURRENT_PORT_DIR}/FindCUDNN.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" )
file ( INSTALL "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" )
file ( INSTALL "${CURRENT_PORT_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" )