diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake index 1db3494e3ed..5c02fac0a32 100644 --- a/3rdparty/find_dependencies.cmake +++ b/3rdparty/find_dependencies.cmake @@ -1782,16 +1782,30 @@ if(BUILD_CUDA_MODULE) CUDA::culibos ) else() - # In CUDA12.0 the liblapack_static.a is deprecated and removed. + # In CUDA 12.0 the liblapack_static.a is deprecated and removed. # Use the libcusolver_lapack_static.a instead. - target_link_libraries(3rdparty_cublas INTERFACE - CUDA::cusolver_static - ${CUDAToolkit_LIBRARY_DIR}/libcusolver_lapack_static.a - CUDA::cusparse_static - CUDA::cublas_static - CUDA::cublasLt_static - CUDA::culibos - ) + # Use of static libraries is preferred. + if(BUILD_WITH_CUDA_STATIC) + # Use static CUDA libraries. + target_link_libraries(3rdparty_cublas INTERFACE + CUDA::cusolver_static + ${CUDAToolkit_LIBRARY_DIR}/libcusolver_lapack_static.a + CUDA::cusparse_static + CUDA::cublas_static + CUDA::cublasLt_static + CUDA::culibos + ) + else() + # Use shared CUDA libraries. + target_link_libraries(3rdparty_cublas INTERFACE + CUDA::cusolver + ${CUDAToolkit_LIBRARY_DIR}/libcusolver.so + CUDA::cusparse + CUDA::cublas + CUDA::cublasLt + CUDA::culibos + ) + endif() endif() if(NOT BUILD_SHARED_LIBS) # Listed in ${CMAKE_INSTALL_PREFIX}/lib/cmake/Open3D/Open3DTargets.cmake. @@ -1818,16 +1832,34 @@ if (BUILD_CUDA_MODULE) CUDA::nppial ) else() - open3d_find_package_3rdparty_library(3rdparty_cuda_npp - REQUIRED - PACKAGE CUDAToolkit - TARGETS CUDA::nppc_static - CUDA::nppicc_static - CUDA::nppif_static - CUDA::nppig_static - CUDA::nppim_static - CUDA::nppial_static - ) + if(BUILD_WITH_CUDA_STATIC) + # Use static CUDA libraries. + open3d_find_package_3rdparty_library(3rdparty_cuda_npp + REQUIRED + PACKAGE CUDAToolkit + TARGETS CUDA::nppc_static + CUDA::nppicc_static + CUDA::nppif_static + CUDA::nppig_static + CUDA::nppim_static + CUDA::nppial_static + ) + else() + # Use shared CUDA libraries. + open3d_find_package_3rdparty_library(3rdparty_cuda_npp + REQUIRED + PACKAGE CUDAToolkit + TARGETS CUDA::nppc + CUDA::nppicc + CUDA::nppif + CUDA::nppig + CUDA::nppim + CUDA::nppial + ) + endif() + endif() + if(NOT 3rdparty_cuda_npp_FOUND) + message(FATAL_ERROR "CUDA NPP libraries not found.") endif() list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_SYSTEM Open3D::3rdparty_cuda_npp) endif () diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e4781e7e72..f7fc2b3eb5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(BUILD_UNIT_TESTS "Build Open3D unit tests" OFF option(BUILD_BENCHMARKS "Build the micro benchmarks" OFF) option(BUILD_PYTHON_MODULE "Build the python module" ON ) option(BUILD_CUDA_MODULE "Build the CUDA module" OFF) +option(BUILD_WITH_CUDA_STATIC "Build with static CUDA libraries" ON ) option(BUILD_COMMON_CUDA_ARCHS "Build for common CUDA GPUs (for release)" OFF) if (WIN32) # Causes CUDA runtime error on Windows (See issue #6555) option(ENABLE_CACHED_CUDA_MANAGER "Enable cached CUDA memory manager" OFF)