【问题标题】:How to get correct GPU device id for Microsoft.ML.OnnxRuntime.DirectML (.net core 3.1)?如何为 Microsoft.ML.OnnxRuntime.DirectML(.net core 3.1)获取正确的 GPU 设备 ID?
【发布时间】:2020-10-21 11:30:08
【问题描述】:

我正在使用 Microsoft.ML.OnnxRuntime.DirectML nuget 包进行图像分类,如下所示:

    var options = new SessionOptions();
    options.AppendExecutionProvider_DML( 1 ); // deviceId goes here
    var session = new InferenceSession( _modelPath, options );

而且我有一个大问题:在 IIS 中,集成显卡的 deviceId 为 0,离散显卡的 deviceId 为 1。但是当我的应用在 Kestrel 下运行时,集成显卡的 deviceId 为 1,离散显卡的 deviceId 为 0,这与什么任务相反评分进行时,管理器会显示在“GPU 引擎”列中。

现在我的集成卡不能与这个包一起使用,因为它会抛出这个异常(无论如何这毫无意义):

Exception Info: Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:RuntimeException] D:\5\s\onnxruntime\core\providers\dml\dml_provider_factory.cc(110)\onnxruntime.DLL!00007FF8C074118F: (caller: 00007FF8C07411C7) Exception(941) tid(35b8) 887A0020 An internal issue prevented the driver from carrying out the specified operation. The driver's state is probably suspect, and the application should not continue.

所以我需要一种可靠的方法来检测离散显卡的 deviceId。

【问题讨论】:

    标签: asp.net-core asp.net-core-3.1 onnxruntime


    【解决方案1】:

    好的,我现在找到了解决方法。 我可以使用这种方法检查女巫显卡是集成/离散的 How get GPU information in C#? 然后我可以使用 Vortice.DXGI nuget 包来找出每个显卡有哪个 deviceId - 它基本上是索引

    DXGI.CreateDXGIFactory1( out IDXGIFactory1 factory );
    factory.EnumAdapters1( 0, out var adapter0 );
    factory.EnumAdapters1( 1, out var adapter1 );
    factory.EnumAdapters1( 2, out var adapter2 );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      • 2020-12-13
      • 1970-01-01
      • 2020-06-11
      • 1970-01-01
      相关资源
      最近更新 更多