源码编译OpenCV 启用cuda 加速
系统:ubuntu22.04 x86_64
显卡:nvidia 4070tisuper 16G
NVIDIA-SMI 550.67
Driver Version: 550.67
CUDA Version: 12.4
clone github源码:https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv.git
检出4.10.0 版本,目前2024年6月5日,最新版本
git checkout 4.10.0
clone opencv_contrib
我这里放在 opencv/modules/opencv_contrib
git clone https://github.com/opencv/opencv_contrib.git
编译cuda支持
指定安装路径 CMAKE_INSTALL_PREFIX
指定opencv_contrib路径 /media/wmx/ws1/software/opencv/modules/opencv_contrib/modules
mkdir build & cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/media/wmx/soft1/software/opencv-4.10 \
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D WITH_CUDA=ON \
-D WITH_CUBLAS=ON \
-D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \
-D BUILD_opencv_cudacodec=OFF \
-D OPENCV_DNN_CUDA=ON \
-D OPENCV_EXTRA_MODULES_PATH=/media/wmx/ws1/software/opencv/modules/opencv_contrib/modules \
..
生成MakeFile
然后编译
make -j48
安装
make install