当前位置:网站首页>Compiling opencv4.5.5 with CUDA (4.2.0+cuda11.1+cudnn8.0.5 failed)

Compiling opencv4.5.5 with CUDA (4.2.0+cuda11.1+cudnn8.0.5 failed)

2022-06-09 07:33:00 Ferry companion

 Insert picture description here
I haven't won a prize for living so big , Never hit more than 20 A $lottery , I won a prize in this place , Very sharp !!
Finally change to 4.5.5 The version succeeded :
 Insert picture description here
cmake The content of :

cmake \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_C_COMPILER=/usr/bin/gcc \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \
    -D CUDA_CUDA_LIBRARY=/usr/lib/x86_64-linux-gnu/libcuda.so \
    -D CUDA_ARCH_BIN=7.5 \
    -D CUDA_ARCH_PTX="" \
    -D WITH_CUDA=ON \
    -D WITH_TBB=ON \
    -D WITH_FFMPEG=ON \
    -D BUILD_PYTHON_SUPPORT=ON \
    -D BUILD_NEW_PYTHON_SUPPORT=ON \
    -D BUILD_OPENCV_PYTHON3=ON \
    -D PYTHON_INCLUDE_DIR=(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
    -D PYTHON_PACKAGES_PATH=(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
    -D WITH_V4L=ON \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D WITH_QT=ON \
    -D WITH_GSTREAMER=ON \
    -D WITH_OPENGL=ON \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D OPENCV_PC_FILE_NAME=opencv.pc \
    -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
    -D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
    -D WITH_CUBLAS=ON \
    -D WITH_NVCUVID=ON \
    -D BUILD_opencv_cudacodec=ON \
    -D OPENCV_DNN_CUDA=ON \
    -D WITH_CUDNN=ON \
    -D OPENCV_ENABLE_NONFREE=ON\
    -D WITH_GSTREAMER=ON \
    -D BUILD_EXAMPLES=ON ..

brothers , The benefits have been paid , Trampling on numerous pits .cache file :
link : https://pan.baidu.com/s/1Eq2U6WD3AL6lAaHLMqed9w Extraction code : 6avj
– From Baidu network disk super member v5 The share of
Permanent validity !
Cry , In memory of my dead brain cells !

Test whether the compilation is correct :
 Insert picture description here
Code :

#include <iostream>
#include<opencv2/opencv.hpp>

int main(int argc, char* argv[])
{
    
    cv::cuda::GpuMat img(400, 600, CV_8UC3, cv::Scalar(255, 0, 0));
    cv::Mat cpuImg;
    img.download(cpuImg);
    cv::imshow("test", cpuImg);
    cv::waitKey(0);
    return 0;
}

I don't trust you, but I made a match again
 Insert picture description here
after work , after work !!

When I left yesterday g++ Compile successfully , however vscode Call failed , Mainly cv::cuda:cvtColor function , Today is OK
 Insert picture description here
stay task.json Medium plus lib library , current task.json Long like this

{
    
    "tasks": [

        {
    
            "type": "shell",
            "label": "g++ build active file",
            "command": "g++",
            "args": [
                "-g",
                "-std=c++11",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.out",
                "`pkg-config", "--cflags", "--libs", "opencv`", "-I", "/usr/local/include/opencv4", "-I", "/usr/local/include/opencv4/opencv2", "-I", "/usr/local/include", "-L", "/usr/local/lib", "-l", "opencv_core", "-l", "opencv_imgproc", "-l", "opencv_imgcodecs", "-l", "opencv_video", "-l", "opencv_ml", "-l", "opencv_highgui", "-l", "opencv_objdetect", "-l", "opencv_flann", "-l", "opencv_imgcodecs", "-l", "opencv_photo", "-l", "opencv_videoio" ], "options": { "cwd": "/usr/bin" }, "group": { "kind": "build", "isDefault": true } } ], "version": "2.0.0"
}

Reference link :
True knowledge comes from practice ——Ubuntu 18.04 VSCODE To configure OpenCV4.5 function YOLO4 Model

原网站

版权声明
本文为[Ferry companion]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021419049423.html