首页 > 解决方案 > 将 ML.net 与 ONNX 模型和 GPU 一起使用

问题描述

如何使用 C# 让 Microsof.tML 在 NVDIA GPU 上运行?我按照指示

https://github.com/dotnet/machinelearning/blob/master/docs/api-reference/tensorflow-usage.md

我的管道如下所示。所有版本依赖项(onnxruntime.gpu、Microsoft.ML 等)都是 1.5.2,因此应该支持它,但我得到异常 DllNotFoundException:无法加载 DLL 'onnxruntime' 或其依赖项之一:找不到指定的模块 -是的 onnxruntime 确实出现在已安装的 nuget 包列表中。

有没有人让这个工作?文档仍然很稀疏,并且似乎没有任何在线示例。

var pipeline = context.Transforms.ResizeImages(
    resizing: ImageResizingEstimator.ResizingKind.Fill,
    outputColumnName: "image", imageWidth: ImageSettings.imageWidth,
    imageHeight: ImageSettings.imageHeight,
    inputColumnName: nameof(ModelInput.Image)
)
.Append(context.Transforms.ExtractPixels(outputColumnName: "image"))
.Append(context.Transforms.ApplyOnnxModel(
    modelFile: "./ObjectDetection/tinyyolov2-8.onnx",
    outputColumnName: "grid", 
    inputColumnName: "image", 
    gpuDeviceId:0)
);

标签: c#microsoft.ml

解决方案


好的 - 回答我自己的问题的形式不好,但上面的链接说你必须使用 Cuda 10 似乎不准确。如果您使用的是 ML.net 1.5 nuget 版本,则需要 Cuda 10.2。

除非您从源代码构建(以及谁有时间),否则 11 将无法工作。

希望这可以解决它,但如果您要发表评论,请也这样做!


推荐阅读