Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torch shared library: libc10.so: cannot open shared object file #639

Closed
gorghino opened this issue Apr 17, 2024 · 4 comments
Closed

Torch shared library: libc10.so: cannot open shared object file #639

gorghino opened this issue Apr 17, 2024 · 4 comments

Comments

@gorghino
Copy link

gorghino commented Apr 17, 2024

Hi all,
I created a ROS2 Humble C++ package which includes <torch/script.h> on my Orin NX (aarch64).
I think I correctly managed the CMakeList.txt and package.xml but I cannot run the package if I don't set the LD_LIBRARY_PATH manually first.

nvidia@nvidia:~/ws$ ros2 run online_traj online_traj 
/home/nvidia/ws/install/online_traj/lib/online_traj/online_traj: error while loading shared libraries: libc10.so: cannot open shared object file: No such file or directory
[ros2run]: Process exited with failure 127

As a workaround I can add /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/ but I'd prefer install/setup.bash to find them instead.

As ldd shows, the .so files from libtorch are missing:

nvidia@nvidia:~/ws$ ldd install/online_traj/lib/online_traj/online_traj 
	linux-vdso.so.1 (0x0000ffff9fffb000)
	librclcpp.so => /home/nvidia/ros2_humble/install/lib/librclcpp.so (0x0000ffff9fb7f000)
	libyaml-cpp.so.0.6 => /lib/aarch64-linux-gnu/libyaml-cpp.so.0.6 (0x0000ffff9fade000)
	libc10.so => not found
	liblibstatistics_collector.so => /home/nvidia/ros2_humble/install/lib/liblibstatistics_collector.so (0x0000ffff9fac8000)
	librcl.so => /home/nvidia/ros2_humble/install/lib/librcl.so (0x0000ffff9fa7e000)
	libstatistics_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_cpp.so (0x0000ffff9fa6b000)
	libtracetools.so => /home/nvidia/ros2_humble/install/lib/libtracetools.so (0x0000ffff9fa58000)
	librmw.so => /home/nvidia/ros2_humble/install/lib/librmw.so (0x0000ffff9fa3f000)
	librcutils.so => /home/nvidia/ros2_humble/install/lib/librcutils.so (0x0000ffff9fa19000)
	libtorch_cpu.so => not found
	libtorch_cuda.so => not found
	libtorch.so => not found
	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffff9f834000)
	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff9f789000)
	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff9f765000)
	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff9f5f2000)
	/lib/ld-linux-aarch64.so.1 (0x0000ffff9ffcb000)
	.....

This is my current CMakeLists.txt

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(online_traj)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# get and append paths for finding dep
execute_process(
  COMMAND python -c "import torch; import os; print(os.path.dirname(torch.__file__), end='')"
  OUTPUT_VARIABLE TorchPath
)
list(APPEND CMAKE_PREFIX_PATH ${TorchPath})

find_package(ament_cmake REQUIRED)
find_package(Torch REQUIRED PATHS "${TorchPath}")
find_package(rclcpp REQUIRED)

add_executable(online_traj src/online_traj.cpp)
ament_target_dependencies(online_traj Torch rclcpp)
target_include_directories(online_traj PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
target_link_libraries(online_traj "${TORCH_LIBRARIES}")

target_compile_features(online_traj PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17

install(TARGETS online_traj
  DESTINATION lib/${PROJECT_NAME}
  )

install(DIRECTORY
  config
  DESTINATION
    share/${PROJECT_NAME})

ament_package()

All the missing libs are in /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/

@cottsay
Copy link
Member

cottsay commented Apr 17, 2024

I'm not sure how colcon could do any of this differently. How would you expect this project to build without colcon involved at all?

It seems like the root of your problem is that Torch is installed to your home directory and your environment variables are not updated to enable discoverability from that location. This would all happen (presumably by pip) prior to building the package at all, whether colcon is involved or not.

Is there a system package for Torch you could use instead?

@gorghino
Copy link
Author

Hi @cottsay !
I'm not sure colcon can do it differently, but I'm trying to understand which is the good practice for this situation.
My final goal is to avoid asking the user to add /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/ manually to LD_LIBRARY_PATH if cmake/colcon can do it. I'm not very familiar with colcon and maybe I'm missing some useful flags or cmake directives.

For example this is the colcon log when I compile online_traj:


nvidia@nvidia:~/ws$ colcon build --packages-select online_traj --event-handlers console_cohesion+ --cmake-args -DCMAKE_VERBOSE_MAKEFILE=ON
Starting >>> online_traj
[Processing: online_traj]                             
[Processing: online_traj]                                     
--- output: online_traj                                        
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 1.3.8 (/home/nvidia/ros2_humble/install/share/ament_cmake/cmake)
-- Found Python3: /usr/bin/python3 (found version "3.8.10") found components: Interpreter 
-- Found CUDA: /usr/local/cuda-11.4 (found version "11.4") 
-- The CUDA compiler identification is NVIDIA 11.4.315
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-11.4/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDAToolkit: /usr/local/cuda-11.4/include (found version "11.4.315") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Caffe2: CUDA detected: 11.4
-- Caffe2: CUDA nvcc is: /usr/local/cuda-11.4/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda-11.4
-- Caffe2: Header version is: 11.4
-- /usr/local/cuda-11.4/lib64/libnvrtc.so shorthash is 7c7201d5
-- USE_CUDNN is set to 0. Compiling without cuDNN support
-- Autodetected CUDA architecture(s):  8.7
-- Added CUDA NVCC flags for: -gencode;arch=compute_87,code=sm_87
-- Found Torch: /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so  
-- Found eigen3_cmake_module: 0.1.1 (/home/nvidia/ros2_humble/install/share/eigen3_cmake_module/cmake)
-- Found Eigen3: TRUE (found version "3.3.7") 
-- Found rclcpp: 16.0.8 (/home/nvidia/ros2_humble/install/share/rclcpp/cmake)
-- Found rosidl_generator_c: 3.1.5 (/home/nvidia/ros2_humble/install/share/rosidl_generator_c/cmake)
-- Found rosidl_adapter: 3.1.5 (/home/nvidia/ros2_humble/install/share/rosidl_adapter/cmake)
-- Found rosidl_generator_cpp: 3.1.5 (/home/nvidia/ros2_humble/install/share/rosidl_generator_cpp/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found rmw_implementation_cmake: 6.1.1 (/home/nvidia/ros2_humble/install/share/rmw_implementation_cmake/cmake)
-- Found rmw_fastrtps_cpp: 6.2.6 (/home/nvidia/ros2_humble/install/share/rmw_fastrtps_cpp/cmake)
-- Found OpenSSL: /usr/lib/aarch64-linux-gnu/libcrypto.so (found version "1.1.1f")  
-- Found FastRTPS: /home/nvidia/ros2_humble/install/include  
-- Using RMW implementation 'rmw_fastrtps_cpp' as default
-- Found dr_msgs: 0.0.4 (/home/nvidia/ws/install/dr_msgs/share/dr_msgs/cmake)
-- Found yaml_cpp_vendor: 8.0.2 (/home/nvidia/ros2_humble/install/share/yaml_cpp_vendor/cmake)
-- Found control_utils: 0.0.0 (/home/nvidia/ws/install/control_utils/share/control_utils/cmake)
-- Configuring done (7.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/nvidia/ws/build/online_traj
Change Dir: '/home/nvidia/ws/build/online_traj'

Run Build Command(s): /home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile -j8 -l8
/home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -S/home/nvidia/ws/src/controllers/online_traj -B/home/nvidia/ws/build/online_traj --check-build-system CMakeFiles/Makefile.cmake 0
/home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E cmake_progress_start /home/nvidia/ws/build/online_traj/CMakeFiles /home/nvidia/ws/build/online_traj//CMakeFiles/progress.marks
/usr/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/nvidia/ws/build/online_traj'
/usr/bin/make  -f CMakeFiles/online_traj.dir/build.make CMakeFiles/online_traj.dir/depend
/usr/bin/make  -f CMakeFiles/chunk_node.dir/build.make CMakeFiles/chunk_node.dir/depend
make[2]: Entering directory '/home/nvidia/ws/build/online_traj'
cd /home/nvidia/ws/build/online_traj && /home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/nvidia/ws/src/controllers/online_traj /home/nvidia/ws/src/controllers/online_traj /home/nvidia/ws/build/online_traj /home/nvidia/ws/build/online_traj /home/nvidia/ws/build/online_traj/CMakeFiles/online_traj.dir/DependInfo.cmake "--color="
make[2]: Entering directory '/home/nvidia/ws/build/online_traj'
cd /home/nvidia/ws/build/online_traj && /home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/nvidia/ws/src/controllers/online_traj /home/nvidia/ws/src/controllers/online_traj /home/nvidia/ws/build/online_traj /home/nvidia/ws/build/online_traj /home/nvidia/ws/build/online_traj/CMakeFiles/chunk_node.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/home/nvidia/ws/build/online_traj'
/usr/bin/make  -f CMakeFiles/online_traj.dir/build.make CMakeFiles/online_traj.dir/build
make[2]: Leaving directory '/home/nvidia/ws/build/online_traj'
/usr/bin/make  -f CMakeFiles/chunk_node.dir/build.make CMakeFiles/chunk_node.dir/build
make[2]: Entering directory '/home/nvidia/ws/build/online_traj'
make[2]: Entering directory '/home/nvidia/ws/build/online_traj'
[ 50%] Building CXX object CMakeFiles/online_traj.dir/src/online_traj.cpp.o
[ 50%] Building CXX object CMakeFiles/chunk_node.dir/src/chunk_node.cpp.o
/usr/bin/c++ -DDEFAULT_RMW_IMPLEMENTATION=rmw_fastrtps_cpp -DRCUTILS_ENABLE_FAULT_INJECTION -I/usr/include/eigen3 -I/home/nvidia/ws/src/controllers/online_traj/include -isystem /home/nvidia/ws/install/dr_msgs/include/dr_msgs -isystem /home/nvidia/ros2_humble/install/include/rclcpp -isystem /home/nvidia/ros2_humble/install/include/ament_index_cpp -isystem /home/nvidia/ros2_humble/install/include/libstatistics_collector -isystem /home/nvidia/ros2_humble/install/include/builtin_interfaces -isystem /home/nvidia/ros2_humble/install/include/rosidl_runtime_c -isystem /home/nvidia/ros2_humble/install/include/rcutils -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_interface -isystem /home/nvidia/ros2_humble/install/include -isystem /home/nvidia/ros2_humble/install/include/rosidl_runtime_cpp -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_fastrtps_cpp -isystem /home/nvidia/ros2_humble/install/include/rmw -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_fastrtps_c -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_introspection_c -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_introspection_cpp -isystem /home/nvidia/ros2_humble/install/include/rcl -isystem /home/nvidia/ros2_humble/install/include/rcl_interfaces -isystem /home/nvidia/ros2_humble/install/include/rcl_logging_interface -isystem /home/nvidia/ros2_humble/install/include/rcl_yaml_param_parser -isystem /home/nvidia/ros2_humble/install/include/libyaml_vendor -isystem /home/nvidia/ros2_humble/install/include/tracetools -isystem /home/nvidia/ros2_humble/install/include/rcpputils -isystem /home/nvidia/ros2_humble/install/include/statistics_msgs -isystem /home/nvidia/ros2_humble/install/include/rosgraph_msgs -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_cpp -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_c -isystem /home/nvidia/ros2_humble/install/include/geometry_msgs -isystem /home/nvidia/ros2_humble/install/include/std_msgs -isystem /home/nvidia/ros2_humble/install/include/sensor_msgs -isystem /home/nvidia/.local/lib/python3.8/site-packages/torch/include -isystem /home/nvidia/.local/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /usr/local/cuda-11.4/include -std=gnu++17 -Wall -Wextra -Wpedantic -D_GLIBCXX_USE_CXX11_ABI=1 -MD -MT CMakeFiles/online_traj.dir/src/online_traj.cpp.o -MF CMakeFiles/online_traj.dir/src/online_traj.cpp.o.d -o CMakeFiles/online_traj.dir/src/online_traj.cpp.o -c /home/nvidia/ws/src/controllers/online_traj/src/online_traj.cpp
/usr/bin/c++ -DDEFAULT_RMW_IMPLEMENTATION=rmw_fastrtps_cpp -DRCUTILS_ENABLE_FAULT_INJECTION -isystem /home/nvidia/ws/install/control_utils/include -isystem /home/nvidia/ws/install/dr_msgs/include/dr_msgs -isystem /home/nvidia/ros2_humble/install/include/rclcpp -isystem /usr/include/eigen3 -isystem /home/nvidia/ros2_humble/install/include/ament_index_cpp -isystem /home/nvidia/ros2_humble/install/include/libstatistics_collector -isystem /home/nvidia/ros2_humble/install/include/builtin_interfaces -isystem /home/nvidia/ros2_humble/install/include/rosidl_runtime_c -isystem /home/nvidia/ros2_humble/install/include/rcutils -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_interface -isystem /home/nvidia/ros2_humble/install/include -isystem /home/nvidia/ros2_humble/install/include/rosidl_runtime_cpp -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_fastrtps_cpp -isystem /home/nvidia/ros2_humble/install/include/rmw -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_fastrtps_c -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_introspection_c -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_introspection_cpp -isystem /home/nvidia/ros2_humble/install/include/rcl -isystem /home/nvidia/ros2_humble/install/include/rcl_interfaces -isystem /home/nvidia/ros2_humble/install/include/rcl_logging_interface -isystem /home/nvidia/ros2_humble/install/include/rcl_yaml_param_parser -isystem /home/nvidia/ros2_humble/install/include/libyaml_vendor -isystem /home/nvidia/ros2_humble/install/include/tracetools -isystem /home/nvidia/ros2_humble/install/include/rcpputils -isystem /home/nvidia/ros2_humble/install/include/statistics_msgs -isystem /home/nvidia/ros2_humble/install/include/rosgraph_msgs -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_cpp -isystem /home/nvidia/ros2_humble/install/include/rosidl_typesupport_c -isystem /home/nvidia/ros2_humble/install/include/geometry_msgs -isystem /home/nvidia/ros2_humble/install/include/std_msgs -isystem /home/nvidia/ros2_humble/install/include/sensor_msgs -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT CMakeFiles/chunk_node.dir/src/chunk_node.cpp.o -MF CMakeFiles/chunk_node.dir/src/chunk_node.cpp.o.d -o CMakeFiles/chunk_node.dir/src/chunk_node.cpp.o -c /home/nvidia/ws/src/controllers/online_traj/src/chunk_node.cpp
[ 75%] Linking CXX executable chunk_node
/home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/chunk_node.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/chunk_node.dir/src/chunk_node.cpp.o -o chunk_node  -Wl,-rpath,/home/nvidia/ros2_humble/install/lib:/home/nvidia/ws/install/dr_msgs/lib: /home/nvidia/ros2_humble/install/lib/librclcpp.so /home/nvidia/ws/install/control_utils/lib/libcontrol_utils.a /home/nvidia/ros2_humble/install/lib/liblibstatistics_collector.so /home/nvidia/ros2_humble/install/lib/librcl.so /home/nvidia/ros2_humble/install/lib/librmw_implementation.so /home/nvidia/ros2_humble/install/lib/libament_index_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_logging_spdlog.so /home/nvidia/ros2_humble/install/lib/librcl_logging_interface.so -lpthread /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/librcl_yaml_param_parser.so /home/nvidia/ros2_humble/install/lib/libyaml.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libtracetools.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_fastrtps_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libfastcdr.so.1.0.24 /home/nvidia/ros2_humble/install/lib/librmw.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_introspection_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_generator_py.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librcpputils.so /home/nvidia/ros2_humble/install/lib/librosidl_runtime_c.so /home/nvidia/ros2_humble/install/lib/librcutils.so -ldl /usr/lib/aarch64-linux-gnu/libpython3.8.so 
make[2]: Leaving directory '/home/nvidia/ws/build/online_traj'
[ 75%] Built target chunk_node
[100%] Linking CXX executable online_traj
/home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/online_traj.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/online_traj.dir/src/online_traj.cpp.o -o online_traj  -Wl,-rpath,/home/nvidia/ros2_humble/install/lib:/home/nvidia/ws/install/dr_msgs/lib:/home/nvidia/.local/lib/python3.8/site-packages/torch/lib:/usr/local/cuda-11.4/lib64: /home/nvidia/ros2_humble/install/lib/librclcpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_generator_py.so /usr/lib/aarch64-linux-gnu/libyaml-cpp.so.0.6.2 /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10.so /usr/lib/aarch64-linux-gnu/libcuda.so /usr/local/cuda-11.4/lib64/libnvrtc.so /usr/local/cuda-11.4/lib64/libnvToolsExt.so /usr/local/cuda-11.4/lib64/libcudart.so /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10_cuda.so /home/nvidia/ros2_humble/install/lib/liblibstatistics_collector.so /home/nvidia/ros2_humble/install/lib/librcl.so /home/nvidia/ros2_humble/install/lib/librmw_implementation.so /home/nvidia/ros2_humble/install/lib/libament_index_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_logging_spdlog.so /home/nvidia/ros2_humble/install/lib/librcl_logging_interface.so -lpthread /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/librcl_yaml_param_parser.so /home/nvidia/ros2_humble/install/lib/libyaml.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libtracetools.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libfastcdr.so.1.0.24 /home/nvidia/ros2_humble/install/lib/librmw.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librcpputils.so /home/nvidia/ros2_humble/install/lib/librosidl_runtime_c.so /home/nvidia/ros2_humble/install/lib/librcutils.so -ldl /usr/lib/aarch64-linux-gnu/libpython3.8.so -Wl,--no-as-needed,"/home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so" -Wl,--as-needed /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10_cuda.so /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10.so /usr/local/cuda-11.4/lib64/libcudart.so /usr/local/cuda-11.4/lib64/libnvToolsExt.so /usr/local/cuda-11.4/lib64/libcufft.so /usr/local/cuda-11.4/lib64/libcurand.so /usr/local/cuda-11.4/lib64/libcublas.so /usr/local/cuda-11.4/lib64/libcublasLt.so -Wl,--no-as-needed,"/home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so" -Wl,--as-needed 
make[2]: Leaving directory '/home/nvidia/ws/build/online_traj'
[100%] Built target online_traj
make[1]: Leaving directory '/home/nvidia/ws/build/online_traj'
/home/nvidia/.local/lib/python3.8/site-packages/cmake/data/bin/cmake -E cmake_progress_start /home/nvidia/ws/build/online_traj/CMakeFiles 0

-- Install configuration: ""
-- Installing: /home/nvidia/ws/install/online_traj/lib/online_traj/online_traj
-- Set non-toolchain portion of runtime path of "/home/nvidia/ws/install/online_traj/lib/online_traj/online_traj" to ""
-- Installing: /home/nvidia/ws/install/online_traj/lib/online_traj/chunk_node
-- Set non-toolchain portion of runtime path of "/home/nvidia/ws/install/online_traj/lib/online_traj/chunk_node" to "/home/nvidia/ros2_humble/install/lib:/home/nvidia/ws/install/dr_msgs/lib"
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/config
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/config/quadrotor_env.yaml
-- Installing: /home/nvidia/ws/install/online_traj/share/ament_index/resource_index/package_run_dependencies/online_traj
-- Installing: /home/nvidia/ws/install/online_traj/share/ament_index/resource_index/parent_prefix_path/online_traj
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/environment/ament_prefix_path.sh
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/environment/ament_prefix_path.dsv
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/environment/path.sh
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/environment/path.dsv
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/local_setup.bash
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/local_setup.sh
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/local_setup.zsh
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/local_setup.dsv
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/package.dsv
-- Installing: /home/nvidia/ws/install/online_traj/share/ament_index/resource_index/packages/online_traj
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/cmake/online_trajConfig.cmake
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/cmake/online_trajConfig-version.cmake
-- Installing: /home/nvidia/ws/install/online_traj/share/online_traj/package.xml
---
Finished <<< online_traj [1min 8s]

Summary: 1 package finished [1min 9s]

In the linking step I can see the correct links to the .so files that are missing in the final exe (e.g. /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so).

Another test I tried is to launch the last c++ command from the log above, inside build/online_traj:

nvidia@nvidia:~/ws/build/online_traj$ /usr/bin/c++ CMakeFiles/online_traj.dir/src/online_traj.cpp.o -o online_traj  -Wl,-rpath,/home/nvidia/ros2_humble/install/lib:/home/nvidia/ws/install/dr_msgs/lib:/home/nvidia/.local/lib/python3.8/site-packages/torch/lib:/usr/local/cuda-11.4/lib64: /home/nvidia/ros2_humble/install/lib/librclcpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_generator_py.so /usr/lib/aarch64-linux-gnu/libyaml-cpp.so.0.6.2 /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10.so /usr/lib/aarch64-linux-gnu/libcuda.so /usr/local/cuda-11.4/lib64/libnvrtc.so /usr/local/cuda-11.4/lib64/libnvToolsExt.so /usr/local/cuda-11.4/lib64/libcudart.so /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10_cuda.so /home/nvidia/ros2_humble/install/lib/liblibstatistics_collector.so /home/nvidia/ros2_humble/install/lib/librcl.so /home/nvidia/ros2_humble/install/lib/librmw_implementation.so /home/nvidia/ros2_humble/install/lib/libament_index_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_logging_spdlog.so /home/nvidia/ros2_humble/install/lib/librcl_logging_interface.so -lpthread /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/librcl_yaml_param_parser.so /home/nvidia/ros2_humble/install/lib/libyaml.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libtracetools.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_fastrtps_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_fastrtps_cpp.so /home/nvidia/ros2_humble/install/lib/libfastcdr.so.1.0.24 /home/nvidia/ros2_humble/install/lib/librmw.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_introspection_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_introspection_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_cpp.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_c.so /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libsensor_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_py.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/libstd_msgs__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_c.so /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_c.so /home/nvidia/ros2_humble/install/lib/librcpputils.so /home/nvidia/ros2_humble/install/lib/librosidl_runtime_c.so /home/nvidia/ros2_humble/install/lib/librcutils.so -ldl /usr/lib/aarch64-linux-gnu/libpython3.8.so -Wl,--no-as-needed,"/home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so" -Wl,--as-needed -Wl,--no-as-needed,"/home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so" -Wl,--as-needed /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10_cuda.so /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10.so /usr/local/cuda-11.4/lib64/libcudart.so /usr/local/cuda-11.4/lib64/libnvToolsExt.so /usr/local/cuda-11.4/lib64/libcufft.so /usr/local/cuda-11.4/lib64/libcurand.so /usr/local/cuda-11.4/lib64/libcublas.so /usr/local/cuda-11.4/lib64/libcublasLt.so -Wl,--no-as-needed,"/home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so" -Wl,--as-needed

which correctly creates the exe online_traj in the same folder.
THIS exe has all the corresponding libraries instead and this is ok without setting the library in the env:

nvidia@nvidia:~/ws$ echo $LD_LIBRARY_PATH
/home/nvidia/ws/install/optimization_utils/lib:/home/nvidia/ws/install/dr_msgs/lib:/home/nvidia/ros2_humble/install/opt/rviz_ogre_vendor/lib:/home/nvidia/ros2_humble/install/lib:/usr/local/cuda-11.4/lib64:
nvidia@nvidia:~/ws/build/online_traj$ ls
CMakeCache.txt  CTestConfiguration.ini  CTestTestfile.cmake  ament_cmake_core               ament_cmake_index              ament_cmake_uninstall_target  cmake_args.last      colcon_build.rc                 colcon_command_prefix_build.sh.env   detect_cuda_version.cc  online_traj
CMakeFiles      CTestCustom.cmake       Makefile             ament_cmake_environment_hooks  ament_cmake_package_templates  chunk_node                    cmake_install.cmake  colcon_command_prefix_build.sh  detect_cuda_compute_capabilities.cu  install_manifest.txt
nvidia@nvidia:~/ws/build/online_traj$ ldd online_traj 
	linux-vdso.so.1 (0x0000ffff88dc5000)
	librclcpp.so => /home/nvidia/ros2_humble/install/lib/librclcpp.so (0x0000ffff88950000)
	libdr_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ws/install/dr_msgs/lib/libdr_msgs__rosidl_typesupport_cpp.so (0x0000ffff88939000)
	libyaml-cpp.so.0.6 => /lib/aarch64-linux-gnu/libyaml-cpp.so.0.6 (0x0000ffff888af000)
	libc10.so => /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10.so (0x0000ffff887f8000)
	liblibstatistics_collector.so => /home/nvidia/ros2_humble/install/lib/liblibstatistics_collector.so (0x0000ffff887e2000)
	librcl.so => /home/nvidia/ros2_humble/install/lib/librcl.so (0x0000ffff88798000)
	libstatistics_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_cpp.so (0x0000ffff88785000)
	libtracetools.so => /home/nvidia/ros2_humble/install/lib/libtracetools.so (0x0000ffff88772000)
	librmw.so => /home/nvidia/ros2_humble/install/lib/librmw.so (0x0000ffff88759000)
	libgeometry_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_cpp.so (0x0000ffff88740000)
	librcutils.so => /home/nvidia/ros2_humble/install/lib/librcutils.so (0x0000ffff8871a000)
	libtorch_cpu.so => /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so (0x0000ffff82455000)
	libtorch_cuda.so => /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so (0x0000ffff76aa0000)
	libtorch.so => /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libtorch.so (0x0000ffff76a8e000)
	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffff768a9000)
	libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff767fe000)
	libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff767da000)
	libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff76667000)
	/lib/ld-linux-aarch64.so.1 (0x0000ffff88d95000)
	libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffff76636000)
	librcl_interfaces__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_cpp.so (0x0000ffff7661d000)
	librcl_yaml_param_parser.so => /home/nvidia/ros2_humble/install/lib/librcl_yaml_param_parser.so (0x0000ffff76603000)
	librosgraph_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/librosgraph_msgs__rosidl_typesupport_cpp.so (0x0000ffff765f1000)
	librmw_implementation.so => /home/nvidia/ros2_humble/install/lib/librmw_implementation.so (0x0000ffff765d6000)
	libament_index_cpp.so => /home/nvidia/ros2_humble/install/lib/libament_index_cpp.so (0x0000ffff765be000)
	librcl_logging_interface.so => /home/nvidia/ros2_humble/install/lib/librcl_logging_interface.so (0x0000ffff765ab000)
	librcpputils.so => /home/nvidia/ros2_humble/install/lib/librcpputils.so (0x0000ffff7658e000)
	librosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_cpp.so (0x0000ffff7657a000)
	libnuma.so.1 => /lib/aarch64-linux-gnu/libnuma.so.1 (0x0000ffff7655b000)
	librcl_logging_spdlog.so => /home/nvidia/ros2_humble/install/lib/librcl_logging_spdlog.so (0x0000ffff76544000)
	librcl_interfaces__rosidl_typesupport_c.so => /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_typesupport_c.so (0x0000ffff7652c000)
	librcl_interfaces__rosidl_generator_c.so => /home/nvidia/ros2_humble/install/lib/librcl_interfaces__rosidl_generator_c.so (0x0000ffff76501000)
	librosidl_runtime_c.so => /home/nvidia/ros2_humble/install/lib/librosidl_runtime_c.so (0x0000ffff764e8000)
	libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffff764d4000)
	librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000ffff764bc000)
	libopenblas.so.0 => /lib/aarch64-linux-gnu/libopenblas.so.0 (0x0000ffff75624000)
	libgomp.so.1 => /lib/aarch64-linux-gnu/libgomp.so.1 (0x0000ffff755d4000)
	libc10_cuda.so => /home/nvidia/.local/lib/python3.8/site-packages/torch/lib/libc10_cuda.so (0x0000ffff75558000)
	libcudart.so.11.0 => /usr/local/cuda-11.4/lib64/libcudart.so.11.0 (0x0000ffff7549c000)
	libcusparse.so.11 => /usr/local/cuda-11.4/lib64/libcusparse.so.11 (0x0000ffff677f5000)
	libcurand.so.10 => /usr/local/cuda-11.4/lib64/libcurand.so.10 (0x0000ffff6274b000)
	libcufft.so.10 => /usr/local/cuda-11.4/lib64/libcufft.so.10 (0x0000ffff577e1000)
	libnvToolsExt.so.1 => /usr/local/cuda-11.4/lib64/libnvToolsExt.so.1 (0x0000ffff577c5000)
	libcudnn.so.8 => /lib/aarch64-linux-gnu/libcudnn.so.8 (0x0000ffff5778e000)
	libcublas.so.11 => /usr/local/cuda-11.4/lib64/libcublas.so.11 (0x0000ffff4d6b5000)
	libcublasLt.so.11 => /usr/local/cuda-11.4/lib64/libcublasLt.so.11 (0x0000ffff36114000)
	libyaml.so => /home/nvidia/ros2_humble/install/lib/libyaml.so (0x0000ffff360e7000)
	libspdlog.so.1 => /lib/aarch64-linux-gnu/libspdlog.so.1 (0x0000ffff3603b000)
	librosidl_typesupport_c.so => /home/nvidia/ros2_humble/install/lib/librosidl_typesupport_c.so (0x0000ffff36027000)
	libbuiltin_interfaces__rosidl_generator_c.so => /home/nvidia/ros2_humble/install/lib/libbuiltin_interfaces__rosidl_generator_c.so (0x0000ffff36013000)
	libgfortran.so.5 => /lib/aarch64-linux-gnu/libgfortran.so.5 (0x0000ffff35e98000)

Even sourcing the ROS2 workspace doesn't seem to work with the exe under install though.

nvidia@nvidia:~/ws$ . install/setup.bash
nvidia@nvidia:~/ws$ ldd install/online_traj/lib/online_traj/online_traj
	.....
	libyaml-cpp.so.0.6 => /lib/aarch64-linux-gnu/libyaml-cpp.so.0.6 (0x0000ffff90340000)
	libc10.so => not found
	liblibstatistics_collector.so => /home/nvidia/ros2_humble/install/lib/liblibstatistics_collector.so (0x0000ffff9032a000)
	librcl.so => /home/nvidia/ros2_humble/install/lib/librcl.so (0x0000ffff902e0000)
	libstatistics_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/libstatistics_msgs__rosidl_typesupport_cpp.so (0x0000ffff902cd000)
	libtracetools.so => /home/nvidia/ros2_humble/install/lib/libtracetools.so (0x0000ffff902ba000)
	librmw.so => /home/nvidia/ros2_humble/install/lib/librmw.so (0x0000ffff902a1000)
	libgeometry_msgs__rosidl_typesupport_cpp.so => /home/nvidia/ros2_humble/install/lib/libgeometry_msgs__rosidl_typesupport_cpp.so (0x0000ffff90288000)
	librcutils.so => /home/nvidia/ros2_humble/install/lib/librcutils.so (0x0000ffff90262000)
	libtorch_cpu.so => not found
	libtorch_cuda.so => not found
	libtorch.so => not found
	libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffff9007d000)
        .....

@cottsay
Copy link
Member

cottsay commented Apr 23, 2024

It seems that the mechanism by which Torch wants you to locate the shared libraries is using an RPATH on your binaries. CMake is likely stripping RPATHs during installation, as is the default behavior on most platforms.

These RPATHs are an embedded path in the binary that lets the runtime library loader know about additional locations to look for dynamic libraries. That's why manually creating the executable seems to "work" - the RPATHs haven't yet been stripped by CMake.

RPATHs are pretty controversial. Many developers swear by them and sometimes require them when building their software. Platform maintainers, on the other hand, often forbid absolute RPATHs. Major distributions like Debian, Ubuntu, and Fedora discourage their use for a variety of reasons. There are valid reasons on both sides that we won't get into here.

Since Torch has forced your hand, you'll need to instruct CMake to include at least some RPATHs at install time. The most notable downside here is that the binaries you create will no longer be portable, meaning that they'll only be able to find the Torch libraries if they're located exactly where you have them when you build your package. ROS workspaces are generally portable, meaning that you can move the workspace to a different location and re-source the setup.sh and the binaries are still usable. Using absolute RPATHs will probably mean that your packages won't be able to do that.

Again, this is nothing to do with colcon, so this really isn't an appropriate form to troubleshoot your issue. Help requests like this for ROS packages should really be discussed on discourse.ros.org.

@gorghino
Copy link
Author

Thank you @cottsay for the explanation. I will try to better understand how to manage the RPATH with CMake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants