Cmake Find Cuda

This is what i added in my bashrc file, apologies in advance i dont actually understand bashrc and path variables. I would like cmake to find cuda without explicitly setting the path in the cmake file, or is this simply how cmake works on ubuntu? Thanks in advance for any replys. Could not find a package configuration file provided by 'FindCUDAToolkit' with any of the following names: FindCUDAToolkitConfig.cmake findcudatoolkit-config.cmake Finding this unbelievable, I searched for this.cmake file on the host and found it there. The findlibrary, findpath, and findfile commands no longer search in installation prefixes derived from the PATH environment variable on non-Windows platforms. This behavior was added in CMake 3.3 to support Windows hosts but has proven problematic on UNIX hosts. Its initial value is taken from the calling process environment. Preferred executable for compiling CUDA language files. Will only be used by CMake on the first configuration to determine CUDA compiler, after which the value for CUDA is stored in the cache as CMAKECUDACOMPILER. For any configuration run (including the first), the environment variable will be ignored if the CMAKECUDACOMPILER variable is defined. The CUDA Toolkit search behavior uses the following order: 1. If the ``CUDA`` language has been enabled we will use the directory containing the compiler as the first search location for ``nvcc``.

This script locates the NVIDIA CUDA toolkit and the associated libraries, butdoes not require the CUDA language be enabled for a given project. Thismodule does not search for the NVIDIA CUDA Samples.

New in version 3.19: QNX support.

Search Behavior¶

The CUDA Toolkit search behavior uses the following order:

  1. If the CUDA language has been enabled we will use the directorycontaining the compiler as the first search location for nvcc.

  2. If the CUDAToolkit_ROOT cmake configuration variable (e.g.,-DCUDAToolkit_ROOT=/some/path) or environment variable is defined, itwill be searched. If both an environment variable and aconfiguration variable are specified, the configuration variable takesprecedence.

    The directory specified here must be such that the executable nvcc orthe appropriate version.txt file can be found underneath the specifieddirectory.

  3. If the CUDA_PATH environment variable is defined, it will be searchedfor nvcc.

  4. The user's path is searched for nvcc using find_program(). Ifthis is found, no subsequent search attempts are performed. Users areresponsible for ensuring that the first nvcc to show up in the path isthe desired path in the event that multiple CUDA Toolkits are installed.

  5. On Unix systems, if the symbolic link /usr/local/cuda exists, this isused. No subsequent search attempts are performed. No default symbolic linklocation exists for the Windows platform.

  6. The platform specific default install locations are searched. If exactly onecandidate is found, this is used. The default CUDA Toolkit install locationssearched are:

    Platform

    Search Pattern

    macOS

    /Developer/NVIDIA/CUDA-X.Y

    Other Unix

    /usr/local/cuda-X.Y

    Windows

    C:ProgramFilesNVIDIAGPUComputingToolkitCUDAvX.Y

    Where X.Y would be a specific version of the CUDA Toolkit, such as/usr/local/cuda-9.0 orC:ProgramFilesNVIDIAGPUComputingToolkitCUDAv9.0

    Note

    When multiple CUDA Toolkits are installed in the default location of asystem (e.g., both /usr/local/cuda-9.0 and /usr/local/cuda-10.0exist but the /usr/local/cuda symbolic link does not exist), thispackage is marked as not found.

    There are too many factors involved in making an automatic decision inthe presence of multiple CUDA Toolkits being installed. In thissituation, users are encouraged to either (1) set CUDAToolkit_ROOT or(2) ensure that the correct nvcc executable shows up in $PATH forfind_program() to find.

Options¶

VERSION

Cmake Find Cuda Number

If specified, describes the version of the CUDA Toolkit to search for.

REQUIRED

If specified, configuration will error if a suitable CUDA Toolkit is notfound.

QUIET

If specified, the search for a suitable CUDA Toolkit will not produce anymessages.

EXACT

If specified, the CUDA Toolkit is considered found only if the exactVERSION specified is recovered.

Imported targets¶

An imported target named CUDA::toolkit is provided.

Cmake Find Cuda Example

This module defines IMPORTED targets for eachof the following libraries that are part of the CUDAToolkit:

Cmake find cuda version

CUDA Runtime Library¶

The CUDA Runtime library (cudart) are what most applications will typicallyneed to link against to make any calls such as cudaMalloc, and cudaFree.

Targets Created:

  • CUDA::cudart

  • CUDA::cudart_static

CUDA Driver Library¶

The CUDA Driver library (cuda) are used by applications that use callssuch as cuMemAlloc, and cuMemFree. This is generally used by advanced

Targets Created:

  • CUDA::cuda_driver

  • CUDA::cuda_driver

cuBLAS¶

The cuBLAS library.

Targets Created:

  • CUDA::cublas

  • CUDA::cublas_static

  • CUDA::cublasLt starting in CUDA 10.1

  • CUDA::cublasLt_static starting in CUDA 10.1

cuFFT¶

The cuFFT library.

Targets Created:

  • CUDA::cufft

  • CUDA::cufftw

  • CUDA::cufft_static

  • CUDA::cufftw_static

cuRAND¶

The cuRAND library.

Targets Created:

  • CUDA::curand

  • CUDA::curand_static

cuSOLVER¶

The cuSOLVER library.

Targets Created:

  • CUDA::cusolver

  • CUDA::cusolver_static

cuSPARSE¶

The cuSPARSE library.

Targets Created:

  • CUDA::cusparse

  • CUDA::cusparse_static

cupti¶

The NVIDIA CUDA Profiling Tools Interface.

Targets Created:

  • CUDA::cupti

  • CUDA::cupti_static

NPP¶

The NPP libraries.

Targets Created:

  • nppc:

    • CUDA::nppc

    • CUDA::nppc_static

  • nppial: Arithmetic and logical operation functions in nppi_arithmetic_and_logical_operations.h

    • CUDA::nppial

    • CUDA::nppial_static

  • nppicc: Color conversion and sampling functions in nppi_color_conversion.h

    • CUDA::nppicc

    • CUDA::nppicc_static

  • nppicom: JPEG compression and decompression functions in nppi_compression_functions.hRemoved starting in CUDA 11.0, use nvJPEG instead.

    • CUDA::nppicom

    • CUDA::nppicom_static

  • nppidei: Data exchange and initialization functions in nppi_data_exchange_and_initialization.h

    • CUDA::nppidei

    • CUDA::nppidei_static

  • nppif: Filtering and computer vision functions in nppi_filter_functions.h

    • CUDA::nppif

    • CUDA::nppif_static

  • nppig: Geometry transformation functions found in nppi_geometry_transforms.h

    • CUDA::nppig

    • CUDA::nppig_static

  • nppim: Morphological operation functions found in nppi_morphological_operations.h

  • nppist: Statistics and linear transform in nppi_statistics_functions.h and nppi_linear_transforms.h

    • CUDA::nppist

    • CUDA::nppist_static

  • nppisu: Memory support functions in nppi_support_functions.h

    • CUDA::nppisu

    • CUDA::nppisu_static

  • nppitc: Threshold and compare operation functions in nppi_threshold_and_compare_operations.h

    • CUDA::nppitc

    • CUDA::nppitc_static

  • npps:

    • CUDA::npps

    • CUDA::npps_static

nvBLAS¶

The nvBLAS libraries.This is a shared library only.

Targets Created:

  • CUDA::nvblas

nvGRAPH¶

The nvGRAPH library.Removed starting in CUDA 11.0

Targets Created:

  • CUDA::nvgraph

  • CUDA::nvgraph_static

nvJPEG¶

The nvJPEG library.Introduced in CUDA 10.

Targets Created:

  • CUDA::nvjpeg

  • CUDA::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

OpenCL¶

The NVIDIA OpenCL Library.This is a shared library only.

Targets Created:

  • CUDA::OpenCL

cuLIBOS¶

The cuLIBOS library is a backend thread abstraction layer library which isstatic only. The CUDA::cublas_static, CUDA::cusparse_static,CUDA::cufft_static, CUDA::curand_static, and (when implemented) NPPlibraries 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 bynvcc--version or version.txt).

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 CUDAexecutable nvcc.

CUDAToolkit_INCLUDE_DIRS

The path to the CUDA Toolkit include folder containing the header filesrequired to compile a project linking against CUDA.

CUDAToolkit_LIBRARY_DIR

The path to the CUDA Toolkit library directory that contains the CUDARuntime library cudart.

CUDAToolkit_LIBRARY_ROOT

The path to the CUDA Toolkit directory containing the nvvm directory andversion.txt.

CUDAToolkit_TARGET_DIR

The path to the CUDA Toolkit directory including the target architecturewhen cross-compiling. When not cross-compiling this will be equivalent tothe parent directory of CUDAToolkit_BIN_DIR.

CUDAToolkit_NVCC_EXECUTABLE

The path to the NVIDIA CUDA compiler nvcc. Note that this path maynot be the same as_COMPILER'>CMAKE_CUDA_COMPILER. nvcc must befound to determine the CUDA Toolkit version as well as determining otherfeatures of the Toolkit. This variable is set for the convenience ofmodules that depend on this one.

Ask questionsCmake cannot find CUDA when I build my opencv from source

System information (version)

<!-- Example

  • OpenCV => 4.4

  • Operating System / Platform => ubuntu 18.04

  • Compiler =>-->

  • OpenCV => :4.4:

  • Operating System / Platform => :ubuntu:

  • Compiler => :ubuntu default:

Detailed description

<I want to build opencv 4.4 with cuda on ubuntu 18.04, while, when I cmake, it shows that:'CMake Warning at cmake/OpenCVFindLibsPerf.cmake:45 (message):OpenCV is not able to find/configure CUDA SDK (required by WITH_CUDA).

CUDA support will be disabled in OpenCV build.

To eliminate this warning remove WITH_CUDA=ON CMake configuration option.

Call Stack (most recent call first):CMakeLists.txt:688 (include)

CMake Error at modules/dnn/CMakeLists.txt:35 (message):DNN: CUDA backend requires CUDA Toolkit. Please resolve dependency ordisable OPENCV_DNN_CUDA=OFF'

But when I try the command 'nvcc -V', it shows: '(base) [email protected]:~$ nvcc -Vnvcc: NVIDIA (R) Cuda compiler driverCopyright (c) 2005-2019 NVIDIA CorporationBuilt on Wed_Oct_23_19:24:38_PDT_2019Cuda compilation tools, release 10.2, V10.2.89'

I think this means I have already install CUDA correctly

Cmake Find Cuda Company

I successfully build opencv 4.4 with CUDA on win10, but it just doesn't work on ubuntu 18.04, I already tried a week,Could you give me a help?Thanks A LOT !!!

Steps to reproduce

<!-- to add code example fence it with triple backticks and optional file extension.cpp // C++ code exampleor attach as .txt or .zip file-->

Issue submission checklist
  • [ ] I report the issue, it's not a question<!--OpenCV team works with answers.opencv.org, Stack Overflow and other communitiesto discuss problems. Tickets with question without real issue statement will beclosed.-->
  • [ ] I checked the problem with documentation, FAQ, open issues,answers.opencv.org, Stack Overflow, etc and have not found solution<!--Places to check:
    • OpenCV documentation: https://docs.opencv.org
    • FAQ page: https://github.com/opencv/opencv/wiki/FAQ
    • OpenCV forum: https://answers.opencv.org
    • OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
    • Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv-->
  • [ ] I updated to latest OpenCV version and the issue is still there<!--master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.OpenCV team supports only latest release for each branch.The ticket is closed, if the problem is not reproduced with modern version.-->
  • [ ] There is reproducer code and related data files: videos, images, onnx, etc<!--The best reproducer -- test case for OpenCV that we can add to the library.Recommendations for media files and binary files:
    • Try to reproduce the issue with images and videos in opencv_extra repositoryto reduce attachment size
    • Use PNG for images, if you report some CV related bug, but not image readerissue
    • Attach the image as archive to the ticket, if you report some reader issue.Image hosting services compress images and it breaks the repro code.
    • Provide ONNX file for some public model or ONNX file with with random weights,if you report ONNX parsing or handling issue. Architecture details diagramfrom netron tool can be very useful too. See https://lutzroeder.github.io/netron/-->
opencv/opencv