You can use CUDA_GENERATION to specify the appropriate generation codename for your GPU architecture.
Here is the corresponding opencv cmake code that parses the value of CUDA_GENERATION :
set(__cuda_arch_ptx "") if(CUDA_GENERATION STREQUAL "Fermi") set(__cuda_arch_bin "2.0") elseif(CUDA_GENERATION STREQUAL "Kepler") set(__cuda_arch_bin "3.0 3.5 3.7") elseif(CUDA_GENERATION STREQUAL "Maxwell") set(__cuda_arch_bin "5.0 5.2") elseif(CUDA_GENERATION STREQUAL "Pascal") set(__cuda_arch_bin "6.0 6.1") elseif(CUDA_GENERATION STREQUAL "Volta") set(__cuda_arch_bin "7.0") elseif(CUDA_GENERATION STREQUAL "Auto") execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" ${CUDA_NVCC_FLAGS} "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/" RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT _nvcc_res EQUAL 0) message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.") else() set(__cuda_arch_bin "${_nvcc_out}") string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}") endif() endif()
And on the CUDA wikipedia page there is a table with a good ratio for comparing your video card with the correct microarchitecture name (sorry, it is too large to play here):
https://en.wikipedia.org/wiki/CUDA#GPUs_supported
For example, my mid-term 2012 Macbook Pro has an antique GeForce GT 650M, which in the wikipedia table points to Kepler's microarchitecture. Therefore, I use this on my cmake command line:
cmake -D CUDA_GENERATION="Kepler" ...
and the opencv script converts it to "3.0 3.5 3.7" when it displays the configuration summary and passes the corresponding nvcc flags.
In my case, before setting this correctly, I was getting errors in compute_70 that were not supported. Apparently, there is still an open problem in opencv tracker today (2017-10-07) that automatic detection does not work properly.
rob3c Oct 08 '17 at 3:27 2017-10-08 03:27
source share