Im use CMake to generate visual studio 2013 solution. Next im try to build it, but get follow error:
Building NVCC (Device) object modules/core/CMakeFile
You can use CUDA_GENERATION to specify the corresponding generation code name for your GPU architecture.
Here's the relevant opencv cmake code that parses the CUDA_GENERATION value:
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 the wikipedia CUDA page has a nice table for mapping your video card to the right microarchitecture code name (sorry, it's too large to reproduce here):
https://en.wikipedia.org/wiki/CUDA#GPUs_supported
For example, my middling-2012 Macbook Pro has an antique GeForce GT 650M, which the wikipedia table indicates uses the Kepler microarchitecture. Therefore, I use this in my cmake command line:
cmake -D CUDA_GENERATION="Kepler" ...
and the opencv script converts that to "3.0 3.5 3.7" when it displays the config summary, and passes on the corresponding flags to nvcc.
In my case, before setting this properly, I was getting errors about compute_70 not supported. Apparently, there is still an open issue in the opencv tracker as of today (2017-10-07) about auto-detection not working properly.