Search code examples
opencvrosnanonvidia-jetson

ROS and OpenCV with CUDA on Jetson Nano : Incompatible versions


I want to use ROS with CUDA-enabled OpenCV on my Jetson Nano. At this point I don´t care about the versions.

The problem: Jetson Nano only supports CUDA 10 and Ubuntu 18.04. The ROS version for Ubuntu 18.04 is Melodic, which needs OpenCV 3.2, but OpenCV 3.2 only supports CUDA 8.

I have found a guide here on SO (CMake Error: Variables are set to NOTFOUND) to build it with CUDA 9, but it fails when trying it with CUDA 10 due to "error: identifier "__shfl_down" is undefined", and some other "__shfl_XXX" errors.

Anyone here succeeded in getting this to work? Or any idea on how to fix the "__shfl_down" error?

Can OpenCV 3.2 work with CUDA 10.2?


Solution

  • I found a solution, even though I have not done extensive testing on it yet:

    1. Build OpenCV 4.2 (any version that supports CUDA 10.2 should work) from source, enabling CUDA. A good guide is available at https://www.pyimagesearch.com/2020/03/25/how-to-configure-your-nvidia-jetson-nano-for-computer-vision-and-deep-learning/ (skip parts with tensorflow etc)

    2. Install ROS Melodic. No need to build from source.

    3. After creating a workspace, clone the cv_bridge and image_transport modules into it. IMPORTANT: Switch to branch "Noetic"!

    4. In the CMakeLists.txt in cv_bridge, change the find_package(Boost REQUIRED python37) to find_package(BOOST REQUIRED python)

    5. In cv_bridge/src/module.hpp in the function do_numpy_import, change the return type from void* to void, and remove the return nullptr;

    6. Build the workspace with catkin. It should build normally.

    I have tested a basic image publish, and viewing it in rqt_image_view. Works like a charm!

    I know this is a bit of a hacky solution, so if anyone knows something better, please let me know!