본문 바로가기
개발 이야기/머신러닝, 딥러닝

[문제해결] OpenCV 4.5.3 우분투 빌드 결과 몇 가지 오류 발견 및 해결 방법 - 1

by AI 동키 2021. 8. 10.
반응형

Ubunto 20.04 WSL2 환경에서

CUDA 11.4, cuDNN8.2.2, OpenCV4.5.3 환경을 구축하고 있다.

OpenCV 빌드 결과 몇가지 오류가 발견되어 오류를 파악하고 해결한 방법을 남긴다. 

 

빌드는 다음과 같이 진행했으니 참고 바란다.

[문제해결] OpenCV 4.5.3 리눅스 빌드 중 cmake 오류

 

[문제해결] OpenCV 4.5.3 리눅스 빌드 중 cmake 오류_No source or binary directory provided. Both will be assumed to be

문제 Linux 환경에 OpenCV 설치 중, 다운로드, 관련 패키지 설치 등을 끝마치고 cmake 빌드 시 오류 발생 타 블로그와 같이 아래와 같이 입력했으나, 오류 발생 cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INS..

lapina.tistory.com

 

빌드는 성공적으로 되었지만 그 안에 여러가지 오류가 발생했다. 이 대로 진행해도 될것인가, 안될 것인가?!

일단 개선할 수 있는 부분을 개선한 후 설치를 진행해 보겠다.

-- Detected processor: x86_64
-- Found PythonInterp: /home/heeungs/anaconda3/bin/python3 (found suitable version "3.8.8", minimum required is "2.7")
-- Looking for ccache - not found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3")
Cleaning INTERNAL cached variable: WEBP_LIBRARY
Cleaning INTERNAL cached variable: WEBP_INCLUDE_DIR
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.4.0, BUILD = opencv-4.5.3-openjp2-2.4.0
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.4.0")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- libva: missing va.h header (VA_INCLUDE_DIR)
-- found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
-- at: /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/build/3rdparty/ippicv/ippicv_lnx/icv
-- found Intel IPP Integration Wrappers sources: 2020.0.0
-- at: /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/build/3rdparty/ippicv/ippicv_lnx/iw
-- CUDA detected: 11.4
-- CUDA: Using CUDA_ARCH_BIN=8.6
-- CUDA NVCC target flags: -gencode;arch=compute_86,code=sm_86;-D_FORCE_INLINES;-gencode;arch=compute_86,code=compute_86
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
-- A library with LAPACK API found.
-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Checking for module 'libavresample'
--   No package 'libavresample' found
-- Checking for module 'libdc1394-2'
--   No package 'libdc1394-2' found
-- Performing Test HAVE_CXX_WNO_UNUSED_VARIABLE
-- Performing Test HAVE_CXX_WNO_UNUSED_VARIABLE - Success
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE - Success
-- Checking for module 'freetype2'
--   Found freetype2, version 23.1.17
-- Checking for module 'harfbuzz'
--   Found harfbuzz, version 2.6.4
-- freetype2:   YES (ver 23.1.17)
-- harfbuzz:    YES (ver 2.6.4)
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Found HDF5: /home/heeungs/anaconda3/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/librt.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/home/heeungs/anaconda3/lib/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.4")
-- Julia not found. Not compiling Julia Bindings.
-- 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 gflags 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: Glog/Gflags
-- Checking for module 'tesseract'
--   No package 'tesseract' found
-- Tesseract:   NO
-- Allocator metrics storage type: 'long long'
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE - Success
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL - Success
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- wechat_qrcode: Download: detect.caffemodel
-- wechat_qrcode: Download: detect.prototxt
-- wechat_qrcode: Download: sr.caffemodel
-- wechat_qrcode: Download: sr.prototxt
-- highgui: using builtin backend: GTK3
-- xfeatures2d/boostdesc: Download: boostdesc_bgm.i
-- xfeatures2d/boostdesc: Download: boostdesc_bgm_bi.i
-- xfeatures2d/boostdesc: Download: boostdesc_bgm_hd.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_064.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_128.i
-- xfeatures2d/boostdesc: Download: boostdesc_binboost_256.i
-- xfeatures2d/boostdesc: Download: boostdesc_lbgm.i
-- xfeatures2d/vgg: Download: vgg_generated_48.i
-- xfeatures2d/vgg: Download: vgg_generated_64.i
-- xfeatures2d/vgg: Download: vgg_generated_80.i
-- xfeatures2d/vgg: Download: vgg_generated_120.i
-- data: Download: face_landmark_model.dat
-- NVIDIA_OPTICAL_FLOW: Download: edb50da3cf849840d680249aa6dbef248ebce2ca.zip
-- Building with NVIDIA Optical Flow API 2.0
-- Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD
-- Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD - Failed
-- OpenCL samples are skipped: OpenCL SDK is required
-- SYCL/OpenCL samples are skipped: SYCL SDK is required
--    - check configuration of SYCL_DIR/SYCL_ROOT/CMAKE_MODULE_PATH
--    - ensure that right compiler is selected from SYCL SDK (e.g, clang++): CMAKE_CXX_COMPILER=/usr/bin/c++
-- Registered 'check_pylint' target: using /home/heeungs/anaconda3/bin/pylint (ver: 2.7.4), checks: 186
-- Registered 'check_flake8' target: using /home/heeungs/anaconda3/bin/flake8 (ver: 3.9.0)
--

 

오류들 모음

-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off

-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off

<TRY> 

OpenBLAS 설치 https://github.com/opencv/opencv/issues/12957

OpenBLAS를 설치하고 opencv/cmake/OpenCVFindOpenBLAS.cmake 에 경로를 추가해줌

다시 빌드한 결과 해결!!

-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)

<TRY>

1. 패키지 설치

$ sudo apt-get install libatlas-base-dev

(base) heeungs@DESKTOP-AA6H6V8:~/opencv-sources/opencv453/opencv-4.5.3/cmake$ ldconfig -p | grep atlas
        liblapack_atlas.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/liblapack_atlas.so.3
        liblapack_atlas.so (libc6,x86-64) => /lib/x86_64-linux-gnu/liblapack_atlas.so
        libatlas.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libatlas.so.3
        libatlas.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libatlas.so

2. 마찬가지로 opncv/cmake/OpenCVFindAtlas.cmake 파일에 경로를 수정해줌.

다시 빌드한 결과 해결!!

 

-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)

<TRY>

sudo apt-get install -y openjdk-8-jdk

sudo apt-get install -y default-jdk

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

다시 빌드한 결과 해결!!

 

-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file

-- Checking for module 'libavresample'

--   No package 'libavresample' found

-- Checking for module 'libdc1394-2'

--   No package 'libdc1394-2' found

-- Julia not found. Not compiling Julia Bindings.

-- Module opencv_ovis disabled because OGRE3D was not found

-- 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 gflags 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

--   No package 'tesseract' found

-- Tesseract:   NO

-- Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD - Failed

 

 

-- General configuration for OpenCV 4.5.3 =====================================
--   Version control:               unknown
--
--   Extra modules:
--     Location (extra):            /home/heeungs/opencv-sources/opencv453/opencv_contrib-4.5.3/modules
--     Version control (extra):     unknown
--
--   Platform:
--     Timestamp:                   2021-08-10T04:32:17Z
--     Host:                        Linux 5.10.16.3-microsoft-standard-WSL2 x86_64
--     CMake:                       3.16.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (17 files):         + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (31 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (7 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 9.3.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed
--     Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-11.4/lib64 -L/usr/lib/x86_64-linux-gnu
--     3rdparty dependencies:
--
--   OpenCV modules:
--     To be built:                 alphamat aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cvv java julia matlab ovis python2 sfm viz
--     Applications:                tests perf_tests examples apps
--     Documentation:               NO
--     Non-free algorithms:         YES
--
--   GUI:
--     GTK+:                        YES (ver 3.24.20)
--       GThread :                  YES (ver 2.64.6)
--       GtkGlExt:                  NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     OpenEXR:                     build (ver 2.3.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
--
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (58.54.100)
--       avformat:                  YES (58.29.100)
--       avutil:                    YES (56.31.100)
--       swscale:                   YES (5.5.100)
--       avresample:                NO
--     GStreamer:                   YES (1.16.2)
--     v4l/v4l2:                    YES (linux/videodev2.h)
--
--   Parallel framework:            pthreads
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/build/3rdparty/ippicv/ippicv_lnx/iw
--     VA:                          NO
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.3.7)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
--
--   NVIDIA CUDA:                   YES (ver 11.4, CUFFT CUBLAS FAST_MATH)
--     NVIDIA GPU arch:             86
--     NVIDIA PTX archs:            86
--
--   cuDNN:                         YES (ver 8.2)
--
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python 3:
--     Interpreter:                 /home/heeungs/anaconda3/bin/python3 (ver 3.8.8)
--     Libraries:                   /home/heeungs/anaconda3/lib/libpython3.8.so (ver 3.8.8)
--     numpy:                       /home/heeungs/anaconda3/lib/python3.8/site-packages/numpy/core/include (ver 1.20.1)
--     install path:                /home/heeungs/anaconda3/lib/python3.8/site-packages
--
--   Python (for build):            /home/heeungs/anaconda3/bin/python3
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/heeungs/opencv-sources/opencv453/opencv-4.5.3/build

 

 

TRY

설치 전 패키지들을 빠짐없이 다시 설치 확인

$ sudo apt-get install build-essential cmake git pkg-config dkms

$ sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev

$ sudo apt-get install ubuntu-restricted-extras

$ sudo apt-get install libjpeg-dev libtiff5 libjasper-dev libpng-dev

$ sudo apt-get install libavcodec-dev ffmpeg libavformat-dev libswscale-dev libv4l-dev v4l-utils

$ sudo apt-get install libxvidcore-dev libx264-dev libxine2-dev

$ sudo apt-get install libgtk-3-dev

$ sudo apt-get install libatlas-base-dev gfortran

$ sudo apt-get install mesa-utils libgl1-mesa-dri libgtkgl2.0-dev libgtkglext1-dev

 

 

내용이 길어지는 관계로 다음 글에서 계속 이어가겠습니다.

 

반응형

댓글