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

Revision history [back]

I managed to build a CUDA-enabled OpenCV without having to modify the CMakeLists. Here are the steps for Kinetic:

First, install CUDA 10.2 or earlier (OpenCV 3.3.1 is not compatible with CUDA 11). Then:

cd catkin_ws/src
git clone -b release/kinetic/opencv3 https://github.com/ros-gbp/opencv3-release.git opencv3
git clone -b kinetic https://github.com/ros-perception/vision_opencv.git
cd ..

catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DCUDA_HOST_COMPILER=/usr/bin/g++ 
# you can add more arguments for OpenCV, like -DWITH_CUDA=ON, but OpenCV should autodetect your CUDA installation, so that won't be necessary

# since opencv3 isn't a catkin package, it won't be built before dependent packages, so we have to build it manually first
catkin clean
catkin build opencv3
source devel/setup.bash

# build the rest of the packages
catkin build --force-cmake

I managed to build a CUDA-enabled OpenCV without having to modify the CMakeLists. Here are the steps for Kinetic:

First, install CUDA 10.2 or earlier (OpenCV 3.3.1 is not compatible with CUDA 11). Then:

cd catkin_ws/src
git clone -b release/kinetic/opencv3 https://github.com/ros-gbp/opencv3-release.git opencv3
git clone -b kinetic https://github.com/ros-perception/vision_opencv.git
cd ..

catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DCUDA_HOST_COMPILER=/usr/bin/g++ 
# you can add more arguments for OpenCV, like -DWITH_CUDA=ON, but OpenCV should autodetect your 
# CUDA installation, so that won't be necessary

# since opencv3 isn't a catkin package, it won't be built before dependent packages, so we have 
# to build it manually first
catkin clean
catkin build opencv3
source devel/setup.bash

# build the rest of the packages
catkin build --force-cmake