Opencv-GPU 编译错误 CUDA_nppicom_LIBRARY (ADVANCED) 未定义

问题出现描述

  • Opencv : 4.3
  • CUDA: 11.1
  • Ubuntu 18.04

编译支持CUDA的OpenCV, CMake命令和报错内容如下:

cmake \
-D INCLUDE_DIRS=${OPENCV_INCLUDE_DIR_ANACONDA} $INCLUDE_DIRS \
-D LIBRARY_DIRS=$OPENCV_LIBRARY_ANACONDA $LIBRARY_DIRS \
-D BUILD_PYTHON_SUPPORT=ON \
-D BUILD_DOCS=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv \
-D OPENCV_EXTRA_MODULES_PATH=/home/timber/Library/opencv_contrib/modules \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=${OPENCV_PYTHON_EXECUTABLE_ANACONDA} \
-D PYTHON3_INCLUDE_DIR=${OPENCV_INCLUDE_DIR_ANACONDA} \
-D PYTHON3_PACKAGES_PATH=${OPENCV_PACKAGE_ANACONDA} \
-D BUILD_EXAMPLES=OFF \
-D WITH_GTK=ON \
-D WITH_GTK_2_X=ON \
-D WITH_IPP=ON \
-D BUILD_TIFF=ON \
-D BUILD_opencv_cvv=OFF \
-D INSTALL_CREATE_DISTRIB=ON \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_TBB=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D WITH_CUDA=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
-D CUDA_ARCH_BIN="8.6" \
-D CUDA_ARCH_PTX="" \
-D WITH_CUBLAS=ON \
-D WITH_NVCUVID=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D CMAKE_BUILD_TYPE=Release \
..

其中一些变量是python是虚拟环境相关的,在激活虚拟环境后运行如下命令获得,编译时取消激活防止库冲突。

OPENCV_PYTHON_EXECUTABLE_ANACONDA=$(which python${PYTHON_VERSION}) && \
OPENCV_INSTALL_PATH=$(python -c "import sys; print(sys.prefix)") && \
OPENCV_INCLUDE_DIR_ANACONDA=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") && \
OPENCV_PACKAGE_ANACONDA=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") && \
OPENCV_LIBRARY_ANACONDA=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")

报错内容如下:

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)

Opencv-GPU 编译错误 CUDA_nppicom_LIBRARY (ADVANCED) 未定义

解决办法

cmake \
-D INCLUDE_DIRS=${OPENCV_INCLUDE_DIR_ANACONDA} $INCLUDE_DIRS \
-D LIBRARY_DIRS=$OPENCV_LIBRARY_ANACONDA $LIBRARY_DIRS \
-D BUILD_PYTHON_SUPPORT=ON \
-D BUILD_DOCS=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv \
-D OPENCV_EXTRA_MODULES_PATH=/home/timber/Library/opencv_contrib/modules \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=${OPENCV_PYTHON_EXECUTABLE_ANACONDA} \
-D PYTHON3_INCLUDE_DIR=${OPENCV_INCLUDE_DIR_ANACONDA} \
-D PYTHON3_PACKAGES_PATH=${OPENCV_PACKAGE_ANACONDA} \
-D BUILD_EXAMPLES=OFF \
-D WITH_GTK=ON \
-D WITH_GTK_2_X=ON \
-D WITH_IPP=ON \
-D BUILD_TIFF=ON \
-D BUILD_opencv_cvv=OFF \
-D INSTALL_CREATE_DISTRIB=ON \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_TBB=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D WITH_CUDA=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
-D CUDA_ARCH_BIN="8.6" \
-D CUDA_ARCH_PTX="" \
-D WITH_CUBLAS=ON \
-D WITH_NVCUVID=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D CUDA_nppicom_LIBRARY=true \
..

结果:
Opencv-GPU 编译错误 CUDA_nppicom_LIBRARY (ADVANCED) 未定义

上一篇:Generate the Jobs script from msdb Database


下一篇:在UMAP图上标识我们感兴趣的基因所在的类群(单细胞数据)