CMake Error : OpenCV CUDA CMakeLists.txt

Hello, I have been trying to install and uninstall CUDA a few time to address the problem that it seems to be inconsistent to what information I can find online. For example inside my /usr/local/cuda/bin/ I lack an uninstall script which I think should be there given my 12.2 installation. Worse yet I cannot seem correct my CMake and have exhausted most methods found on forums. I will attach all relevant Information below.

Platform:

HP Omen 15
Linux Ubuntu 22.04
GeForce RTX 2070
NVIDIA-SMI 535.54.03 - Driver Version: 535.54.03
CUDA Version: 12.2

CMakeLists.txt:

cmake_minimum_required(VERSION 3.27)
project(synchronisation_buffer)

# Set C++ Standards
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# FIND LIBRARIES
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

find_package(CUDA REQUIRED)
message(STATUS "    libraries: ${CUDA_LIBS}")

# INCLUDE HEADERS
include_directories(${OpenCV_INCLUDE_DIRS})
# Target the only executable
add_executable(${PROJECT_NAME}
    src/main.cpp 
    src/main.hpp 
    src/buffer.hpp 
)

Inside .bashrc

# CUDA Bash links
# export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}$ 
# export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/lib
export CPLUS_INCLUDE_PATH=/usr/local/cuda/include

Inside local

XXXX@XXXX-OMEN-Laptop-15-ek0xxx:/usr/local$ ls
bin cuda cuda-12 cuda-12.2 doc etc games include lib man sbin share src

Inside cuda bin

XXXX@XXXX-OMEN-Laptop-15-ek0xxx:/usr/local/cuda/bin$ ls
bin2c cudafe++ cuobjdump nsight_ee_plugins_manage.sh nsys-ui nvdisasm nvvp
computeprof cuda-gdb fatbinary nsight-sys nvcc nvlink ptxas
compute-sanitizer cuda-gdbserver ncu nsys __nvcc_device_query nvprof
crt cu++filt ncu-ui nsys-exporter nvcc.profile nvprune

Error

-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:86 (find_package):
  By not providing "FindCUDA.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "CUDA", but
  CMake did not find one.

  Could not find a package configuration file provided by "CUDA" (requested
  version 12.2) with any of the following names:

    CUDAConfig.cmake
    cuda-config.cmake

  Add the installation prefix of "CUDA" to CMAKE_PREFIX_PATH or set
  "CUDA_DIR" to a directory containing one of the above files.  If "CUDA"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:108 (find_host_package)
  CMakeLists.txt:11 (find_package)


-- Configuring incomplete, errors occurred!
make: *** No targets specified and no makefile found.  Stop.

Due to 3.27 deprecation it is no longer necessary to use this module or call find_package(CUDA) for compiling CUDA code. To resolve the issue in my OP, I simply reduced the cmake_minimum_required() to anything before the 3.27 release i.e. 3.26 and below.

Reference relevant info. FindCUDA CMake Module

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.