table of Contents
CUDA Installation and Configuration
CUDA Installation and Configuration
Own GPU choose the right version based on, I was RTX2080Ti, select CUDA10.0 version, installed just fine with the default address to see whether there is after installing environment variables. If not, add their own.
as well as,
cuDNN
cuDNN must be 7.5 or later, otherwise it would not recognize the cuDNN CMake path.
Open downloaded cuDNN, following FIG.
CuDNN in the bin, include, lib folder corresponding to the file into the folder path CUDA
CMake compilation
CMake open, select the source directory, and generating path, select the corresponding version VS. Start the first Configue.
Which will download some third-party file can be downloaded on their own, or a slower speed. For the first time after the completion of configure, check BUILD_opencv_world.
And a check OPENCV_DNN_CUDA, good choice decompression modules opencv_contrib add in the path.
Check WITH_CUDA.
Configure a second, may be error after Configure completed at this time whether he, select the appropriate value based GPU CUDA_ARCH_BIN force calculation table, as I was RTX2080Ti, then the remaining value CUDA_ARCH_BIN deleted, leaving only 7.5. Then check CUDA_FAST_MATH, click Configure.
After waiting Configure completed to see if detected CUDA and cuDNN, after all YES appears, indicating that there is no problem. Here is a pit, need to pay attention, if not detected, then you need to confirm whether the correct versions of CUDA and cuDNN, otherwise the compiler will not compile CUDA behind the module, a waste of time. After confirmation, click Generate.
Click Open Project to open the project, right-click ALL_BUILD in Release mode, generating longer time
After generating, right-click INSTALL-> Only for the project -> Generate only INSTALL
It translated well to the side, Debug version empathy
Run the test
Add the environment variable.
在测试代码中配置包含目录和库目录,添加附加依赖项,opencv_world420.lib
由于项目的关系,代码就不贴出来了,官方提供了一份代码示例。
在我自己的项目上运行,首先是CPU版本(I9-9900K),推理时间在22.45ms。
CUDA版本(RTX 2080Ti),推理时间是2.16ms。提升了10倍左右。
顺便贴一个OpenVINO推理引擎的运行效率,大概是8.17ms左右
总结
opencv和opencv_contrib版本要对应
在下载部分第三方库时也要找好对应版本。
勾选WITH_CUDA 、OPENCV_DNN_CUDA。
一定要查看cuDNN版本是否正确,否则几个小时的编译将是浪费时间。
最好使用VS2017版本,VS2015测试出现异常,编译失败。
原文链接:https://blog.csdn.net/weixin_39928773/article/details/103709184