ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

CMake detects intended OpenCV+CUDA, but runtime does not use intended OpenCV version

asked 2022-05-02 05:00:28 -0500

MrOCW gravatar image

updated 2022-05-02 05:09:02 -0500

CMakeLists.txt contains

find_package( OpenCV 4.5.5 REQUIRED
  PATHS /usr/local
  NO_DEFAULT_PATH)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  geometry_msgs
  image_transport
  message_filters
  nav_msgs
  roscpp
  std_msgs
  tf
)

if(USE_CUDA)
    find_package(CUDA)
    include_directories("${CUDA_INCLUDE_DIRS}")
    add_definitions(-DUSE_CUDA)
endif(USE_CUDA)

include_directories(
# include
  ${OpenCV_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

add_executable( xxxxx src/xxxxx.cpp )
target_link_libraries( xxxxx ${OpenCV_LIBS} ${catkin_LIBRARIES .........}

Output of catkin_make -DUSE_CUDA=ON

-- Found CUDA: /usr/local/cuda (found suitable exact version "11.6") 
-- Found OpenCV: /usr/local (found suitable version "4.5.5", minimum required is "4.5.5") 
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Found CUDA: /usr/local/cuda (found version "11.6")

and everything builds and compiles nicely

However, when i run my node, it shows OpenCV(4.2.0) without CUDA:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.2.0) ../modules/core/include/opencv2/core/private.cuda.hpp:109: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda'

I've built OpenCV 4.5.5 with CUDA. Non ROS applications are able to use it correctly

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-02 05:31:44 -0500

MrOCW gravatar image

Figured out the solution. Issue seems to be cv_bridge using OpenCV 4.2. I compiled vision_opencv with my intended opencv version and it works now.

edit flag offensive delete link more

Comments

Hi, I am facing a similar issue. I have ROS noetic installed on my PC. During ROS installation, OpenCV 4.2 was installed without CUDA support. I am using a custom package which needs OpenCV with CUDA support. So I installed OpenCV 4.7.0 form source. In my CMakeLists I have given my path to the 4.7.0 build folder. During the the catkin make 4.7.0 version is found and catkin_make was successful with few warnings. When i try to run my roslaunch, I gets terminated as you mentioned showing No CUDA support. Can you please guide me how did you resolved in your case.

Thank you.

Sriniketh gravatar image Sriniketh  ( 2023-02-28 01:54:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-05-02 05:00:28 -0500

Seen: 692 times

Last updated: May 02 '22