System information (version)
- OpenCV => recent master ( ff99218 )
- Operating System / Platform => Ubuntu 18.04 (Aarch64) Jetson Xavier
- Compiler => GCC 7.5.0
- CUDA => 10.0
- CMake => 3.10.2
Detailed description
#17745 always adds /usr/bin/cc when detecting CC automatically, which fails
-- CUDA detected: 10.0
CMake Warning at cmake/OpenCVDetectCUDA.cmake:191 (message):
COMMAND:
/usr/local/cuda-10.0/bin/nvcc;-ccbin;/usr/bin/cc;/mnt/sd/opencv-fork/cmake/checks/OpenCVDetectCudaArch.cu;--run
Call Stack (most recent call first):
cmake/OpenCVDetectCUDA.cmake:243 (ocv_detect_native_cuda_arch)
cmake/OpenCVFindLibsPerf.cmake:43 (include)
CMakeLists.txt:688 (include)
-- Result: 1
-- Out:
-- Err:
-- Automatic detection of CUDA generation failed. Going to build for all known architectures.
I can trace back the cause to here
|
elseif(CUDA_HOST_COMPILER AND EXISTS "${CUDA_HOST_COMPILER}") |
|
LIST(APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${CUDA_HOST_COMPILER}") |
Now, of course, I didn't specify CUDA_HOST_COMPILER variable by myself.
NOT in environment variable, NOR in cmake options or any other places.
It comes from CMake find modules.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC")
else()
if(APPLE
AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang"
AND "${CMAKE_C_COMPILER}" MATCHES "/cc$")
# Using cc which is symlink to clang may let NVCC think it is GCC and issue
# unhandled -dumpspecs option to clang. Also in case neither
# CMAKE_C_COMPILER is defined (project does not use C language) nor
# CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let
# nvcc use its own default C compiler.
# Only care about this on APPLE with clang to avoid
# following symlinks to things like ccache
if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER)
get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH)
# if the real path does not end up being clang then
# go back to using CMAKE_C_COMPILER
if(NOT "${c_compiler_realpath}" MATCHES "/clang$")
set(c_compiler_realpath "${CMAKE_C_COMPILER}")
endif()
else()
set(c_compiler_realpath "")
endif()
set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC")
else()
set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" <=========== This lines always get hit on Jetson
CACHE FILEPATH "Host side compiler used by NVCC")
endif()
endif()
Looking at the comments, I guess that this is not desired behavior by @alalek in #17745
I'll send a PR of my solution shortly.
Steps to reproduce
time cmake -DOPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib/modules -DBUILD_EXAMPLES=true -DOPENCV_ENABLE_NONFREE=true -DWITH_CUDA=ON -DOPENCV_CMAKE_CUDA_DEBUG=1 ..
Issue submission checklist
System information (version)
Detailed description
#17745 always adds
/usr/bin/ccwhen detecting CC automatically, which failsI can trace back the cause to here
opencv/cmake/OpenCVDetectCUDA.cmake
Lines 118 to 119 in 8bf1b9a
Now, of course, I didn't specify
CUDA_HOST_COMPILERvariable by myself.NOT in environment variable, NOR in cmake options or any other places.
It comes from CMake find modules.
Looking at the comments, I guess that this is not desired behavior by @alalek in #17745
I'll send a PR of my solution shortly.
Steps to reproduce
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution