Unable to link CUDA libraries with dw_ros

Please provide the following info (check/uncheck the boxes after creating this topic):
Software Version
DRIVE OS Linux 5.2.6
DRIVE OS Linux 5.2.6 and DriveWorks 4.0
DRIVE OS Linux 5.2.0
DRIVE OS Linux 5.2.0 and DriveWorks 3.5
NVIDIA DRIVE™ Software 10.0 (Linux)
NVIDIA DRIVE™ Software 9.0 (Linux)
other DRIVE OS version

Target Operating System

Hardware Platform
NVIDIA DRIVE™ AGX Xavier DevKit (E3550)
NVIDIA DRIVE™ AGX Pegasus DevKit (E3550)

SDK Manager Version

Host Machine Version
native Ubuntu 18.04

We have been trying to integrate the sample Object Detection with dw_ros framework. The sample_object_detector_tracker sample works fine when run from the /usr/local/driveworks-3.5/samples/bin folder and CUDA libraries are linked to the executable

The problem arises when we try to cross-compile a custom executable using dw_ros tutorial. In the attached CMakeLists.txt, we try to find the cuda-libs package. In the cuda-libs config file, cudart library cant be found even though the path for cudart library is given in HINTS . This the error we get when building the custom executable.

-- catkin 0.7.29
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Warning at /usr/local/driveworks-3.5/samples/3rdparty/shared/cuda-libs/cuda-libs-config.cmake:15 (message):
  Could not find cudart library.  Looked in
Call Stack (most recent call first):
  CMakeLists.txt:23 (find_package)

CMake Error at CMakeLists.txt:23 (find_package):
  Found package configuration file:


  but it set cuda-libs_FOUND to FALSE so package "cuda-libs" is considered to

-- Configuring incomplete, errors occurred!
See also "/home/agx-pegasus/ros_radar_driver_agx/build_isolated/nv_camera_multiple_new/CMakeFiles/CMakeOutput.log".
See also "/home/agx-pegasus/ros_radar_driver_agx/build_isolated/nv_camera_multiple_new/CMakeFiles/CMakeError.log".
Makefile:820: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
<== Failed to process package 'nv_camera_multiple_new': 
  Command '['/home/agx-pegasus/ros_radar_driver_agx/install_isolated/env.sh', 'make', 'cmake_check_build_system']' returned non-zero exit status 2

Reproduce this error by running:
==> cd /home/agx-pegasus/ros_radar_driver_agx/build_isolated/nv_camera_multiple_new && /home/agx-pegasus/ros_radar_driver_agx/install_isolated/env.sh make cmake_check_build_system

Command failed, exiting.

The cuda-libs-config.cmake file is attached for reference. We get Unable to find cudart library linkage error. The issue is similar with cublas and other CUDA related libraries
CMakeLists.txt (1.8 KB)
cuda-libs-config.cmake (1.0 KB)

Dear @user130505,
Could you confirm if you can cross compile DW samples with out any issue?

No issues with samples such as sample_camera which involves camera initialization. Object detection involves CUDA libraries, which fail to fetch the required CUDA libraries even though the definitions are found in the CMakeList. For example, at the end of building the package, like mentioned above, it says the given path to cuda-libs config file is present and is able to locate it but continues to say “not found”.

Hi, @user130505

I haven’t looked into your problem. But have you referred to the compilation of sample_object_detector_tracker to see if any clue on it?

Yes, as a matter of fact, I have looked into it and sample_object_detector_tracker works fine. We used a similar approach to compile object detection with ROS and it fails. Like I mentioned above, not able to link the CUDA libraries when doing cross-compiling with ROS. Any help would be great.

Dear @user130505,
I think CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES variable seems to be empty as per my understanding from log output. Could you check that first?

Yes I added the CUDA TOOLKIT DIRECTORIES path. Now the error is as follows:

/home/agx-pegasus/nvidia/nvidia_sdk/DRIVE_OS_5.2.0_SDK_Linux_OS_DDPX/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcudart_LIBRARY`
`/home/agx-pegasus/nvidia/nvidia_sdk/DRIVE_OS_5.2.0_SDK_Linux_OS_DDPX/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/../../../../aarch64-linux-gnu/bin/ld: cannot find -lcuda_LIBRARY`
`collect2: error: ld returned 1 exit status`
`CMakeFiles/nv_camera_multiple_new.dir/build.make:136: recipe for target '/home/agx-pegasus/ros_radar_driver_agx/devel_isolated/nv_camera_multiple_new/lib/nv_camera_multiple_new/nv_camera_multiple_new' failed`

This issue has been resolved. The CUDA libraries have been linked successfully.

1 Like

Dear @user130505,
Good to hear the issue is resolved.

Dear @user130505,
Could you share the solution used to fix the issue to help others in community