I compiled OpenCV with cuda support and it works fine with a program that does not use ROS.
I created a node in ROS Kinetic that uses OpenCV CUDA implemented algorithms and used catkin_make to compile it, pointing to the OpenCV installation in /usr/local. The output of catkin_make is shown here:
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/degraw/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/degraw/catkin_ws/build/test_results
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.6
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 2 packages in topological order:
-- ~~ - depth_calculator
-- ~~ - zed_wrapper
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'depth_calculator'
-- ==> add_subdirectory(depth_calculator)
-- Found CUDA: /usr/local/cuda (found suitable exact version "8.0")
-- Found OpenCV: /usr/local (found version "3.2.0")
During runtime i get the error:
OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/core/include/opencv2/core/private.cuda.hpp, line 97
terminate called after throwing an instance of 'cv::Exception'
what(): /tmp/binarydeb/ros-kinetic-opencv3-3.2.0/modules/core/include/opencv2/core/private.cuda.hpp:97: error: (-216) The library is compiled without CUDA support in function throw_no_cuda
[1] 21085 abort (core dumped) rosrun depth_calculator double_image_acq
even though there are no files in /tmp (i deleted everything, deleted build and devel folders in catkin_ws and rerun catkin_make, which had the output shown above).
Could this be a caching issue from previous runs? Are there any runtime Environment Variables that point to the OpenCV installed in /opt/ros/kinetic instead of the one in /usr/local, with which the node was compiled and linked against?