CUDA in ROS node example code

Hi, I am writing some ROS node on my jetson Xavier and my node needs to use CUDA. Is there any example code about how to use CUDA in ROS node, including CMakeLists, and soruce code?

Hi @AutoCar, you can add a find_package(cuda REQUIRED) statement to your CMakeLists, and then use cuda_add_executable() instead of add_executable() to build the CUDA code (see FindCUDA docs for more info).

I enabled CUDA in this ROS project:
I don’t actually need to compile it there, as my CUDA code is in another library, but it does find the CUDA toolkit libs + headers that way.

@dusty_nv thanks. I have been using your jetson-inference, jetson-utilities code, very helpful. Very look into ros_deep_learning

Besides ROS integration, I am also looking for CUDA sample code to do image resizing, data clustering (dbscan) etc.

There are some simple CUDA image resizing functions in jetson-utils in You may be able to reference those and the other CUDA functions under the jetson-utils/cuda dir as basic examples if you need to write your own.

Otherwise you might want to check the CUDA NPP library, which has lots of image processing functions. cuML implements DBSCAN, although there isn’t official support in that library for Jetson (although I’ve heard it can work on Xavier).

1 Like