dotnet-smartcomponents / smartcomponents

Experimental, end-to-end AI features for .NET apps
622 stars 54 forks source link

Unable to run in aspnet:8.0-alpine #26

Closed feffe81 closed 3 months ago

feffe81 commented 3 months ago

When running as docker container I get

Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception. 2024-03-22T11:16:16.853868543+01:00 ---> System.DllNotFoundException: Unable to load shared library 'onnxruntime' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 2024-03-22T11:16:16.853882633+01:00 Error loading shared library /app/runtimes/linux-x64/native/onnxruntime.so: No such file or directory 2024-03-22T11:16:16.853892674+01:00 Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.3/onnxruntime.so: No such file or directory 2024-03-22T11:16:16.853902558+01:00 Error loading shared library /app/onnxruntime.so: No such file or directory

Any hint or example project available? Many thanks.

SteveSandersonMS commented 3 months ago

Looks like this might be the steps you need: https://stackoverflow.com/questions/67457600/adding-onnxruntime-library-to-a-net-core-docker-container-for-linux

I'll close since this seems like the answer, but if not please let us know!

SteveSandersonMS commented 3 months ago

No wait, that's not quite it.

It looks like ONNX runtime doesn't currently have prebuilt binaries for Alpine (https://github.com/microsoft/onnxruntime/issues/2909), so you'd have to either:

This is out of scope for what we'd solve inside this repo. To move forwards most easily, I'd definitely recommend using a base image that ONNX does support natively, e.g., mcr.microsoft.com/dotnet/aspnet:8.0.

feffe81 commented 3 months ago

Ok. Thanks. I am using the image you mentioned now.