sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
为
sudo cp cuda/include/*.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
step1: 下载opencv4.7.0源码
step2: 下载opencv4.7.0对于的contirb,这个在opencv4.7.0 官方github中README中有contrib的链接,调整,选择对应Tag版本的下载放入源码文件夹
step3:按需配置,贴如下两个常用命令分别用于GPU 和 CPU的版本安装
# My GPU 2080ti , change -D CUDA_ARCH_BIN=7.5 for your gpu version
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=../install \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D BUILD_CUDA_STUBS=ON \
-D WITH_CUDA=ON \
-D WITH_CUBLAS=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D BUILD_OPENCV_WORLD=ON \
-D CUDA_ARCH_BIN=7.5 \
-D INSTALL_CREATE_DISTRIB=ON \
-D WITH_OPENGL=ON \
-D MAKE_INSTALL_PREFIX=/usr/local
-D CUDNN_INCLUDE_DIR=/usr/local/cuda/include/ \
-D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=OFF \
..
# cpu version
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=../install \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D WITH_CUDA=OFF \
-D INSTALL_CREATE_DISTRIB=ON \
-D WITH_OPENGL=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=OFF \
..