首页 > 解决方案 > onnxruntime with use_dml mix build hanppen error 使用 DML 执行提供程序时不支持启用内存模式

问题描述

在窗口环境中,使用--use_dml 在nxruntime 上构建,我的命令是“

.\build.bat --update --build --build_shared_lib --build_wheel --config RelWithDebInfo --use_dml --cmake_generator "Visual Studio 16 2019"  --parallel --skip_tests".

最终构建成功,生成whl文件。然后

pip3 install *.whl 

.so我可以使用python进行推理。但是发生了错误。我的代码是“

session_1 = onnxruntime.InferenceSession(model_path,options)"

错误是“2021-03-10 19:03:59.3618026 [W:onnxruntime:, inference_session.cc:411 onnxruntime::InferenceSession::RegisterExecutionProvider] 使用 DML 执行提供程序时不支持启用内存模式。所以禁用它用于此会话,因为它使用 DML 执行提供程序。” 而且推理时间很长。谁能告诉我为什么?

标签: provideronnxruntime

解决方案


根据文档(https://onnxruntime.ai/docs/execution-providers/DirectML-ExecutionProvider.html#configuration-options),声明会话时应使用以下两个参数:

options.enable_mem_pattern = False
options.execution_mode = rt.ExecutionMode.ORT_SEQUENTIAL

推荐阅读