feichtenhofer / gpu_flow

GPU based optical flow extraction in OpenCV
431 stars 109 forks source link

Building with latest version of Cuda and OpenCv #14

Open kasparov92 opened 6 years ago

kasparov92 commented 6 years ago

Hello,

Have anyone build successfully this repo? it keeps giving me issues when building

Trial 1: Using Opencv3.4 (latest version to date) gave me an issue regarding the "gpu.h" library, and seems I cannot go with this version as there is not a branch or another code version using this opencv version

Trial 2: Using Opencv2.4. Well I have cuda 9, so it seems that this version of opencv does not compile with this version of cuda. I also tried to copy the findcuda and detectopencv files from latest version of Opencv, and I had also tried to modify some lines in those files, but all these tricks did not make it work.

So before going further and installing another cuda version and give another try, have anyone tried to build this successfully? and what version of opencv and cuda did you have?

Thanks in advance, Regards, Bassel Safwat

lfjdhr123 commented 5 years ago

Is there anyone who like to contribute the latest version?

Etang21 commented 5 years ago

@kasparov92 this is likely too late, but - for anyone reading - I did manage to build this repo with OpenCV 2.4.13 and CUDA 10.

To start, in order to use our GPU with OpenCV 2, we have to build OpenCV from source, using the WITH_CUDA=ON flag when we build OpenCV. Otherwise, OpenCV will seemingly build normally but throw CV_GpuNotSupported errors when we actually try to run it. This appears to be the error referenced in #11 and it is described in the OpenCV 2.4 docs here. Instructions for building OpenCV from source can be found here, and the source code for OpenCV 2.4 is somewhere in the OpenCV release archives.

Now we have to install OpenCV! As you mentioned, OpenCV 2.4 is not compatible with CUDA >= 9. This is because CUDA 9 split up the nppi library into several new libraries, and OpenCV 2.4 has trouble finding these new libraries. We have to modify some search paths in the OpenCV makefiles to help it find the new nppi* libraries. This is apparently a pretty well-known issue, and I found this blog post to be the best guide for solving it. This StackOverflow thread contains a similar set of instructions, though it's designed to fix the same issue in OpenCV 3.3.

If you've made it to this point, after editing the OpenCV files as described above and building OpenCV, you should have a working installation of OpenCV 2.4. After that, when building gpu_flow, the gpu_flow makefiles complained about not finding the new nppi* libraries and a few Qt libraries. I fixed those errors by finding those files and appending them to my CMAKE_PREFIX_PATH in the $cmake command. On my machine, my nppi* libraries were hanging out at /usr/local/cuda and my Qt libraries were installed locally at /vision/u/etang21/Qt5.4.2/5.4/gcc_64/lib/cmake/Qt5Widgets. Running cmake with $cmake -D CMAKE_PREFIX_PATH=/usr/local/cuda;/vision/u/etang21/Qt5.4.2/5.4/gcc_64/lib/cmake/Qt5Widgets .. did the trick for me. It looks like the thread in #5 may also be helpful for any errors you encounter here.

Hope this helps in any small way!

KomalBagai commented 3 years ago

I am trying to build OpenCV 2.4 with Cuda-10.2 which is installed on Jetson AGX Xavier. I have followed this blog post in order to change the files so that opencv is able to find all cuda libraries.

System information (version)

I am running the following command to generate cmake cache:

cmake -DCMAKE_INSTALL_PREFIX=~/lib/opencv_2.4/installed -DCMAKE_BUILD_TYPE="Release" -DWITH_CUDA=ON -DCUDA_GENERATION=Volta -D OPENCV_DNN_CUDA=ON -DCUDA_ARCH_BIN=7.5 -DCUDA_HOST_COMPILER=/usr/bin/gcc-8 -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ..

Cmake are generated as follows:

-- The CXX compiler identification is GNU 8.4.0
-- The C compiler identification is GNU 8.4.0
-- Check for working CXX compiler: /usr/bin/g++-8
-- Check for working CXX compiler: /usr/bin/g++-8 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/gcc-8
-- Check for working C compiler: /usr/bin/gcc-8 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Looking for ccache - not found
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Success
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test HAVE_C_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_WSHADOW
-- Performing Test HAVE_CXX_WSHADOW - Success
-- Performing Test HAVE_C_WSHADOW
-- Performing Test HAVE_C_WSHADOW - Success
-- Performing Test HAVE_CXX_WSIGN_PROMO
-- Performing Test HAVE_CXX_WSIGN_PROMO - Success
-- Performing Test HAVE_C_WSIGN_PROMO
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_CXX_WNO_NARROWING
-- Performing Test HAVE_CXX_WNO_NARROWING - Success
-- Performing Test HAVE_C_WNO_NARROWING
-- Performing Test HAVE_C_WNO_NARROWING - Success
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_CXX_WNO_COMMENT
-- Performing Test HAVE_CXX_WNO_COMMENT - Success
-- Performing Test HAVE_C_WNO_COMMENT
-- Performing Test HAVE_C_WNO_COMMENT - Success
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS - Success
-- Performing Test HAVE_C_WNO_ARRAY_BOUNDS
-- Performing Test HAVE_C_WNO_ARRAY_BOUNDS - Success
-- Performing Test HAVE_CXX_WNO_AGGRESSIVE_LOOP_OPTIMIZATIONS
-- Performing Test HAVE_CXX_WNO_AGGRESSIVE_LOOP_OPTIMIZATIONS - Success
-- Performing Test HAVE_C_WNO_AGGRESSIVE_LOOP_OPTIMIZATIONS
-- Performing Test HAVE_C_WNO_AGGRESSIVE_LOOP_OPTIMIZATIONS - Success
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_CXX_PTHREAD
-- Performing Test HAVE_CXX_PTHREAD - Success
-- Performing Test HAVE_C_PTHREAD
-- Performing Test HAVE_C_PTHREAD - Success
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_CXX_MFPU_NEON
-- Performing Test HAVE_CXX_MFPU_NEON - Failed
-- Performing Test HAVE_C_MFPU_NEON
-- Performing Test HAVE_C_MFPU_NEON - Failed
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_C_FFUNCTION_SECTIONS
-- Performing Test HAVE_C_FFUNCTION_SECTIONS - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11") 
-- Found TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (found version "4.0.9") 
-- Found JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so  
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
-- Performing Test HAVE_C_WNO_IMPLICIT_FUNCTION_DECLARATION
-- Performing Test HAVE_C_WNO_IMPLICIT_FUNCTION_DECLARATION - Success
-- Performing Test HAVE_C_WNO_UNINITIALIZED
-- Performing Test HAVE_C_WNO_UNINITIALIZED - Success
-- Performing Test HAVE_C_WNO_MISSING_PROTOTYPES
-- Performing Test HAVE_C_WNO_MISSING_PROTOTYPES - Success
-- Performing Test HAVE_C_WNO_UNUSED_BUT_SET_PARAMETER
-- Performing Test HAVE_C_WNO_UNUSED_BUT_SET_PARAMETER - Success
-- Performing Test HAVE_C_WNO_MISSING_DECLARATIONS
-- Performing Test HAVE_C_WNO_MISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WNO_UNUSED
-- Performing Test HAVE_C_WNO_UNUSED - Success
-- Performing Test HAVE_C_WNO_SHADOW
-- Performing Test HAVE_C_WNO_SHADOW - Success
-- Performing Test HAVE_C_WNO_SIGN_COMPARE
-- Performing Test HAVE_C_WNO_SIGN_COMPARE - Success
-- Performing Test HAVE_C_WNO_UNUSED_PARAMETER
-- Performing Test HAVE_C_WNO_UNUSED_PARAMETER - Success
-- Performing Test HAVE_C_WNO_STRICT_PROTOTYPES
-- Performing Test HAVE_C_WNO_STRICT_PROTOTYPES - Success
-- Found PNG: /usr/lib/aarch64-linux-gnu/libpng.so (found version "1.6.34") 
-- Looking for /usr/include/libpng/png.h
-- Looking for /usr/include/libpng/png.h - found
-- Looking for semaphore.h
-- Looking for semaphore.h - found
-- Performing Test HAVE_CXX_WNO_SHADOW
-- Performing Test HAVE_CXX_WNO_SHADOW - Success
-- Performing Test HAVE_CXX_WNO_UNUSED
-- Performing Test HAVE_CXX_WNO_UNUSED - Success
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE - Success
-- Performing Test HAVE_CXX_WNO_UNDEF
-- Performing Test HAVE_CXX_WNO_UNDEF - Success
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WNO_UNINITIALIZED
-- Performing Test HAVE_CXX_WNO_UNINITIALIZED - Success
-- Performing Test HAVE_CXX_WNO_SWITCH
-- Performing Test HAVE_CXX_WNO_SWITCH - Success
-- Performing Test HAVE_CXX_WNO_PARENTHESES
-- Performing Test HAVE_CXX_WNO_PARENTHESES - Success
-- Performing Test HAVE_CXX_WNO_EXTRA
-- Performing Test HAVE_CXX_WNO_EXTRA - Success
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WNO_MISLEADING_INDENTATION
-- Performing Test HAVE_CXX_WNO_MISLEADING_INDENTATION - Success
-- Checking for module 'gtk+-2.0'
--   Found gtk+-2.0, version 2.24.32
-- Checking for module 'gthread-2.0'
--   Found gthread-2.0, version 2.56.4
-- Checking for module 'gstreamer-base-1.0'
--   Found gstreamer-base-1.0, version 1.14.5
-- Checking for module 'gstreamer-video-1.0'
--   Found gstreamer-video-1.0, version 1.14.5
-- Checking for module 'gstreamer-app-1.0'
--   Found gstreamer-app-1.0, version 1.14.5
-- Checking for module 'gstreamer-riff-1.0'
--   Found gstreamer-riff-1.0, version 1.14.5
-- Checking for module 'gstreamer-pbutils-1.0'
--   Found gstreamer-pbutils-1.0, version 1.14.5
-- Checking for module 'libdc1394-2'
--   Found libdc1394-2, version 2.2.5
-- Checking for module 'libv4l1'
--   Found libv4l1, version 1.14.2
-- Checking for module 'libv4l2'
--   Found libv4l2, version 1.14.2
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for modules 'libavcodec;libavformat;libavutil;libswscale'
--   Found libavcodec, version 57.107.100
--   Found libavformat, version 57.83.100
--   Found libavutil, version 55.78.100
--   Found libswscale, version 4.8.100
-- Checking for module 'libavresample'
--   Found libavresample, version 3.7.0
-- CUDA detected: 10.2
-- CUDA NVCC target flags: -gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_72,code=sm_72;-gencode;arch=compute_75,code=sm_75
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2.0") 
-- Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython2.7.so (found suitable exact version "2.7.17") 
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL
-- Performing Test HAVE_CXX_WNO_OVERLOADED_VIRTUAL - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE
-- Performing Test HAVE_CXX_WNO_UNUSED_BUT_SET_VARIABLE - Success
-- Performing Test HAVE_CXX_WNO_CLOBBERED
-- Performing Test HAVE_CXX_WNO_CLOBBERED - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD
-- Performing Test HAVE_CXX_WNO_UNUSED_PRIVATE_FIELD - Failed
-- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER
-- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER - Success
-- Performing Test HAVE_CXX_WNO_STRICT_ALIASING
-- Performing Test HAVE_CXX_WNO_STRICT_ALIASING - Success
-- 
-- General configuration for OpenCV 2.4.13.7 =====================================
--   Version control:               unknown
-- 
--   Platform:
--     Timestamp:                   2021-01-08T09:23:10Z
--     Host:                        Linux 4.9.140-tegra aarch64
--     CMake:                       3.10.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/g++-8  (ver 8.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/gcc-8
--     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 -Wno-narrowing -Wno-comment -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -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 -Wno-narrowing -Wno-comment -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):
--     Linker flags (Debug):
--     ccache:                      NO
--     Precompiled headers:         YES
-- 
--   OpenCV modules:
--     To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib python stitching superres ts videostab
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera dynamicuda java viz
-- 
--   GUI: 
--     QT:                          NO
--     GTK+ 2.x:                    YES (ver 2.24.32)
--     GThread :                    YES (ver 2.56.4)
--     GtkGlExt:                    NO
--     OpenGL support:              NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/aarch64-linux-gnu/libjpeg.so (ver )
--     PNG:                         /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
--     TIFF:                        /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 - 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.5)
--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.107.100)
--       avformat:                  YES (ver 57.83.100)
--       avutil:                    YES (ver 55.78.100)
--       swscale:                   YES (ver 4.8.100)
--       avresample:                YES (ver 3.7.0)
--     GStreamer:                   
--       base:                      YES (ver 1.14.5)
--       video:                     YES (ver 1.14.5)
--       app:                       YES (ver 1.14.5)
--       riff:                      YES (ver 1.14.5)
--       pbutils:                   YES (ver 1.14.5)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
--     PvAPI:                       NO
--     GigEVisionSDK:               NO
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     V4L/V4L2:                    Using libv4l1 (ver 1.14.2) / libv4l2 (ver 1.14.2)
--     XIMEA:                       NO
--     Xine:                        NO
-- 
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use Eigen:                   YES (ver 3.3.4)
--     Use TBB:                     NO
--     Use OpenMP:                  NO
--     Use GCD                      NO
--     Use Concurrency              NO
--     Use C=:                      NO
--     Use Cuda:                    YES (ver 10.2)
--     Use OpenCL:                  YES
-- 
--   NVIDIA CUDA
--     Use CUFFT:                   YES
--     Use CUBLAS:                  NO
--     USE NVCUVID:                 NO
--     NVIDIA GPU arch:             70 72 75
--     NVIDIA PTX archs:
--     Use fast math:               NO
--     Tiny gpu module:             NO
-- 
--   OpenCL:
--     Version:                     dynamic
--     Include path:                /home/nvidia/opencv-2.4/3rdparty/include/opencl/1.2
--     Use AMD FFT:                 NO
--     Use AMD BLAS:                NO
-- 
--   Python:
--     Interpreter:                 /usr/bin/python2 (ver 2.7.17)
--     Libraries:                   /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java tests:                  NO
-- 
--   Documentation:
--     Build Documentation:         NO
--     Sphinx:                      NO
--     PdfLaTeX compiler:           NO
--     Doxygen:                     NO
-- 
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     C/C++ Examples:              NO
-- 
--   Install path:                  /home/nvidia/lib/opencv_2.4/installed
-- 
--   cvconfig.h is in:              /home/nvidia/opencv-2.4/build
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nvidia/opencv-2.4/build

I am getting the following error when I do make or make -j8

[ 56%] Linking CXX executable ../../bin/opencv_perf_photo
[ 56%] Built target opencv_perf_photo
[ 56%] Built target opencv_gpu_pch_dephelp
[ 57%] Built target pch_Generate_opencv_gpu
[ 58%] Building NVCC (Device) object modules/gpu/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_bf_knnmatch.cu.o
In file included from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/functional.hpp:50:0,
                 from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/vec_distance.hpp:47,
                 from /home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu:49:
/usr/local/cuda-10.2/include/device_functions.h:54:2: warning: #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp]
 #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead."
  ^~~~~~~
In file included from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/functional.hpp:50:0,
                 from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/vec_distance.hpp:47,
                 from /home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu:49:
/usr/local/cuda-10.2/include/device_functions.h:54:2: warning: #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp]
 #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead."
  ^~~~~~~
In file included from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/functional.hpp:50:0,
                 from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/vec_distance.hpp:47,
                 from /home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu:49:
/usr/local/cuda-10.2/include/device_functions.h:54:2: warning: #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp]
 #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead."
  ^~~~~~~
In file included from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/functional.hpp:50:0,
                 from /home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/vec_distance.hpp:47,
                 from /home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu:49:
/usr/local/cuda-10.2/include/device_functions.h:54:2: warning: #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp]
 #warning "device_functions.h is an internal header file and must not be used directly.  This file will be removed in a future CUDA release.  Please use cuda_runtime_api.h or cuda_runtime.h instead."
  ^~~~~~~
/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(60): error: identifier "__shfl" is undefined

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(71): error: identifier "__shfl" is undefined

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(92): error: identifier "__shfl_down" is undefined

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(103): error: identifier "__shfl_down" is undefined

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(124): error: identifier "__shfl_up" is undefined

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(135): error: identifier "__shfl_up" is undefined

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(84): error: identifier "__shfl_down" is undefined
          detected during:
            instantiation of "T cv::gpu::device::shfl_down(T, unsigned int, int) [with T=float]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(75): here
            instantiation of "void cv::gpu::device::bf_knnmatch::findBestMatch<BLOCK_SIZE>(float &, float &, int &, int &, float *, int *) [with BLOCK_SIZE=16]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(401): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchUnrolledCached<BLOCK_SIZE,MAX_DESC_LEN,Dist,T,Mask>(cv::gpu::PtrStepSz<T>, cv::gpu::PtrStepSz<T>, Mask, int2 *, float2 *) [with BLOCK_SIZE=16, MAX_DESC_LEN=64, Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(420): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchUnrolledCached<BLOCK_SIZE,MAX_DESC_LEN,Dist,T,Mask>(const cv::gpu::PtrStepSz<T> &, const cv::gpu::PtrStepSz<T> &, const Mask &, const cv::gpu::PtrStepSz<int2> &, const cv::gpu::PtrStepSz<float2> &, cudaStream_t) [with BLOCK_SIZE=16, MAX_DESC_LEN=64, Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(852): here
            instantiation of "void cv::gpu::device::bf_knnmatch::match2Dispatcher<Dist,T,Mask>(const cv::gpu::PtrStepSz<T> &, const cv::gpu::PtrStepSz<T> &, const Mask &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, cudaStream_t) [with Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(1149): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchDispatcher<Dist,T,Mask>(const cv::gpu::PtrStepSz<T> &, const cv::gpu::PtrStepSz<T> &, int, const Mask &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzf &, cudaStream_t) [with Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(1166): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchL1_gpu<T>(const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, int, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzf &, cudaStream_t) [with T=cv::gpu::device::uchar]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(1172): here

/home/nvidia/opencv-2.4/modules/gpu/include/opencv2/gpu/device/detail/../warp_shuffle.hpp(84): error: identifier "__shfl_down" is undefined
          detected during:
            instantiation of "T cv::gpu::device::shfl_down(T, unsigned int, int) [with T=int]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(77): here
            instantiation of "void cv::gpu::device::bf_knnmatch::findBestMatch<BLOCK_SIZE>(float &, float &, int &, int &, float *, int *) [with BLOCK_SIZE=16]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(401): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchUnrolledCached<BLOCK_SIZE,MAX_DESC_LEN,Dist,T,Mask>(cv::gpu::PtrStepSz<T>, cv::gpu::PtrStepSz<T>, Mask, int2 *, float2 *) [with BLOCK_SIZE=16, MAX_DESC_LEN=64, Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(420): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchUnrolledCached<BLOCK_SIZE,MAX_DESC_LEN,Dist,T,Mask>(const cv::gpu::PtrStepSz<T> &, const cv::gpu::PtrStepSz<T> &, const Mask &, const cv::gpu::PtrStepSz<int2> &, const cv::gpu::PtrStepSz<float2> &, cudaStream_t) [with BLOCK_SIZE=16, MAX_DESC_LEN=64, Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(852): here
            instantiation of "void cv::gpu::device::bf_knnmatch::match2Dispatcher<Dist,T,Mask>(const cv::gpu::PtrStepSz<T> &, const cv::gpu::PtrStepSz<T> &, const Mask &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, cudaStream_t) [with Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(1149): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchDispatcher<Dist,T,Mask>(const cv::gpu::PtrStepSz<T> &, const cv::gpu::PtrStepSz<T> &, int, const Mask &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzf &, cudaStream_t) [with Dist=cv::gpu::device::L1Dist<cv::gpu::device::uchar>, T=unsigned char, Mask=cv::gpu::device::SingleMask]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(1166): here
            instantiation of "void cv::gpu::device::bf_knnmatch::matchL1_gpu<T>(const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, int, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzb &, const cv::gpu::PtrStepSzf &, cudaStream_t) [with T=cv::gpu::device::uchar]" 
/home/nvidia/opencv-2.4/modules/gpu/src/cuda/bf_knnmatch.cu(1172): here

8 errors detected in the compilation of "/tmp/tmpxft_000021a9_00000000-7_bf_knnmatch.compute_72.cpp1.ii".
CMake Error at cuda_compile_generated_bf_knnmatch.cu.o.cmake:264 (message):
  Error generating file
  /home/nvidia/opencv-2.4/build/modules/gpu/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_bf_knnmatch.cu.o

modules/gpu/CMakeFiles/opencv_gpu.dir/build.make:503: recipe for target 'modules/gpu/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_bf_knnmatch.cu.o' failed
make[2]: *** [modules/gpu/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_bf_knnmatch.cu.o] Error 1
CMakeFiles/Makefile2:4741: recipe for target 'modules/gpu/CMakeFiles/opencv_gpu.dir/all' failed
make[1]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2 

I have also tried it with -DCUDA_ARCH_BIN=7.2. I get the same error. How can I resolve this error?

Thank you

hshreeshail commented 1 year ago

@kasparov92 this is likely too late, but - for anyone reading - I did manage to build this repo with OpenCV 2.4.13 and CUDA 10.

To start, in order to use our GPU with OpenCV 2, we have to build OpenCV from source, using the WITH_CUDA=ON flag when we build OpenCV. Otherwise, OpenCV will seemingly build normally but throw CV_GpuNotSupported errors when we actually try to run it. This appears to be the error referenced in #11 and it is described in the OpenCV 2.4 docs here. Instructions for building OpenCV from source can be found here, and the source code for OpenCV 2.4 is somewhere in the OpenCV release archives.

Now we have to install OpenCV! As you mentioned, OpenCV 2.4 is not compatible with CUDA >= 9. This is because CUDA 9 split up the nppi library into several new libraries, and OpenCV 2.4 has trouble finding these new libraries. We have to modify some search paths in the OpenCV makefiles to help it find the new nppi* libraries. This is apparently a pretty well-known issue, and I found this blog post to be the best guide for solving it. This StackOverflow thread contains a similar set of instructions, though it's designed to fix the same issue in OpenCV 3.3.

If you've made it to this point, after editing the OpenCV files as described above and building OpenCV, you should have a working installation of OpenCV 2.4. After that, when building gpu_flow, the gpu_flow makefiles complained about not finding the new nppi* libraries and a few Qt libraries. I fixed those errors by finding those files and appending them to my CMAKE_PREFIX_PATH in the $cmake command. On my machine, my nppi* libraries were hanging out at /usr/local/cuda and my Qt libraries were installed locally at /vision/u/etang21/Qt5.4.2/5.4/gcc_64/lib/cmake/Qt5Widgets. Running cmake with $cmake -D CMAKE_PREFIX_PATH=/usr/local/cuda;/vision/u/etang21/Qt5.4.2/5.4/gcc_64/lib/cmake/Qt5Widgets .. did the trick for me. It looks like the thread in #5 may also be helpful for any errors you encounter here.

Hope this helps in any small way!

I tried this method. I am able to run cmake without any error (I added the WITH_CUDA=ON flag too). However, on running make, I am getting the following error:

[  3%] Built target libtiff
[  6%] Built target libjasper
[  7%] Built target libpng
[ 13%] Built target IlmImf
Scanning dependencies of target opencv_core_pch_dephelp
[ 13%] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o
[ 13%] Linking CXX static library ../../lib/libopencv_core_pch_dephelp.a
[ 13%] Built target opencv_core_pch_dephelp
[ 13%] Generating precomp.hpp.gch/opencv_core_RELEASE.gch
[ 13%] Built target pch_Generate_opencv_core
[ 13%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/cuda_compile_generated_matrix_operations.cu.o
nvcc fatal   : Unsupported gpu architecture 'compute_20'
CMake Error at cuda_compile_generated_matrix_operations.cu.o.cmake:208 (message):
  Error generating
  /data/models/gpu_flow/build/opencv-2.4.13.5/release/modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/./cuda_compile_generated_matrix_operations.cu.o

make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:65: modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/cuda_compile_generated_matrix_operations.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1784: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

On searching online, I found other situations (ex: this) where this error occurs. However, the solution there involved modifying the Makefile.Config file. There is no such file in my case. How do I resolve this error? I am working on NVIDIA A6000 GPU machine with cuda 10.1 installed.

hshreeshail commented 1 year ago

Hello,

Have anyone build successfully this repo? it keeps giving me issues when building

Trial 1: Using Opencv3.4 (latest version to date) gave me an issue regarding the "gpu.h" library, and seems I cannot go with this version as there is not a branch or another code version using this opencv version

Trial 2: Using Opencv2.4. Well I have cuda 9, so it seems that this version of opencv does not compile with this version of cuda. I also tried to copy the findcuda and detectopencv files from latest version of Opencv, and I had also tried to modify some lines in those files, but all these tricks did not make it work.

So before going further and installing another cuda version and give another try, have anyone tried to build this successfully? and what version of opencv and cuda did you have?

Thanks in advance, Regards, Bassel Safwat

Hi @kasparov92, Were you able to build this successfully? What opencv version did you use?