简体   繁体   English

CUDA(GPU) 作为 OpenCV 后端

[英]CUDA(GPU) as OpenCV backend

Am trying to use CUDA as backend for dnn module provided in opencv-4.1.1 , I have build opencv with CUDA enabled, nvidia drivers and CUDA is properly placed on system, here am using manjaro as development platform.我正在尝试使用 CUDA 作为 opencv-4.1.1 中提供的 dnn 模块的后端,我构建了启用 CUDA 的 opencv,nvidia 驱动程序和 CUDA 正确放置在系统上,这里使用 manjaro 作为开发平台。

am trying to load pre-trained YOLOv3 weights using cv2.dnn module,我正在尝试使用 cv2.dnn 模块加载预训练的 YOLOv3 权重,

net = cv2.dnn.readNetFromDarknet('yolov3.cfg', 'yolov3.weights')

But it uses CPU as defualt inference engine, but am trying to use GPU as backend IE, from offecial opencv doc, i found following但它使用 CPU 作为默认推理引擎,但我试图使用 GPU 作为后端 IE,来自官方 opencv 文档,我发现以下

DNN_TARGET_CPU  
DNN_TARGET_OPENCL   
DNN_TARGET_OPENCL_FP16  
DNN_TARGET_MYRIAD       
DNN_TARGET_FPGA 

as target backend, but no support for direct GPU inference, so what's point of compiling opencv with CUDA if it doen't make use of GPU as underlying inferencing engine,作为目标后端,但不支持直接 GPU 推理,所以如果不使用 GPU 作为底层推理引擎,用 CUDA 编译 opencv 有什么意义,

in order to make sure processes are runing on GPU I posted output of nvidia-smi ,为了确保进程在 GPU 上运行,我发布了nvidia-smi输出,

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.26       Driver Version: 430.26       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 710      Off  | 00000000:01:00.0 N/A |                  N/A |
| 40%   40C    P0    N/A /  N/A |    598MiB /  1998MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+

the process id for GPU utilization is 0, clearly means that no process utilizing GPU, any guidance will be appreciated. GPU 使用的进程 id 为 0,显然意味着没有使用 GPU 的进程,任何指导将不胜感激。

At the moment CUDA support for DNN module way in progress under a GSOC task so there is no official release yet.目前 CUDA 在 GSOC 任务下对 DNN 模块方式的支持正在进行中,因此还没有正式发布。 You can check its repo here to see progress.您可以在此处查看其存储库以查看进度。

Edit: Looks CUDA backend integration is completed and included in the release version 4.2.0, you can check the change logs here .编辑:看起来 CUDA 后端集成已完成并包含在发布版本 4.2.0 中,您可以在此处查看更改日志。

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

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