Arch Linux 中 OpenCV 中的 CUDA 编译

Arch Linux 中 OpenCV 中的 CUDA 编译

我正在尝试使用 CUDA 在 OpenCV 3.2.0 中编译程序,我有一块显卡 Nvidia Gforce 950M (Maxwell),我使用 Arch Linux

首先,我在 Arch Linux X64 上安装了最新版本的 nvidia、nvidia-settings、gcc-5 和 cuda

在 Cmake 上我选择 gcc-5 进行编译,这是我的 CUDA Cmake 编译文件

BUILD_CUDA_STUBS=ON
BUILD_opencv_cudaarithm=ON
BUILD_opencv_cudabgsegm=ON
BUILD_opencv_cudacodec=ON
BUILD_opencv_cudafeatures2d=ON
BUILD_opencv_cudafilters=ON
BUILD_opencv_cudaimgproc=ON
BUILD_opencv_cudalegacy=ON
BUILD_opencv_cudaobjdetect=ON
BUILD_opencv_cudaoptflow=ON
BUILD_opencv_cudastereo=ON
BUILD_opencv_cudawarping=ON
CUDA_ARCH_BIN = 5.0 5.2
CUDA_ARCH_PTX =
CUDA_FAST_MATH = ON
CUDA_GENERATION = Maxwell
CUDA_HOST_COMPILER = /usr/bin/gcc-5
CUDA_SEPARABLE_COMPILATION = OFF
CUDA_TOOLKIT_ROOT_DIR = /opt/cuda
WITH_CUDA = ON

(来自 Cmake GUI 图像的值)

编译完 OpenCV 后,我在 QT Creator 中加载库

    TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lopencv_cudaarithm -lopencv_cudabgsegm -lopencv_cudacodec -lopencv_features2d  -lopencv_cudafilters -lopencv_cudaimgproc -lopencv_cudalegacy -lopencv_cudaobjdetect -lopencv_cudaoptflow -lopencv_cudastereo -lopencv_cudawarping -lopencv_videoio

INCLUDEPATH += $$PWD/../../../../usr/local/include
DEPENDPATH += $$PWD/../../../../usr/local/include



unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lopencv_core -lopencv_objdetect -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs

INCLUDEPATH += $$PWD/../../../../usr/local/include
DEPENDPATH += $$PWD/../../../../usr/local/include

INCLUDEPATH += /opt/cuda/include/
LIBS += -L /opt/cuda/include/



unix:!macx: LIBS += -L$$PWD/../../../../opt/cuda/lib64/ -lcudart

INCLUDEPATH += $$PWD/../../../../opt/cuda/lib64
DEPENDPATH += $$PWD/../../../../opt/cuda/lib64

我尝试编译 cascadeclassifier_nvidia_api.cpp,但出现以下情况CUDA 错误

NCV Assertion Failed: No GPU found or the library is compiled without CUDA support, file = ../CUDA/main.cpp, line=163

我究竟做错了什么?

相关内容