软件无法运行在个别电脑异常分析

作者:Chdon 发布时间: 2025-08-20 阅读量:13 评论数:0

一、背景

在个别电脑上,无法运行。但是大部分人电脑是正常运行的。

报错信息如下
Microsoft.ML.OnnxRuntime.OnnxRuntimeException
  HResult=0x80131500
  Message=[ErrorCode:NotImplemented] Could not find an implementation for Reshape(19) node with name '/model.10/m/m.0/attn/Reshape'
  Source=Microsoft.ML.OnnxRuntime
  StackTrace:
   在 Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(IntPtr nativeStatus) 在 D:\a\_work\1\s\csharp\src\Microsoft.ML.OnnxRuntime\NativeApiStatus.shared.cs 中: 第 33 行
   在 Microsoft.ML.OnnxRuntime.InferenceSession.Init(String modelPath, SessionOptions options, PrePackedWeightsContainer prepackedWeightsContainer) 在 D:\a\_work\1\s\csharp\src\Microsoft.ML.OnnxRuntime\InferenceSession.shared.cs 中: 第 1185 行
   在 Microsoft.ML.OnnxRuntime.InferenceSession..ctor(String modelPath) 在 D:\a\_work\1\s\csharp\src\Microsoft.ML.OnnxRuntime\InferenceSession.shared.cs 中: 第 78 行
   在 AIRecipeDll.YoloSegment..ctor(String modelPath, Boolean useGPU) 在 E:\2_Code\Q\QMergeTest\qvision\AIRecipeDll\YoloSegment.cs 中: 第 55 行
   在 AIRecipeDll.AIWire.InitAIWire() 在 E:\2_Code\Q\QMergeTest\qvision\AIRecipeDll\AIWire.cs 中: 第 59 行

  此异常最初是在此调用堆栈中引发的: 
    Microsoft.ML.OnnxRuntime.NativeApiStatus.VerifySuccess(System.IntPtr) (位于 NativeApiStatus.shared.cs 中)
    Microsoft.ML.OnnxRuntime.InferenceSession.Init(string, Microsoft.ML.OnnxRuntime.SessionOptions, Microsoft.ML.OnnxRuntime.PrePackedWeightsContainer) (位于 InferenceSession.shared.cs 中)
    Microsoft.ML.OnnxRuntime.InferenceSession.InferenceSession(string) (位于 InferenceSession.shared.cs 中)
    AIRecipeDll.YoloSegment.YoloSegment(string, bool) (位于 YoloSegment.cs 中)
    AIRecipeDll.AIWire.InitAIWire() (位于 AIWire.cs 中)

二、运行异常分析

1. 使用lm 定位加载的模块Microsoft.ML.OnnxRuntime

比对与正常运行电脑, Microsoft.ML.OnnxRuntime 的版本,发现版本一致。

2. 使用!savemodule保存Microsoft.ML.OnnxRuntime.dll

3. 反编译dll查看依赖dll。

发现引用了onnxruntime.dll

4. 使用lm 查看加载的onnxruntime.dll 版本信息。

发现引用的文件在系统目录下,且版本号与正常电脑版本不一致。

四、解决方法

拷贝正常电脑的onnxruntime.dll 到程序根目录,让程序运行时优先使用该版本dll。

评论