简体   繁体   English

cv::cuda::NvidiaOpticalFlow_2_0::create 大约需要 30 秒

[英]cv::cuda::NvidiaOpticalFlow_2_0::create takes about 30 seconds

To use the official example script for NvidiaOpticalFlow, I built OpenCV from source following the instructions from the Nvidia Optical Flow SDK (with slightly modified build flags to enable JPEG, OPENEXR, and Eigen).为了使用 NvidiaOpticalFlow 的官方示例脚本,我按照Nvidia Optical Flow SDK的说明从源代码构建了 OpenCV(稍微修改了构建标志以启用 JPEG、OPENEXR 和 Eigen)。 The OpenCV version is 4.5.2. OpenCV 版本为 4.5.2。 I can post the CMake options on request.我可以根据要求发布 CMake 选项。

This line from the example script takes about 30 seconds.示例脚本中的这一行大约需要 30 秒。 Is this normal or could there be an issue with my setup?这是正常的还是我的设置有问题?

Other details:其他详情:

  • I'm on Ubuntu 20.04我在 Ubuntu 20.04
  • nvidia-smi gives Driver Version: 470.141.03 CUDA Version: 11.4 nvidia-smi提供Driver Version: 470.141.03 CUDA Version: 11.4
  • To compile the example script I use CMake with: cmake_minimum_required(VERSION 3.16) and set(CMAKE_CXX_STANDARD 20) .要编译示例脚本,我使用 CMake 和: cmake_minimum_required(VERSION 3.16)set(CMAKE_CXX_STANDARD 20)

According to user @RobertCrovella in the comments, the delay may have been to do with JIT compilation.根据评论中的用户@RobertCrovella,延迟可能与 JIT 编译有关。 Indeed, when calling create twice in one script, the second time does not have a delay.事实上,当在一个脚本中调用两次create时,第二次没有延迟。

Whether or not that's the real reason, the root cause was that I had incorrectly specified the arch for my GPU in the OpenCV build flags.不管这是否是真正的原因,根本原因是我在 OpenCV 构建标志中错误地为我的 GPU 指定了拱门。 They were set as -DCUDA_ARCH_BIN:STRING=7.5 -DCUDA_ARCH_PTX:STRING=7.5 whereas for my GPU (Nvidia RTX 3090) they should have been set as -DCUDA_ARCH_BIN:STRING=8.6 -DCUDA_ARCH_PTX:STRING=8.6 .它们被设置为-DCUDA_ARCH_BIN:STRING=7.5 -DCUDA_ARCH_PTX:STRING=7.5而对于我的 GPU (Nvidia RTX 3090) 他们应该被设置为-DCUDA_ARCH_BIN:STRING=8.6 -DCUDA_ARCH_PTX:STRING=8.6 I rebuilt OpenCV with the correct flags and the delay went away.我用正确的标志重建了 OpenCV 并且延迟消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM