Robotics StackExchange | Archived questions

Compile cuda into ros code in TEGRA

I've an 'old' Tegra jetson TK1 with ubuntu 16.04 (arm architecture) ros kinetic and CUDA 6.5.

I've a ros node with cuda code that worked fine on two different computers with different Nvidia boards. But now I'm trying to use it on Tegra and the ros cpp librarys are not working. Here is the terminal output of the errors:

here is part of the .cu code

#include <numeric>
#include <stdlib.h>
#include <stdio.h>
#include <cuda_runtime.h>
#include "Novo_Teste.hpp"
#include <iostream> //Este tambem repete no .cpp
#include <math.h>


//Includes do .cpp
#include <ros/ros.h>
#include <ros/package.h>
#include <image_transport/image_transport.h>
#include <compressed_image_transport/compressed_subscriber.h>
#include <cv_bridge/cv_bridge.h>
#include <opencv2/highgui/highgui.hpp>

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/opencv.hpp>
#include <string>


#include <vector>

#include <sstream>

#include <fstream>

#include "fbn_lbp/imagedescriptor.h"
#include "fbn_lbp/lbp_pattern.h"
#include "train_and_test.h"
/*************************************************************/

//Declaration from .cu

#define CHECK(call)                                                     \
{                                                                       \
const cudaError_t error = call;                                         \
if (error != cudaSuccess)                                               \
{                                                                       \
printf("Error: %s:%d, ", __FILE__, __LINE__);                           \
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));      \
exit(-10*error);                                                        \
}                                                                       \
}

I just posted the headers because that's where the problems start. in the includes of ROS.

Could someone help me to solve this?

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(v_detector)

find_package(catkin REQUIRED COMPONENTS
    roscpp
    rospy
    std_msgs
    image_transport
    compressed_image_transport
    image_geometry
    cv_bridge
    rosbag
    geometry_msgs
    tf
)

find_package(OpenCV REQUIRED)
include_directories(  ${OpenCV_INCLUDE_DIRS} )

find_package(Boost REQUIRED COMPONENTS system thread filesystem  )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )

find_package( CUDA REQUIRED )
include_directories(
  ${catkin_INCLUDE_DIRS}
  ${CUDA_INCLUDE_DIRS}
)


catkin_package()


SET(CUDA_NVCC_FLAGS "-arch=sm_32" CACHE STRING "nvcc flags" FORCE)
SET (CUDA_VERBOSE_BUILD ON CACHE BOOL "nvcc verbose" FORCE)
SET(LIB_TYPE STATIC)
CUDA_ADD_LIBRARY(TestLib ${LIB_TYPE} src/Novo_Teste.cu)      # THE ERROR OCCURS IN THIS LINE !

set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -DMY_DEF=1")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMY_DEF=1" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMY_DEF=1" )

#include_directories(
 # ${catkin_INCLUDE_DIRS}
#  ${CUDA_INCLUDE_DIRS}

#)

link_directories(${CUDA_LIBRARY_DIRS})

cuda_compile(NOVO_TESTE_CU_O src/Novo_Teste.cu)

set(FBN_SVM src/fbn_libsvm/fbn_svm.cpp  src/lrf_to_camera.cpp src/fbn_libsvm/fbn_svm-predict.cpp src/fbn_libsvm/fbn_svm-scale.cpp  src/fbn_libsvm/fbn_svm-train.cpp )
set(FBN_LBP src/fbn_lbp/lbp_pattern.cpp src/fbn_lbp/imagedescriptor.cpp)

## Declare a C++ and cuda executable
## cuda_add_executable( hello_exec ${LINE_PROFILER_CU_O} )
add_executable(V_detector_node src/main.cpp ${FBN_SVM})
target_link_libraries(V_detector_node   ${catkin_LIBRARIES} ${OpenCV_LIBS} ${cuda_LIBRARIES})


add_executable(must_detector_hLBP_plus_Colour_4_classes_V16_ground_truth src/detector_hLBP_plus_Colour_4_classes_V16_ground_truth.cpp src/train_and_test.cpp  ${FBN_SVM} ${FBN_LBP} ${NOVO_TESTE_CU_O})
target_link_libraries(must_detector_hLBP_plus_Colour_4_classes_V16_ground_truth   ${catkin_LIBRARIES} ${OpenCV_LIBS} ${cuda_LIBRARIES} TestLib /home/catkin_ws/src/V_detector/src/Novo_Teste.hpp)

Compilation output:

[ 45%] Building NVCC (Device) object V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o
-- Removing /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/./TestLib_generated_Novo_Teste.cu.o
/usr/bin/cmake -E remove /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/./TestLib_generated_Novo_Teste.cu.o
-- Generating dependency file: /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.NVCC-depend
/usr/local/cuda-6.5/bin/nvcc -M -D__CUDACC__ /home/ubuntu/catkin_ws/src/V_detector/src/Novo_Teste.cu -o /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.NVCC-depend -ccbin /usr/bin/cc -m32 -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"V_detector\" -DROSCONSOLE_BACKEND_LOG4CXX -Xcompiler ,\"-g\" -arch=sm_32 -DNVCC -I/usr/local/cuda-6.5/include -I/opt/ros/kinetic/include/opencv-3.3.1-dev -I/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv -I/usr/include -I/home/ubuntu/catkin_ws/devel/include -I/home/ubuntu/catkin_ws/src/image_common/image_transport/include -I/home/ubuntu/catkin_ws/src/image_transport_plugins/compressed_image_transport/include -I/home/ubuntu/catkin_ws/src/vision_opencv/cv_bridge/include -I/home/ubuntu/catkin_ws/src/vision_opencv/image_geometry/include -I/opt/ros/kinetic/include -I/opt/ros/kinetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp -I/usr/local/cuda-6.5/include
-- Generating temporary cmake readable file: /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend.tmp
/usr/bin/cmake -D input_file:FILEPATH=/home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.NVCC-depend -D output_file:FILEPATH=/home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend.tmp -P /usr/share/cmake-3.5/Modules/FindCUDA/make2cmake.cmake
-- Copy if different /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend.tmp to /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend
/usr/bin/cmake -E copy_if_different /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend.tmp /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend
-- Removing /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend.tmp and /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.NVCC-depend
/usr/bin/cmake -E remove /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.depend.tmp /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/TestLib_generated_Novo_Teste.cu.o.NVCC-depend
-- Generating /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/./TestLib_generated_Novo_Teste.cu.o
/usr/local/cuda-6.5/bin/nvcc /home/ubuntu/catkin_ws/src/V_detector/src/Novo_Teste.cu -c -o /home/ubuntu/catkin_ws/build/V_detector/CMakeFiles/TestLib.dir/src/./TestLib_generated_Novo_Teste.cu.o -ccbin /usr/bin/cc -m32 -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"V_detector\" -DROSCONSOLE_BACKEND_LOG4CXX -Xcompiler ,\"-g\" -arch=sm_32 -DNVCC -I/usr/local/cuda-6.5/include -I/opt/ros/kinetic/include/opencv-3.3.1-dev -I/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv -I/usr/include -I/home/ubuntu/catkin_ws/devel/include -I/home/ubuntu/catkin_ws/src/image_common/image_transport/include -I/home/ubuntu/catkin_ws/src/image_transport_plugins/compressed_image_transport/include -I/home/ubuntu/catkin_ws/src/vision_opencv/cv_bridge/include -I/home/ubuntu/catkin_ws/src/vision_opencv/image_geometry/include -I/opt/ros/kinetic/include -I/opt/ros/kinetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp -I/usr/local/cuda-6.5/include
/opt/ros/kinetic/include/ros/service_client.h(185): error: expected a ")"

/opt/ros/kinetic/include/ros/service_client.h(185): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(269): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(269): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(270): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(270): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(272): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(272): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(273): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(273): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(275): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(275): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(276): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(276): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(278): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(278): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(279): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(279): error: too few arguments in function call

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(281): error: expected a ")"

/home/ubuntu/catkin_ws/devel/include/compressed_image_transport/CompressedSubscriberConfig.h(281): error: too few arguments in function call

/opt/ros/kinetic/include/sensor_msgs/image_encodings.h(179): warning: statement is unreachable

/opt/ros/kinetic/include/sensor_msgs/image_encodings.h(227): warning: statement is unreachable

/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/stitching/detail/warpers.hpp(213): warning: overloaded virtual function "cv::detail::PlaneWarper::buildMaps" is only partially overridden in class "cv::detail::AffineWarper"

/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/stitching/detail/warpers.hpp(213): warning: overloaded virtual function "cv::detail::PlaneWarper::warp" is only partially overridden in class "cv::detail::AffineWarper"

/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/videostab/motion_stabilizing.hpp(106): warning: function "cv::videostab::IMotionStabilizer::stabilize(int, const std::vector<cv::Mat, std::allocator<cv::Mat>> &, std::pair<int, int>, cv::Mat *)" is hidden by "cv::videostab::GaussianMotionFilter::stabilize" -- virtual function override intended?

/home/ubuntu/catkin_ws/src/V_detector/src/fbn_lbp/lbp_pattern.h(63): warning: missing return statement at end of non-void function "LBP_LRF_info_3D::init"

/home/ubuntu/catkin_ws/src/V_detector/src/fbn_lbp/lbp_pattern.h(109): warning: missing return statement at end of non-void function "LBP_LRF_info_3D::inc_area"

/home/ubuntu/catkin_ws/src/V_detector/src/fbn_lbp/lbp_pattern.h(114): warning: missing return statement at end of non-void function "LBP_LRF_info_3D::set_val"

/home/ubuntu/catkin_ws/src/V_detector/src/Novo_Teste.cu(1961): warning: missing return statement at end of non-void function "load_train_and_test"

/home/ubuntu/catkin_ws/src/V_detector/src/Novo_Teste.cu(2118): warning: variable "bwimage" was set but never used

/home/ubuntu/catkin_ws/src/V_detector/src/Novo_Teste.cu(2120): warning: variable "lbp_image" was set but never used

/home/ubuntu/catkin_ws/src/V_detector/src/Novo_Teste.cu(2121): warning: variable "output" was set but never used

Asked by billyDong on 2018-10-03 11:26:06 UTC

Comments

I just posted the headers because that's where the problems start. in the includes of ROS.

it's actually more likely that the problem is somewhere else and it first surfaces in the error message that refers to /opt/ros/kinetic/include/ros/service_client.h.

Asked by gvdhoorn on 2018-10-03 13:14:45 UTC

@gvdhoorn it works perfectly with cuda 9.1 either using ros kinetic or ros melodic in an x86_64 arch.

Here I must use cuda 6.5 (the latest compatible version) and ubuntu 16.04 with ARM arch. the problem begins by adding the ROS header in file "novo_teste.cu"

Asked by billyDong on 2018-10-22 13:27:34 UTC

Answers