1
框架组件
如何使用Onnxruntime 开启DCU加速
2024-03-19 09:32:15
320

我在使用onnxruntime 来调用DCU的推理能力,
当前用的 22.10.1 的驱动和 DTK。
从 AI生态包(https://download.sourcefind.cn:65024/4/main/onnxruntime/dtk22.10.1) 下载了onnxruntime-1.14.0+giteda74d18+dtk-22.10.1.run。
同时也下载安装了migraphix的包(migraphx-2.5.0-f2f7ae8.el7.x86_64.rpm)
如果使用cpu推理,可以正确运行。
但
使用如下代码开启来 onnxruntime的 dcu后端

int device_id_ = 0;
  Ort::SessionOptions so;
  Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_MIGraphX(so, device_id_)); 
  // Ort::ThrowOnError(OrtSessionOptionsAppendExecutionProvider_ROCM(so, device_id));

如果使用MIGraphX 作为rpovider,运行就报错:

2023-06-28 14:34:24.164831170 [I, reshape_fusion.cc:42 ApplyImpl] Total fused reshape node count: 0
MIGraphX Error: /FrameWork/code_project/migraphx_2.5.0/src/include/migraphx/op/dot.hpp:65: compute_shape: DOT: inner dimensions do not match: {1, 128} x {1152, 128}
2023-06-28 14:34:24.173258659 [E, inference_session.cc:1548 operator()] Exception during initialization: Failed to call function
terminate called after throwing an instance of 'Ort::Exception'
  what():  Exception during initialization: Failed to call function
Aborted (core dumped) 

如果 使用ROCM作为 provider,报错:


MIOpen Error: /data/jenkins_workspace/workspace/miopen_release_1/miopen/src/convolution_api.cpp:205: requestedSpatialDim is larger than actual spatial dimension
2023-06-28 14:37:41.668338217 [Ibackend, bfc_arena.cc:267 Reserve] Reserving memory in BFCArena for Hip size: 33554432
2023-06-28 14:37:41.672936646 [Ibackend, bfc_arena.cc:267 Reserve] Reserving memory in BFCArena for Hip size: 33554432
MIOpen Error: /data/jenkins_workspace/workspace/miopen_release_1/miopen/src/convolution_api.cpp:205: requestedSpatialDim is larger than actual spatial dimension
2023-06-28 14:37:41.678442607 [Ebackend, rocm_call.cc:122 RocmCall] MIOPEN failure 1: miopenStatusNotInitialized ; GPU=0 ; hostname=710953 ; expr=status_; 
2023-06-28 14:37:41.678491607 [E, sequential_executor.cc:369 Execute] Non-zero status code returned while running FusedConv node. Name:'Conv_18' Status Message: MIOPEN failure 1: miopenStatusNotInitialized ; GPU=0 ; hostname=710953 ; expr=status_; 
terminate called after throwing an instance of 'Ort::Exception'
  what():  Non-zero status code returned while running FusedConv node. Name:'Conv_18' Status Message: MIOPEN failure 1: miopenStatusNotInitialized ; GPU=0 ; hostname=710953 ; expr=status_; 
Aborted (core dumped)

请问这是这个怎么解决啊?

========================
经过研究发现

  1. 只能开启ROCM ,无使用 MIGraphx
  2. 不能开启全部graph优化(ORT_ENABLE_ALL),我用的ORT_ENABLE_BASIC,感觉跟不开速度没差别。

提速还是很明显的,由cpu的2s多,降到240ms。

全部评论(3)
只看楼主
网
网友NdMX7t
2楼
可以问下怎么开启ROCM呀
2025/8/12
火
火星上种蘑菇
楼主
1楼

经过研究发现

1. 只能开启ROCM ,无使用 MIGraphx

2. 不能开启全部graph优化(ORT_ENABLE_ALL),我用的ORT_ENABLE_BASIC,感觉跟不开速度没差别。

备注,当前用的 22.10.1 的驱动和 DTK。
2023/6/28
T
tianlh
回复 @火星上种蘑菇
您好,麻烦明确一下具体问题?现在是要解决什么呢?另外如果有报错,请贴一下源码,我们复现分析看下,谢谢
2023/7/6
没有更多内容了
--
楼主
Level.1
0 帖子
楼主热帖
暂无数据