2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2014,2015,2017,2018, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
39 # Find the NVIDIA Management Library (NVML) includes and library. NVML documentation
40 # is available at: http://docs.nvidia.com/deploy/nvml-api/index.html
42 # Starting with CUDA 8 NVML is part of the CUDA Toolkit. Prior to CUDA 8 NVML was part
43 # of the GPU Deployment Kit (GDK) and GPU_DEPLOYMENT_KIT_ROOT_DIR can be specified
44 # if the GPU Deployment Kit is not installed in a default location.
46 # FindNVML defines the following variables:
48 # NVML_INCLUDE_DIR, where to find nvml.h, etc.
49 # NVML_LIBRARY, the libraries needed to use NVML.
50 # NVML_FOUND, If false, do not try to use NVML.
53 # Jiri Kraus, NVIDIA Corp (nvidia.com - jkraus)
55 # Copyright (c) 2008 - 2014,2017 NVIDIA Corporation. All rights reserved.
57 # This code is licensed under the MIT License. See the FindNVML.cmake script
58 # for the text of the license.
62 # License for the specific language governing rights and limitations under
63 # Permission is hereby granted, free of charge, to any person obtaining a
64 # copy of this software and associated documentation files (the "Software"),
65 # to deal in the Software without restriction, including without limitation
66 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
67 # and/or sell copies of the Software, and to permit persons to whom the
68 # Software is furnished to do so, subject to the following conditions:
70 # The above copyright notice and this permission notice shall be included
71 # in all copies or substantial portions of the Software.
73 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
74 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
75 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
76 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
77 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
78 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
79 # DEALINGS IN THE SOFTWARE.
81 ###############################################################################
83 if( CMAKE_SYSTEM_NAME STREQUAL "Windows" )
86 set(NVML_NAMES nvidia-ml)
90 if( CMAKE_SYSTEM_NAME STREQUAL "Windows" )
91 if(${CUDA_VERSION_STRING} VERSION_LESS "8.0")
92 set( NVML_LIB_PATHS "C:/Program Files/NVIDIA Corporation/GDK/nvml/lib" )
93 if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
94 list(APPEND NVML_LIB_PATHS "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/nvml/lib")
97 set( NVML_INC_PATHS "C:/Program Files/NVIDIA Corporation/GDK/nvml/include" )
98 if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
99 list(APPEND NVML_INC_PATHS "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/nvml/include")
102 set( NVML_LIB_PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" )
103 set( NVML_INC_PATHS ${CUDA_INCLUDE_DIRS} )
107 set( NVML_LIB_PATHS /usr/lib64 )
108 if(${CUDA_VERSION_STRING} VERSION_LESS "8.0")
109 # The Linux installer for the GPU Deployment Kit adds a "usr"
110 # suffix to a custom path if one is used, so a user could
111 # reasonably set GPU_DEPLOYMENT_KIT_ROOT_DIR to the value they
112 # passed to the installer, or the root where they later found the
113 # kit to be installed. Below, we cater for both possibilities.
114 if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
115 list(APPEND NVML_LIB_PATHS
116 "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/src/gdk/nvml/lib"
117 "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/usr/src/gdk/nvml/lib"
121 list(APPEND NVML_LIB_PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs")
124 if(${CUDA_VERSION_STRING} VERSION_LESS "8.0")
125 set( NVML_INC_PATHS /usr/include/nvidia/gdk/ /usr/include )
126 if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
127 list(APPEND NVML_INC_PATHS
128 "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/include/nvidia/gdk"
129 "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/usr/include/nvidia/gdk"
133 set( NVML_INC_PATHS ${CUDA_INCLUDE_DIRS} )
138 find_library(NVML_LIBRARY NAMES ${NVML_NAMES} PATHS ${NVML_LIB_PATHS} )
140 find_path(NVML_INCLUDE_DIR nvml.h PATHS ${NVML_INC_PATHS})
142 # handle the QUIETLY and REQUIRED arguments and set NVML_FOUND to TRUE if
143 # all listed variables are TRUE
144 include(FindPackageHandleStandardArgs)
145 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NVML DEFAULT_MSG NVML_LIBRARY NVML_INCLUDE_DIR)
147 mark_as_advanced(NVML_LIBRARY NVML_INCLUDE_DIR)