opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.38k stars 5.75k forks source link

compilation error in cross compilation of opencv 4.2.0 using cuda 11.7 #3318

Open jimurk opened 2 years ago

jimurk commented 2 years ago

system information: operating system: ubuntu 18.04 gcc 4.9 CUDA 11.7 opencv 4.2.0 cross compilation for nvidia agx orin

I am compiling opencv 4.2.0 for nvidia orin. The compilation failed as following:

[INFO 20220805:092856]Running on linux-x86_64 platform
[WARNING 20220805:092856]Project name is not specified, so using -- opencv
[WARNING 20220805:092856]Project version is not specified, so using -- v0.0.1
[INFO 20220805:092856]Cuda toolkit found: /usr/local/cuda-11.7
CMake Warning at /usr/local/share/cmake-3.16/Modules/FindCUDA.cmake:900 (message):
  Expecting to find librt for libcudart_static, but didn't find it.
Call Stack (most recent call first):
  target/make/linux-aarch64_cuda11_7-gcc-4.9-stdc++/hpcc-common.cmake:226 (find_package)
  CMakeLists.txt:4 (include)

OPENCV_EXTRA_MODULES_PATH=/home/orin/opencv/opencv_contrib/modules
-- Detected processor: aarch64
-- Looking for ccache - not found
-- FP16 is not supported by C++ compiler
-- Optimization FP16 is not available, skipped
-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) (Required is at least version "1.2.3")
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) 
-- libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-4.2.0-libjpeg-turbo
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) 
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- Could NOT find ZLIB (missing: ZLIB_INCLUDE_DIR) (found version "1.2.11")
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 
-- math lib 'libm' not found; floating point support disabled
CMake Warning at /usr/local/share/cmake-3.16/Modules/FindCUDA.cmake:900 (message):
  Expecting to find librt for libcudart_static, but didn't find it.
Call Stack (most recent call first):
  opencv-4.2.0/cmake/OpenCVUtils.cmake:131 (find_package)
  opencv-4.2.0/cmake/OpenCVDetectCUDA.cmake:16 (find_host_package)
  opencv-4.2.0/cmake/OpenCVFindLibsPerf.cmake:33 (include)
  opencv-4.2.0/CMakeLists.txt:677 (include)

-- Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (Required is at least version "7.5")
-- CUDA detected: 11.7
-- Automatic detection of CUDA generation failed. Going to build for all known architectures.
-- CUDA NVCC target flags: -std=c++11   -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_
50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62 -gencode arc
h=compute_70,code=sm_70 -gencode arch=compute_72,code=sm_72 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -g
encode arch=compute_86,code=sm_86 -Xcompiler=-fPIC,-Wall,-fvisibility=hidden;-gencode;arch=compute_53,code=sm_53;-gencode;arch=compute
_62,code=sm_62;-gencode;arch=compute_72,code=sm_72;-D_FORCE_INLINES
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPAC
K_LIBRARY) 
-- Could NOT find BLAS (missing: BLAS_LIBRARIES) 
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
-- OpenCV Python: during development append to PYTHONPATH: /home/orin/opencv/target/make/linux-aarch64_cuda11_7-gcc-4.9-stdc++/R
elease/python_loader
-- Caffe:   NO
-- Protobuf:   NO
-- Glog:   NO
-- freetype2:   NO
-- harfbuzz:    NO
-- Module opencv_ovis disabled because OGRE3D was not found
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting
 to preferring an installed/exported gflags CMake configuration if available.
-- Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
-- Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gfla
gs components.
-- Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
-- Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
-- Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.ssse3.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_1.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.sse4_2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.fp16.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx512_skx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx512_skx.cpp
-- Excluding from source files list: <BUILD>/modules/core/test/test_intrin512.avx512_skx.cpp
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/orin/opencv/opencv-4.2.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES
_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- 
-- General configuration for OpenCV 4.2.0 =====================================
--   Version control:               dbe30d7-dirty
-- 
--   Extra modules:
--     Location (extra):            /home/orin/opencv/opencv_contrib/modules
--     Version control (extra):     dbe30d7-dirty
-- 
--   Platform:
--     Timestamp:                   2022-08-04T12:03:36Z
--     Host:                        Linux 5.0.0-32-generic x86_64
--     Target:                      Linux aarch64
--     CMake:                       3.16.0-rc2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    NEON
--       requested:                 NEON FP16
--       required:                  NEON
--       disabled:                  VFPV3
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /opt/toolchains/linux-toolchain-aarch64/bin/aarch64-linux-gnu-g++  (ver 4.9.4)
--     C++ flags (Release):         -std=c++11 -fPIC -fvisibility=hidden -Wall -pthread -fno-strict-aliasing -ftemplate-depth=2014 -ft
ree-vectorize -flax-vector-conversions   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=s
equence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wsign-promo -Wuninitialized
 -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -pthread -fomit-frame
-pointer -ffunction-sections -fdata-sections   -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -std=c++11 -fPIC -fvisibility=hidden -Wall -pthread -fno-strict-aliasing -ftemplate-depth=2014 -ft
ree-vectorize -flax-vector-conversions   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=s
equence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wsign-promo -Wuninitialized
 -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -pthread -fomit-frame
-pointer -ffunction-sections -fdata-sections   -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /opt/toolchains/linux-toolchain-aarch64/bin/aarch64-linux-gnu-gcc-4.9.4
--     C flags (Release):           -fPIC -fvisibility=hidden -Wall -pthread -fno-strict-aliasing -ftree-vectorize -flax-vector-conver
sions   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=fo
rmat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wuninitialized -Win
it-self -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdat
a-sections   -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fPIC -fvisibility=hidden -Wall -pthread -fno-strict-aliasing -ftree-vectorize -flax-vector-conver
sions   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=fo
rmat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wuninitialized -Win
it-self -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdat
a-sections   -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--gc-sections  
--     Linker flags (Debug):        -Wl,--gc-sections  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          m rt cudart_static pthread dl CUDA_nppc_LIBRARY-NOTFOUND CUDA_nppial_LIBRARY-NOTFOUND CUDA_nppicc_
LIBRARY-NOTFOUND CUDA_nppidei_LIBRARY-NOTFOUND CUDA_nppif_LIBRARY-NOTFOUND CUDA_nppig_LIBRARY-NOTFOUND CUDA_nppim_LIBRARY-NOTFOUND CUD
A_nppist_LIBRARY-NOTFOUND CUDA_nppisu_LIBRARY-NOTFOUND CUDA_nppitc_LIBRARY-NOTFOUND CUDA_npps_LIBRARY-NOTFOUND CUDA_cublas_LIBRARY-NOT
FOUND CUDA_cufft_LIBRARY-NOTFOUND -L/usr/local/cuda-11.7/targets/aarch64-linux/lib
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafi
lters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face f
eatures2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwra
pping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts vi
deo videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cnn_3dobj cvv freetype hdf java js matlab ovis python2 python3 sfm viz
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        NO
-- 
--   Media I/O: 
--     ZLib:                        build (ver 1.2.11)
--     JPEG:                        libjpeg-turbo (ver 2.0.2-62)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.0.10)
--     JPEG 2000:                   build (ver 1.900.1)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Lapack:                      NO
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
-- 
--   NVIDIA CUDA:                   YES (ver 11.7, CUFFT CUBLAS)
--     NVIDIA GPU arch:             53 62 72
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         NO
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/orin/opencv/opencv-4.2.0/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Install to:                    /home/orin/opencv/install
-- 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cublas_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_test_core" in directory /home/orin/opencv/opencv-4.2.0/modules/core
    ...
CUDA_cufft_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_test_core" in directory /home/orin/opencv/opencv-4.2.0/modules/core
    ...
CUDA_nppc_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppial_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppicc_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppidei_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppif_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppig_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppim_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppist_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppisu_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_nppitc_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
CUDA_npps_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    linked by target "opencv_cudev" in directory /home/orin/opencv/opencv_contrib/modules/cudev
    ...
asmorkalov commented 2 years ago

opencv 4.2.0 - it's too old I believe. Please try modern version

FLeblanc-OTI commented 1 year ago

opencv 4.2.0

Works with OpenCV 4.5.3 and Orin (jetpack 5.0.2)

asmorkalov commented 1 year ago

OpenCV 4.2 is too old version. OpenCV team does not support so old releases. Please use 4.7, it works well with CUDA up to 12.