FindCUDAToolkit¶
This script locates the NVIDIA CUDA toolkit and the associated libraries, but
does not require the CUDA language be enabled for a given project. This
module does not search for the NVIDIA CUDA Samples.
Search Behavior¶
Finding the CUDA Toolkit requires finding the nvcc executable, which is
searched for in the following order:
If the
CUDAlanguage has been enabled we will use the directory containing the compiler as the first search location fornvcc.If the
CUDAToolkit_ROOTcmake configuration variable (e.g.,-DCUDAToolkit_ROOT=/some/path) or environment variable is defined, it will be searched. If both an environment variable and a configuration variable are specified, the configuration variable takes precedence.The directory specified here must be such that the executable
nvcccan be found underneath the directory specified byCUDAToolkit_ROOT. IfCUDAToolkit_ROOTis specified, but nonvccis found underneath, this package is marked as not found. No subsequent search attempts are performed.If the CUDA_PATH environment variable is defined, it will be searched.
The user’s path is searched for
nvccusingfind_program(). If this is found, no subsequent search attempts are performed. Users are responsible for ensuring that the firstnvccto show up in the path is the desired path in the event that multiple CUDA Toolkits are installed.On Unix systems, if the symbolic link
/usr/local/cudaexists, this is used. No subsequent search attempts are performed. No default symbolic link location exists for the Windows platform.The platform specific default install locations are searched. If exactly one candidate is found, this is used. The default CUDA Toolkit install locations searched are:
Platform Search Pattern macOS /Developer/NVIDIA/CUDA-X.YOther Unix /usr/local/cuda-X.YWindows C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.YWhere
X.Ywould be a specific version of the CUDA Toolkit, such as/usr/local/cuda-9.0orC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0Note
When multiple CUDA Toolkits are installed in the default location of a system (e.g., both
/usr/local/cuda-9.0and/usr/local/cuda-10.0exist but the/usr/local/cudasymbolic link does not exist), this package is marked as not found.There are too many factors involved in making an automatic decision in the presence of multiple CUDA Toolkits being installed. In this situation, users are encouraged to either (1) set
CUDAToolkit_ROOTor (2) ensure that the correctnvccexecutable shows up in$PATHforfind_program()to find.
Options¶
VERSION- If specified, describes the version of the CUDA Toolkit to search for.
REQUIRED- If specified, configuration will error if a suitable CUDA Toolkit is not found.
QUIET- If specified, the search for a suitable CUDA Toolkit will not produce any messages.
EXACT- If specified, the CUDA Toolkit is considered found only if the exact
VERSIONspecified is recovered.
Imported targets¶
An imported target named CUDA::toolkit is provided.
This module defines IMPORTED targets for each
of the following libraries that are part of the CUDAToolkit:
- CUDA Runtime Library
- CUDA Driver Library
- cuBLAS
- cuFFT
- cuRAND
- cuSOLVER
- cuSPARSE
- cuPTI
- NPP
- nvBLAS
- nvGRAPH
- nvJPEG
- nvidia-ML
- nvRTC
- nvToolsExt
- OpenCL
- cuLIBOS
CUDA Runtime Library¶
The CUDA Runtime library (cudart) are what most applications will typically need to link against to make any calls such as cudaMalloc, and cudaFree.
Targets Created:
CUDA::cudartCUDA::cudart_static
CUDA Driver Library¶
The CUDA Driver library (cuda) are used by applications that use calls such as cuMemAlloc, and cuMemFree. This is generally used by advanced
Targets Created:
CUDA::cuda_driverCUDA::cuda_driver
cuFFT¶
The cuFFT library.
Targets Created:
CUDA::cufftCUDA::cufftwCUDA::cufft_staticCUDA::cufftw_static
NPP¶
The NPP libraries.
Targets Created:
- nppc:
CUDA::nppcCUDA::nppc_static
- nppial: Arithmetic and logical operation functions in nppi_arithmetic_and_logical_operations.h
CUDA::nppialCUDA::nppial_static
- nppicc: Color conversion and sampling functions in nppi_color_conversion.h
CUDA::nppiccCUDA::nppicc_static
- nppicom: JPEG compression and decompression functions in nppi_compression_functions.h
CUDA::nppicomCUDA::nppicom_static
- nppidei: Data exchange and initialization functions in nppi_data_exchange_and_initialization.h
CUDA::nppideiCUDA::nppidei_static
- nppif: Filtering and computer vision functions in nppi_filter_functions.h
CUDA::nppifCUDA::nppif_static
- nppig: Geometry transformation functions found in nppi_geometry_transforms.h
CUDA::nppigCUDA::nppig_static
- nppim: Morphological operation functions found in nppi_morphological_operations.h
CUDA::nppimCUDA::nppim_static
- nppist: Statistics and linear transform in nppi_statistics_functions.h and nppi_linear_transforms.h
CUDA::nppistCUDA::nppist_static
- nppisu: Memory support functions in nppi_support_functions.h
CUDA::nppisuCUDA::nppisu_static
- nppitc: Threshold and compare operation functions in nppi_threshold_and_compare_operations.h
CUDA::nppitcCUDA::nppitc_static
- npps:
CUDA::nppsCUDA::npps_static
nvJPEG¶
The nvJPEG library. Introduced in CUDA 10.
Targets Created:
CUDA::nvjpegCUDA::nvjpeg_static
nvRTC¶
The nvRTC (Runtime Compilation) library. This is a shared library only.
Targets Created:
CUDA::nvrtc
nvidia-ML¶
The NVIDIA Management Library. This is a shared library only.
Targets Created:
CUDA::nvml
nvToolsExt¶
The NVIDIA Tools Extension. This is a shared library only.
Targets Created:
CUDA::nvToolsExt
cuLIBOS¶
The cuLIBOS library is a backend thread abstraction layer library which is
static only. The CUDA::cublas_static, CUDA::cusparse_static,
CUDA::cufft_static, CUDA::curand_static, and (when implemented) NPP
libraries all automatically have this dependency linked.
Target Created:
CUDA::culibos
Note: direct usage of this target by consumers should not be necessary.
Result variables¶
CUDAToolkit_FOUND- A boolean specifying whether or not the CUDA Toolkit was found.
CUDAToolkit_VERSION- The exact version of the CUDA Toolkit found (as reported by
nvcc --version). CUDAToolkit_VERSION_MAJOR- The major version of the CUDA Toolkit.
CUDAToolkit_VERSION_MAJOR- The minor version of the CUDA Toolkit.
CUDAToolkit_VERSION_PATCH- The patch version of the CUDA Toolkit.
CUDAToolkit_BIN_DIR- The path to the CUDA Toolkit library directory that contains the CUDA
executable
nvcc. CUDAToolkit_INCLUDE_DIRS- The path to the CUDA Toolkit
includefolder containing the header files required to compile a project linking against CUDA. CUDAToolkit_LIBRARY_DIR- The path to the CUDA Toolkit library directory that contains the CUDA
Runtime library
cudart. CUDAToolkit_TARGET_DIR- The path to the CUDA Toolkit directory including the target architecture
when cross-compiling. When not cross-compiling this will be equivalant to
CUDAToolkit_ROOT_DIR. CUDAToolkit_NVCC_EXECUTABLE- The path to the NVIDIA CUDA compiler
nvcc. Note that this path may not be the same asCMAKE_CUDA_COMPILER.nvccmust be found to determine the CUDA Toolkit version as well as determining other features of the Toolkit. This variable is set for the convenience of modules that depend on this one.