-1

We have written a x-plat worker service using .NET 5 that is running on a Raspberry PI 4 (Raspberry Pi OS). We have trained a custom vision object detection model on customvision.ai, exported it to ONNX and it all works well on Windows.

We are now struggling to get it running on the Pi. The ML.NET bits does not seem to work on the Pi. We're getting (with target runtime "linux-arm"):

Microsoft.ML currently supports 'x64' and 'x86' processor architectures. Please ensure your application is targeting 'x64' or 'x86'

We've searched hi and low for any working examples. We've also tried to export to Tensorflow format and explore Tensorflow.NET without any success.

Can anyone point to an example that is consuming a customvision.ai generated model in .NET Core/5 on a Raspberry PI? We are extending an existing prototype and would like to avoid rewriting it all in Python/C++ or create out of process calls.

Versions: ML.NET 1.6, Microsoft.ML.OnnxRuntime 1.8.1

Many thanks,

Mansos

mansos
  • 57
  • 5

2 Answers2

2

Just incase someone else lands here...

The release ML.Net NuGets (mid Dec 2021) now have support for linux-aarch64, linux-arm, linux-arm64, Windows-x64 etc.

If you're still interested I have have a couple of blog posts about my "learning journey" getting a pretrained ONNX model working on RPI4B + Bullseye and ASUS PE100A + Ubuntu

@KiwiBryn

Bryn Lewis
  • 36
  • 2
  • Hi Bryn, I have exactly the same problem. Great that you could get ML.Net running on arm64. I looked into your blog post, but I have problems. I got the newest Microsoft.ML nuget package version 1.7. But I still get the error "only for x64" when publishing. Also I heard that tensorflow models are not supported on arm64. How did you get your onnx model, did you convert it from tensorflow? Would really appriciate anyhelp :-) – Jojo71 Dec 27 '21 at 15:53
  • ok, in the publish profile settings I changed target to portable instead of linux-arm64. Now I can publish. Also I installed the onnxruntime nuget package. But on the raspi I get the error: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'onnxruntime' or one of its dependencies. How can I install libonnxruntime on the raspi? – Jojo71 Dec 27 '21 at 17:04
  • ok, solved it. Followed the instructions here: https://stackoverflow.com/questions/63420533/setting-up-onnx-runtime-on-ubuntu-20-04-c-api to get arm64 version of libonnxruntime from the nuget package for arm64 – Jojo71 Dec 27 '21 at 17:19
  • 1
    I use Visual Studio 2K19 (+some so custom deployment glue) and after "publishing" the application locally there are a series of subfolders (I assume extracted from the Microsoft.ML.OnnxRuntime NuGet) containing the runtimes for the supported platforms. Part of my deployment process then copies the required runtime to the application folder. For my RPI/ASUS PE100 applications it's "TheFolderApplicationisPublishedTo">runtimes>linux-aarch64>native>libonnxruntime.so – Bryn Lewis Dec 29 '21 at 00:07
0

Are you running an Uno Platform app to capture a picture from the camera module (or usb webcam) in your Pi4 and running ML.Net too?

Manuel Hernandez
  • 581
  • 1
  • 7
  • 11