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

How to use CUDA with rosbuild

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

Oier gravatar image

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

ngrennan gravatar image

Hi,

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.

if(SUPPORT_CUDA)
    find_package(CUDA QUIET REQUIRED)
    include_directories(${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc)
    add_definitions(-DCUDA_BUILD -DBT_USE_DOUBLE_PRECISION)
    list(APPEND  SOURCES bar.cu)
else()
    MESSAGE(STATUS "cuda not found")
endif()

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

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
2

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

mortonjt gravatar image

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

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

Comments

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 -0500 )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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 2,074 times

Last updated: May 31 '13