opencv - 在 Ubuntu 18.04 上使用 cuda 11 构建 OpenCV-4.0.0

标签 opencv opencv4

我正在尝试在 Ubuntu 18.04 上使用 cuda 11 构建 openCV 4.0.0。
以下是我的 cmakefile

cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_C_COMPILER=/usr/bin/gcc-7 \
  -D CMAKE_INSTALL_PREFIX=/usr/local/OpenCV-4.0.0 \
  -D INSTALL_PYTHON_EXAMPLES=ON \
  -D INSTALL_C_EXAMPLES=OFF \
  -D WITH_TBB=ON \
  -D WITH_CUDA=ON \
  -D WITH_CUDNN=ON \
  -D OPENCV_DNN_CUDA=ON \
  -D CUDA_ARCH_BIN=7.5 \
  -D BUILD_opencv_cudacodec=OFF \
  -D ENABLE_FAST_MATH=1 \
  -D CUDA_FAST_MATH=1 \
  -D WITH_CUBLAS=1 \
  -D WITH_V4L=ON \
  -D WITH_QT=OFF \
  -D WITH_OPENGL=ON \
  -D WITH_GSTREAMER=ON \
  -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D OPENCV_PC_FILE_NAME=opencv.pc \
  -D OPENCV_ENABLE_NONFREE=ON \
  -D OPENCV_PYTHON3_INSTALL_PATH=~/.virtualenvs/cv/lib/python3.6/site-packages \
  -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-4.0.0/modules \
  -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
  -D BUILD_EXAMPLES=ON ..

我收到以下错误
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_nppicom_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/ali/opencv_contrib-4.0.0/modules/cudev
    linked by target "opencv_cudev" in directory /home/ali/opencv_contrib-4.0.0/modules/cudev
    linked by target "opencv_test_cudev" in directory /home/ali/opencv_contrib-4.0.0/modules/cudev/test
    linked by target "opencv_test_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_perf_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_test_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_perf_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_flann" in directory /home/ali/opencv-4.0.0/modules/flann
    linked by target "opencv_flann" in directory /home/ali/opencv-4.0.0/modules/flann
    linked by target "opencv_test_flann" in directory /home/ali/opencv-4.0.0/modules/flann
    linked by target "opencv_test_hdf" in directory /home/ali/opencv_contrib-4.0.0/modules/hdf
    linked by target "opencv_hdf" in directory /home/ali/opencv_contrib-4.0.0/modules/hdf
    linked by target "opencv_hdf" in directory /home/ali/opencv_contrib-4.0.0/modules/hdf
    linked by target "opencv_test_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc
    linked by target "opencv_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc
    linked by target "opencv_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc
    linked by target "opencv_perf_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc

我测试了 cuda/cudnn 示例,它们运行良好。
任何帮助将非常感激。

最佳答案

似乎是因为版本兼容性问题。两周以来,我一直在寻找同一问题的解决方案。我试图让 OpenCV-4.2.0 在带有 CUDA-11.1 和 CUDNN-8.0.5 的 Ubuntu-20.04 上工作,但它从未奏效。
阅读@antb52 的评论后,我尝试安装 OpenCV-4.4.0,并且成功了!现在,问题解决了!!!

关于opencv - 在 Ubuntu 18.04 上使用 cuda 11 构建 OpenCV-4.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62297025/

相关文章:

OpenCV,筛选 : All of the features of 2 different insects are matching

opencv - 直方图 bin 总数不等于图像像素大小

python - wrapTransform后如何找到一个点?

c++ - 从图像中获取数字

c++ - OpenCV - 段错误实例化冲浪特征检测器

android - 如何在 Android Studio 中导入 OpenCV 4.5

c++ - 在OpenCV C++中创建空白图像

c++ - 为什么基于Opencv DNN的(caffe)人脸检测器无法找到人脸?

c++ - (OpenCV4.1)/usr/bin/ld : cannot find -lopencv_nonfree