1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Merge pull request #28954 from ssam18:fix-cuda13-empty-arch-detection-28952

Fix CMake crash when CUDA arch autodetection comes up empty #28954

With CUDA 13 and a system gcc that the toolkit does not support, every NVCC probe inside ocv_filter_available_architecture fails and the result list ends up empty. The next line then calls list(GET ... -1) on that empty list, so CMake dies with the unhelpful message about list GET given empty list and the user has no obvious next step. This change replaces that path with a fatal error that points at the three real fixes, namely setting CUDA_ARCH_BIN, setting CUDA_HOST_COMPILER, or enabling OPENCV_CMAKE_CUDA_DEBUG to see what NVCC actually printed. It also forwards CMAKE_CUDA_HOST_COMPILER into CUDA_HOST_COMPILER since the issue reporter passed the standard CMake variable and it was being silently ignored.
Fixes #28952
This commit is contained in:
SamareshSingh
2026-05-14 07:43:59 -05:00
committed by GitHub
parent e9b4668bad
commit 4b031345f0
2 changed files with 7 additions and 0 deletions
+4
View File
@@ -14,6 +14,10 @@ if(CUDA_TOOLKIT_ROOT_DIR)
set(CUDA_TOOLKIT_TARGET_DIR ${CUDA_TOOLKIT_ROOT_DIR})
endif()
if(CMAKE_CUDA_HOST_COMPILER AND NOT CUDA_HOST_COMPILER)
set(CUDA_HOST_COMPILER "${CMAKE_CUDA_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC")
endif()
if(((NOT CMAKE_VERSION VERSION_LESS "3.9.0") # requires https://gitlab.kitware.com/cmake/cmake/merge_requests/663
OR OPENCV_CUDA_FORCE_EXTERNAL_CMAKE_MODULE)
AND NOT OPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE)
+3
View File
@@ -300,6 +300,9 @@ macro(ocv_set_cuda_arch_bin_and_ptx nvcc_executable)
${_arch_hopper}
${_arch_blackwell}
)
if(NOT __cuda_arch_bin)
message(FATAL_ERROR "CUDA: No compatible CUDA architecture found. Please enable OPENCV_CMAKE_CUDA_DEBUG=1 for investigation.")
endif()
list(GET __cuda_arch_bin -1 __cuda_arch_ptx)
endif()
endif()