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

How to use CUDA with rosbuild

asked 2013-05-31 10:03:30 -0600

Oier gravatar image

updated 2014-01-28 17:16:43 -0600

ngrennan gravatar image


I am trying to integrate CUDA in my ros package (which is not catkinized) and have some problems. I believe, that I have to use cuda_add_library and cuda_add_executable in my CMakeLists.txt and after that target_link_libraries. If I do that, for some reason I get linking errors because the libraries have not been linked, it says it doesn't know about ros::spin for instance. If instead, I use rosbuild_add_library and rosbuild_add_executable, there is some CUDA related linking issue. I append the important bits of the CMakeLists file. If I compile without CUDA support, everything works. I would be grateful for any help.

    find_package(CUDA QUIET REQUIRED)
    MESSAGE(STATUS "cuda not found")

    cuda_add_library(${PROJECT_NAME} SHARED ${SOURCES})
    cuda_add_executable(main ${PROJECT_SOURCE_DIR}/src/main.cpp)  
    rosbuild_add_library(${PROJECT_NAME} SHARED ${SOURCES})
    rosbuild_add_executable(main ${PROJECT_SOURCE_DIR}/src/main.cpp)

target_link_libraries(${PROJECT_NAME} ${EXTERNAL_LIBS})
target_link_libraries(main ${PROJECT_NAME})
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-05-31 15:41:44 -0600

mortonjt gravatar image

updated 2013-05-31 15:42:55 -0600

You can start by looking at parallel_quickstep package that has CUDA enabled

You can also check out this wiki page.

Both of these packages are incredibly out-of-date, but should provide good guidelines on how to compile your project

Make sure to note the FindCUDA.cmake file in both of these packages as it contains all of the CUDA variables needed to get your project up and running

Also, you may want to look into cuda_compile instead of cuda_add_library. I know this resolved some linking issues for me

edit flag offensive delete link more


I am new in using cuda in ROS package, the first link was not informative for me, the second link is not working! I have test diff solution but non of them couldn't solve my problem. May you please help me to find a step by step tutorial?

reza64 gravatar image reza64  ( 2014-04-08 04:59:00 -0600 )edit

'wiki' page is dead. parallel_quickstep link is not dead, but it's link to the github repo is dead

dwyer2bp gravatar image dwyer2bp  ( 2015-07-02 15:10:35 -0600 )edit

Question Tools

1 follower


Asked: 2013-05-31 10:03:30 -0600

Seen: 2,038 times

Last updated: May 31 '13