This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use FindCUDNN.cmake instead of the previous macro - Previous macro did not detect CUDNN correctly on my system (Deep Learning AMI Ubuntu 18.04) - We now explicitly fail if the user does not provide CUDNN and hasn't manually set -DUSE_CUDNN=0
- Loading branch information
Showing
3 changed files
with
88 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (c) 2019, Facebook, Deepmind Technologies, NYU, NEC Laboratories | ||
# America and IDIAP Research Institute | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, this | ||
# list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories | ||
# America and IDIAP Research Institute nor the names of its contributors may be | ||
# used to endorse or promote products derived from this software without | ||
# specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, | ||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
# Find the CUDNN libraries | ||
# | ||
# The following variables are optionally searched for defaults | ||
# CUDNN_ROOT: Base directory where CUDNN is found | ||
# CUDNN_INCLUDE_DIR: Directory where CUDNN header is searched for | ||
# CUDNN_LIBRARY: Directory where CUDNN library is searched for | ||
# CUDNN_STATIC: Are we looking for a static library? (default: no) | ||
# | ||
# The following are set after configuration is done: | ||
# CUDNN_FOUND | ||
# CUDNN_INCLUDE_PATH | ||
# CUDNN_LIBRARY_PATH | ||
# | ||
# File taken from | ||
# https://github.com/pytorch/pytorch/blob/92750acb88ec5539658b1c51ee27a648ce92a33a/cmake/Modules_CUDA_fix/FindCUDNN.cmake | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
set(CUDNN_ROOT $ENV{CUDNN_ROOT_DIR} CACHE PATH "Folder containing NVIDIA cuDNN") | ||
if (DEFINED $ENV{CUDNN_ROOT_DIR}) | ||
message(WARNING "CUDNN_ROOT_DIR is deprecated. Please set CUDNN_ROOT instead.") | ||
endif() | ||
list(APPEND CUDNN_ROOT $ENV{CUDNN_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR}) | ||
|
||
# Compatible layer for CMake <3.12. CUDNN_ROOT will be accounted in for searching paths and libraries for CMake >=3.12. | ||
list(APPEND CMAKE_PREFIX_PATH ${CUDNN_ROOT}) | ||
|
||
set(CUDNN_INCLUDE_DIR $ENV{CUDNN_INCLUDE_DIR} CACHE PATH "Folder containing NVIDIA cuDNN header files") | ||
|
||
find_path(CUDNN_INCLUDE_PATH cudnn.h | ||
HINTS ${CUDNN_INCLUDE_DIR} | ||
PATH_SUFFIXES cuda/include include) | ||
|
||
option(CUDNN_STATIC "Look for static CUDNN" OFF) | ||
if (CUDNN_STATIC) | ||
set(CUDNN_LIBNAME "libcudnn_static.a") | ||
else() | ||
set(CUDNN_LIBNAME "cudnn") | ||
endif() | ||
|
||
set(CUDNN_LIBRARY $ENV{CUDNN_LIBRARY} CACHE PATH "Path to the cudnn library file (e.g., libcudnn.so)") | ||
if (CUDNN_LIBRARY MATCHES ".*cudnn_static.a" AND NOT CUDNN_STATIC) | ||
message(WARNING "CUDNN_LIBRARY points to a static library (${CUDNN_LIBRARY}) but CUDNN_STATIC is OFF.") | ||
endif() | ||
|
||
find_library(CUDNN_LIBRARY_PATH ${CUDNN_LIBNAME} | ||
PATHS ${CUDNN_LIBRARY} | ||
PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64) | ||
|
||
find_package_handle_standard_args(CUDNN DEFAULT_MSG CUDNN_LIBRARY_PATH CUDNN_INCLUDE_PATH) | ||
|
||
mark_as_advanced(CUDNN_ROOT CUDNN_INCLUDE_DIR CUDNN_LIBRARY) |