Skip to content

Commit

Permalink
Build with CUDA >= 12.0 with dynamic libraries as well (#6815)
Browse files Browse the repository at this point in the history
* Added BUILD_WITH_CUDA_STATIC flag
  • Loading branch information
davconde authored Jul 25, 2024
1 parent 78e4bfd commit f02e7d2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
70 changes: 51 additions & 19 deletions 3rdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 ()
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f02e7d2

Please sign in to comment.