Fails to build with CUDA enabled

System information (version)
  • OpenCV => 4.3.0-527-ga711e2aa41 (master latest)
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2019
Detailed description

Have cloned latest master branch, as well as opencv-contrib master branch to separate folders.
Cuda version: 11.0RC (latest)

Build fails with an error:

Building NVCC (Device) object modules/world/CMakeFiles/cuda_compile_1.dir/__/core/src/cuda/Release/cuda_compile_1_generated_gpu_mat.cu.obj
nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified
CMake Error at cuda_compile_1_generated_gpu_mat.cu.obj.Release.cmake:220 (message):
Error generating
D:/_UTILS/_deps/opencv_build/modules/world/CMakeFiles/cuda_compile_1.dir/__/core/src/cuda/Release/cuda_compile_1_generated_gpu_mat.cu.obj

The same exact building process worked fine with opencv-4.2.0 and cuda 10.2

Steps to reproduce
  1. Clone opencv and opencv-contrib from git
  2. init vars for MKL and TBB:
"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\tbb\bin\tbbvars.bat" intel64
"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\mkl\bin\mklvars.bat" intel64
  1. Cmake it:
cmake ..\opencv -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\opencv -DOPENCV_ENABLE_NONFREE:BOOL=ON -DOPENCV_EXTRA_MODULES_PATH=..\opencv_contrib\modules -DBUILD_opencv_python2:BOOL=OFF -DBUILD_opencv_python3:BOOL=ON -DWITH_NVCUVID=OFF -DWITH_CUDA=ON -DCUDA_FAST_MATH=ON -DWITH_CUBLAS=ON -DWITH_MKL=ON -DMKL_USE_MULTITHREAD=ON -DMKL_WITH_TBB=ON -DWITH_TBB=ON -DINSTALL_TESTS=OFF -DINSTALL_C_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DCUDNN_LIBRARY=C:\cudnn\lib\x64\cudnn.lib -DCUDNN_INCLUDE_DIR=C:\cudnn\include -DWITH_VTK=OFF -DBUILD_JAVA=OFF -DBUILD_opencv_java_bindings_generator=OFF -DBUILD_opencv_world=ON -DBUILD_opencv_gapi=OFF -DCUDA_ARCH_PTX=6.1 -DCUDA_ARCH_BIN=6.1
  1. Build with:
msbuild INSTALL.vcxproj -m -p:Configuration=Release
  1. It fails. 😲

Here’s the full console output:
opencv_build_fail_log.txt

Issue submission checklist
  • [v] I report the issue, it’s not a question
  • [v] I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution

  • [v] I updated to latest OpenCV version and the issue is still there
  • [v] There is reproducer code and related data files: videos, images, onnx, etc

1 possible answer(s) on “Fails to build with CUDA enabled