简体   繁体   English

将 ML.net 与 ONNX model 和 GPU 结合使用

[英]Using ML.net with an ONNX model and GPU

How do you get Microsof.tML to run on an NVDIA GPU using C#?如何使用 C# 让 Microsof.tML 在 NVDIA GPU 上运行? I followed the instructions我按照说明操作

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

And my pipeline looks like the below.我的管道如下所示。 All versions dependencies (onnxruntime.gpu,Microsoft.ML etc) are 1.5.2 so this should be supported but I get the exception DllNotFoundException: Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found - and yes onnxruntime does appear in the list of installed nuget packages.所有版本依赖项(onnxruntime.gpu、Microsoft.ML 等)都是 1.5.2,因此应该支持,但我得到异常 DllNotFoundException:无法加载 DLL 'onnxruntime' 或其依赖项之一:找不到指定的模块 -是的,onnxruntime 确实出现在已安装的 nuget 软件包列表中。

Has anyone gotten this to work?有没有人让这个工作? The documentation is still pretty sparse and there don't seem to be any working examples online.该文档仍然非常稀疏,似乎没有任何在线工作示例。

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)
);

OK - bad form to answer my own question but the link above saying you must use Cuda 10 seems inaccurate.好的 - 回答我自己的问题的形式不好,但上面说您必须使用 Cuda 10 的链接似乎不准确。 If you are using the ML.net 1.5 nuget releases you need Cuda 10.2.如果您使用的是 ML.net 1.5 nuget 版本,则需要 Cuda 10.2。

11 won't work unless you build from source (and who has the time for that).除非您从源代码构建(并且谁有时间),否则 11 将无法工作。

Hopefully this solves it but if you were going to comment please do as well!希望这能解决它,但如果您要发表评论,请也这样做!

Here is the compatibility chart.这是兼容性图表。 Newer versions have different compatibilities.较新的版本具有不同的兼容性。

The CUDA Execution Provider enables hardware accelerated computation on Nvidia CUDA-enabled GPUs: CUDA Execution Provider 在支持 Nvidia CUDA 的 GPU 上启用硬件加速计算:

https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM