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

Cmake Error about CUDA::cublas #1

Closed
Pradur241 opened this issue Oct 24, 2023 · 6 comments
Closed

Cmake Error about CUDA::cublas #1

Pradur241 opened this issue Oct 24, 2023 · 6 comments

Comments

@Pradur241
Copy link

请问我在编译的时候提示了这些错误,有什么解决办法吗?

OS: Ubuntu 20.04.6 LTS x86_64 
Kernel: 5.15.0-86-generic 
CPU: 12th Gen Intel i7-12800HX (24)  
GPU: NVIDIA RTX 3080Ti
Memory: 3379MiB / 31855MiB 
OpenCV: 4.2.0
Ceres: 1.4.0
Cuda: 11.7
-- +++ processing catkin package: 'aliengoZ1_description'
-- ==> add_subdirectory(OCL-RPF/unitree_ros/robots/aliengoZ1_description)
WARNING: Package name "aliengoZ1_description" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits, underscores, and dashes.
-- +++ processing catkin package: 'z1_description'
-- ==> add_subdirectory(OCL-RPF/unitree_ros/robots/z1_description)
-- Configuring done
CMake Error at OCL-RPF/mono_tracking/CMakeLists.txt:88 (add_executable):
  Target "mono_tracking_node" links to target "CUDA::cublas" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?


CMake Error at OCL-RPF/mono_tracking/CMakeLists.txt:88 (add_executable):
  Target "mono_tracking_node" links to target "CUDA::cudart" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?


CMake Error at OCL-RPF/mono_tracking/CMakeLists.txt:88 (add_executable):
  Target "mono_tracking_node" links to target "CUDA::cusolver" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?


CMake Error at OCL-RPF/mono_tracking/CMakeLists.txt:88 (add_executable):
  Target "mono_tracking_node" links to target "CUDA::cusparse" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
@yaoluoge
Copy link

l have the same problem!!

@yaoluoge
Copy link

Did you overcome it?

@Pradur241
Copy link
Author

no, I gave it up @yaoluoge

@yaoluoge
Copy link

yaoluoge commented May 6, 2024

maybe l should looking for other ways @Pradur241

@yaoluoge
Copy link

yaoluoge commented May 6, 2024

l got it! maybe you can try it with my cmakelists.`cmake_minimum_required(VERSION 3.16)
project(ceres_test_0)
add_compile_options(-std=c++14)
find_package(Ceres REQUIRED)
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(CERES_CUDA_TARGET_SUFFIX "")
  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()

  if (USE_CUDA STREQUAL "static")
    set(CERES_CUDA_TARGET_SUFFIX "_static")
  else (USE_CUDA STREQUAL "static")
    set(CERES_CUDA_TARGET_SUFFIX "")
  endif (USE_CUDA STREQUAL "static")
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)

if (USE_CUDA)
list(APPEND CERES_CUDA_LIBRARIES
CUDA::cublas${CERES_CUDA_TARGET_SUFFIX}
CUDA::cudart${CERES_CUDA_TARGET_SUFFIX}
CUDA::cusolver${CERES_CUDA_TARGET_SUFFIX}
CUDA::cusparse${CERES_CUDA_TARGET_SUFFIX})
unset (CERES_CUDA_TARGET_SUFFIX)
set(CMAKE_CUDA_RUNTIME_LIBRARY NONE)
else (USE_CUDA)
message("-- Building without CUDA.")
list(APPEND CERES_COMPILE_OPTIONS CERES_NO_CUDA)
endif (USE_CUDA)
add_executable(ceres_test_0 ceres_test.cpp)
target_link_libraries(ceres_test_0 Ceres::ceres)` @Pradur241

@Pradur241
Copy link
Author

@yaoluoge Thanks a lot!! Nice job!

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

3 participants