|
1 | | -cmake_minimum_required(VERSION 3.22) |
2 | | -# If you're using Ubuntu 18.04, we suggest you install the latest CMake from the |
| 1 | +cmake_minimum_required(VERSION 3.24) |
| 2 | +# If you're using Ubuntu 20.04, we suggest you install the latest CMake from the |
3 | 3 | # official repository https://apt.kitware.com/. |
| 4 | +# CMake 3.24+ is required for CUDA native arch selection |
4 | 5 | # CMake 3.22+ is required by Assimp v5.4.2 |
5 | 6 | # CMake 3.20+ is required to detect IntelLLVM compiler for SYCL |
6 | 7 |
|
@@ -401,17 +402,44 @@ cmake_language(EVAL CODE "cmake_language(DEFER CALL open3d_patch_findthreads_mod |
401 | 402 |
|
402 | 403 | # Build CUDA module by default if CUDA is available |
403 | 404 | if(BUILD_CUDA_MODULE) |
404 | | - include(Open3DMakeCudaArchitectures) |
405 | | - open3d_make_cuda_architectures(CUDA_ARCHS) |
406 | | - set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCHS}) |
407 | | - |
408 | | - message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}") |
| 405 | + if(BUILD_COMMON_CUDA_ARCHS) |
| 406 | + if (CMAKE_CUDA_ARCHITECTURES) |
| 407 | + message(STATUS "Building with user-provided architectures: ${CMAKE_CUDA_ARCHITECTURES}") |
| 408 | + else() |
| 409 | + # Build with all supported architectures for previous 2 generations and |
| 410 | + # M0 (minor=0) architectures for previous generations (including |
| 411 | + # deprecated). Note that cubin for M0 runs on GPUs with architecture Mx. |
| 412 | + # This is a tradeoff between binary size / build time and runtime on |
| 413 | + # older architectures. See: |
| 414 | + # https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html#building-for-maximum-compatibility |
| 415 | + # https://docs.nvidia.com/cuda/ampere-compatibility-guide/index.html#application-compatibility-on-ampere |
| 416 | + # https://en.wikipedia.org/wiki/CUDA#GPUs_supported |
| 417 | + find_package(CUDAToolkit REQUIRED) |
| 418 | + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.8") |
| 419 | + set(CMAKE_CUDA_ARCHITECTURES 75-real 80-real 86-real 89-real 90) # Turing, Ampere, Ada Lovelace, Hopper |
| 420 | + elseif(CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.1") |
| 421 | + set(CMAKE_CUDA_ARCHITECTURES 70-real 75-real 80-real 86) # Volta, Turing, Ampere |
| 422 | + elseif(CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.0") |
| 423 | + set(CMAKE_CUDA_ARCHITECTURES 60-real 70-real 72-real 75-real 80) # Pascal, Volta, Turing, Ampere |
| 424 | + else() |
| 425 | + set(CMAKE_CUDA_ARCHITECTURES 30-real 50-real 60-real 70-real 75) # Kepler, Maxwell, Pascal, Turing |
| 426 | + endif() |
| 427 | + message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}") |
| 428 | + endif() |
| 429 | + else() |
| 430 | + execute_process(COMMAND nvidia-smi RESULT_VARIABLE NVIDIA_CHECK OUTPUT_QUIET) |
| 431 | + if (NVIDIA_CHECK EQUAL 0) |
| 432 | + message(STATUS "Building with native CUDA architecture.") |
| 433 | + set(CMAKE_CUDA_ARCHITECTURES native) |
| 434 | + else() |
| 435 | + message(WARNING "No CUDA GPU detected. Building with CMake default CUDA architecture.") |
| 436 | + endif() |
| 437 | + endif() |
409 | 438 | enable_language(CUDA) |
410 | | - |
411 | 439 | if (CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "10.1") |
412 | 440 | message(FATAL_ERROR "CUDA 10.0 and older are not supported. Please upgrade to CUDA 10.1 or newer.") |
413 | 441 | endif() |
414 | | -endif () |
| 442 | +endif() |
415 | 443 |
|
416 | 444 | # ISPC language emulation support |
417 | 445 | include(Open3DISPC) |
@@ -488,6 +516,12 @@ macro(add_source_group module_name) |
488 | 516 | source_group("Source Files\\Material" FILES ${MODULE_MATERIAL_FILES}) |
489 | 517 | endmacro() |
490 | 518 |
|
| 519 | +if (LINUX_AARCH64) |
| 520 | +# Fix for ImportError: ... /pybind.cpython-310-aarch64-linux-gnu.so: cannot allocate memory in static TLS block |
| 521 | +# https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1889851 |
| 522 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftls-model=global-dynamic") |
| 523 | +endif() |
| 524 | + |
491 | 525 | # Include convenience functions |
492 | 526 | include(Open3DLink3rdpartyLibraries) |
493 | 527 | include(Open3DSetGlobalProperties) |
|
0 commit comments