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

catkin_make error #65

Open
iason-r opened this issue Jan 3, 2024 · 4 comments
Open

catkin_make error #65

iason-r opened this issue Jan 3, 2024 · 4 comments

Comments

@iason-r
Copy link

iason-r commented Jan 3, 2024

/usr/bin/ld: cannot find -lCUDA::cublas
/usr/bin/ld: cannot find -lCUDA::cudart
/usr/bin/ld: cannot find -lCUDA::cusolver
/usr/bin/ld: cannot find -lCUDA::cusparse
collect2: error: ld returned 1 exit status

What should I do to solve this problem

@SunZezhou
Copy link

In my personal experience, this is because the USE_CUDA parameter is turned on when compiling Ceres. Setting USE_CUDA to OFF in CMakeLists of Ceres and then re-install it may solve this problem.

@mz7790
Copy link

mz7790 commented Apr 25, 2024

The solution I encountered was similar to yours. I'm using Ceres 2.2.0. When compiling Ceres 2.2.0, everything goes smoothly. However, when compiling ALOAM, I encounter the same error as you. I found that copying the CUDA-related commands from the CMakeLists.txt file in the Ceres library resolved the issue.

Here's the content I copied:
···
option(USE_CUDA "Enable use of CUDA linear algebra solvers." ON)
if (USE_CUDA)
if (CMAKE_VERSION VERSION_LESS 3.17)
# On older versions of CMake (20.04 default is 3.16) FindCUDAToolkit was
# not available, but FindCUDA was deprecated. To avoid special-case handling
# elsewhere, emulate the effects of FindCUDAToolkit locally in terms of the
# expected CMake imported targets and defined variables. This can be removed
# from as soon as the min CMake version is >= 3.17.
find_package(CUDA QUIET)
if (CUDA_FOUND)
message("-- Found CUDA version ${CUDA_VERSION} installed in: "
"${CUDA_TOOLKIT_ROOT_DIR} via legacy (< 3.17) CMake module. "
"Using the legacy CMake module means that any installation of "
"Ceres will require that the CUDA libraries be installed in a "
"location included in the LD_LIBRARY_PATH.")
enable_language(CUDA)

  macro(DECLARE_IMPORTED_CUDA_TARGET COMPONENT)
    add_library(CUDA::${COMPONENT} INTERFACE IMPORTED)
    target_include_directories(
      CUDA::${COMPONENT} INTERFACE ${CUDA_INCLUDE_DIRS})
    target_link_libraries(
      CUDA::${COMPONENT} INTERFACE ${CUDA_${COMPONENT}_LIBRARY} ${ARGN})
  endmacro()

  declare_imported_cuda_target(cublas)
  declare_imported_cuda_target(cusolver)
  declare_imported_cuda_target(cusparse)
  declare_imported_cuda_target(cudart ${CUDA_LIBRARIES})

  set(CUDAToolkit_BIN_DIR ${CUDA_TOOLKIT_ROOT_DIR}/bin)

else (CUDA_FOUND)
  message("-- Did not find CUDA, disabling CUDA support.")
  update_cache_variable(USE_CUDA OFF)
endif (CUDA_FOUND)

else (CMAKE_VERSION VERSION_LESS 3.17)
find_package(CUDAToolkit QUIET)
if (CUDAToolkit_FOUND)
message("-- Found CUDA version ${CUDAToolkit_VERSION} installed in: "
"${CUDAToolkit_TARGET_DIR}")
set(CUDAToolkit_DEPENDENCY
"find_dependency(CUDAToolkit ${CUDAToolkit_VERSION})")
enable_language(CUDA)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
# Support Maxwell, Pascal, Volta, Turing, and Ampere GPUs.
set(CMAKE_CUDA_ARCHITECTURES "50;60;70;80")
message("-- Setting CUDA Architecture to ${CMAKE_CUDA_ARCHITECTURES}")
endif()
list(APPEND CERES_CUDA_LIBRARIES
CUDA::cublas
CUDA::cudart
CUDA::cusolver
CUDA::cusparse)
set(CMAKE_CUDA_RUNTIME_LIBRARY NONE)
else (CUDAToolkit_FOUND)
message("-- Did not find CUDA, disabling CUDA support.")
update_cache_variable(USE_CUDA OFF)
endif (CUDAToolkit_FOUND)
endif (CMAKE_VERSION VERSION_LESS 3.17)
endif (USE_CUDA)

@MoMansa
Copy link

MoMansa commented May 31, 2024

where did you copy the commend line in the Ceres library ?

@mz7790
Copy link

mz7790 commented Jun 1, 2024

where did you copy the commend line in the Ceres library ?
He is located in CMakeLists.txt under the Ceres solver root directory.
As shown in the following figure:
Snipaste_2024-06-01_16-01-29

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

No branches or pull requests

4 participants