SciSharp / TensorFlow.NET

.NET Standard bindings for Google's TensorFlow for developing, training and deploying Machine Learning models in C# and F#.
https://scisharp.github.io/tensorflow-net-docs
Apache License 2.0
3.17k stars 506 forks source link

[BUG Report]: Cannot find backend on Apple Silicon mac #1236

Open ronimizy opened 4 months ago

ronimizy commented 4 months ago

Description

When running on Apple Silicon mac (M1 Pro) exception is thrown

Unhandled exception. System.TypeInitializationException: The type initializer for 'Tensorflow.Binding' threw an exception.
 ---> Tensorflow.RuntimeError: Tensorflow.NET cannot find a backend. Please install one of the following packages for your program: SciSharp.TensorFlow.Redist, SciSharp.TensorFlow.Redist-Linux-GPU, SciSharp.TensorFlow.Redist-Windows-GPU. For more details, please visit https://github.com/SciSharp/TensorFlow.NET. If it still not work after installing the backend, please submit an issue to https://github.com/SciSharp/TensorFlow.NET/issues
   at Tensorflow.tensorflow..ctor()
   at Tensorflow.Binding..cctor()
   --- End of inner exception stack trace ---
   at Tensorflow.Binding.get_tf()
   at Program.<Main>$(String[] args) in /Users/george/Documents/C#/SampleTfNet/SampleTfNet/Program.cs:line 3

Reproduction Steps

create new console app with net8.0 runtime

csproj should look as such

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.16.0" />
        <PackageReference Include="TensorFlow.Keras" Version="0.15.0" />
        <PackageReference Include="TensorFlow.NET" Version="0.150.0" />
    </ItemGroup>

</Project>

paste this into Program.cs:

using static Tensorflow.Binding;

var t = tf;

run project, the exception would be thrown

Known Workarounds

Not found

Configuration and Other Information

SciSharp.TensorFlow.Redist:2.16.0 TensorFlow.Keras:0.15.0 TensorFlow.NET:0.150.0 .net SDK 8.0.100 macOS 14.1

DavidPeralta36 commented 3 months ago

I have the same error but I have a solution with WPF application, I am trying to call tf and I am getting the same (yes, i have SciSharp.TensorFlow.Redist installed)

Configuration and Other Information SciSharp.TensorFlow.Redist:2.16.0 TensorFlow.Keras:0.15.0 TensorFlow.NET:0.150.0

Win 11