dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
8.99k stars 1.88k forks source link

Image classification can't run on CPU that doesn't support AVX instruction #5341

Open LittleLittleCloud opened 4 years ago

LittleLittleCloud commented 4 years ago

System information

Issue

We have a few users from Model Builder report on image classification failure because of loading error.

After some investigation, I think it is because their CPU is too old and doesn't support AVX instruction, which is used to build tensorflow after v1.6. But I'm not too sure about it, and that conclusion need double check.

In the meanwhile, it would be great if we can catch the instruction not support error from exception thrown by mlnet. Right now the error message is "Tensorflow exception triggered while loading model", which is not really helpful in debugging. Is it possible to have a new exception, or a specific error message to highlight the avx not support exception?

brendantaylor-res commented 1 year ago

I have encountered this issue running ML.NET on an Intel Atom E3940 Quad Core. I'm trying to deploy an image classification model, developed on my development laptop, to an edge device running the Atom processor. Runs fine on my laptop. On the edge device it crashes with an illegal instruction error when I try to classify an image. The research I've done supports the OP's assertion that AVX instructions are compiled into Tensorflow with optimization settings, and lower-end processors (Atom, Celeron, Pentium) don't support those instructions.

    <PackageReference Include="Microsoft.ML" Version="2.0.1" />
    <PackageReference Include="Microsoft.ML.Vision" Version="2.0.1" />
    <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.11.0" />

Is it possible there's a build that does not have the AVX optimizations? I've seen posts on building Tensorflow from source, but they all seem oriented toward building a wheel for Python. I'm not sure how that is related to the ML.NET environment. I don't think it's using Python under the hood, but maybe I'm wrong about that. Any guidance is much appreciated!