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
When using cmake to do configurations, set the option CUDA_GENERATION to specific your GPU architecture. I ran across the same error and tried this to work out the problem.
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.
Following up on Yun's answer (could not leave comment), this worked for me and shows a possible value for CUDA_GENERATION:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..
(Ubuntu 12.04 and 14.04, GTX Titan, and OpenCV 2.4.11 and 3.0.0.)
You should set with cmake
these entries CUDA_ARCH_BIN = 3.2
and CUDA_ARCH_PTX = 3.2
Hope it helps.
Regards
Another option. Ubuntu 14.04, GTX Titan X, opencv-2.4.10
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_TIFF=ON -D BUILD_EXAMPLES=ON -D CUDA_GENERATION=Auto -D BUILD_NEW_PYTHON_SUPPORT=ON ..
I also applied the patch,
but I'm not sure whether it ended up being needed. I had tried with and withoutCUDA_GENERATION=Maxwell
but Maxwell isn't detected. I did not try CUDA_GENERATION=Auto
prior to the patch, that's why I don't know for sure.
Thank you,
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..
This let me install opencv-2.4.9.
If you want to know more detaills check this link.