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 507 forks source link

Tensor.NET can not find a Tensor Backend #1156

Open sang416 opened 12 months ago

sang416 commented 12 months ago

Description

using System;
using Tensorflow;
using static Tensorflow.Binding;
using System.Diagnostics;

class TensorEX {
    static void Main() {
        var watch = Stopwatch.StartNew();
        var shape = new int[] { 10000, 10000 };
        var randomMatrix = tf.random.uniform(shape: shape, minval: 0, maxval: 1f);
        var dotOperation = tf.linalg.matmul(randomMatrix, randomMatrix);
        var sumOperation = tf.reduce_sum(dotOperation);
        var result = sumOperation.numpy();
        Console.WriteLine($"Tensor computing result: {result}");
        watch.Stop();
        Console.WriteLine($"Time taken: {watch.ElapsedMilliseconds} ms");
    }
}

dotnet add package TensorFlow.NET dotnet add package TensorFlow.Keras dotnet add package SciSharp.TensorFlow.Redist

My system is running on Mac OS 13.4.1 (Ventura), and even though I've installed all three items mentioned, I'm still getting the message below. I've already installed the Python Tensorflow package and even included the project path in the PATH, but the message still pops up

20230723-162658

Wanglongzhi2001 commented 11 months ago

Hello, you can refer to #1141. If there still exist some problem, please let me know.

FuzzyNat26 commented 11 months ago

Hello @sang416! Do you succeed in solving the issues?

Currently I'm also using Ventura 13.4.1 on M1. Even though I already installed the SciSharp.TensorFlow.Redist-OSX (using nuget), it still brings up the same exception messages.

sang416 commented 11 months ago

Hello @sang416! Do you succeed in solving the issues?

Currently I'm also using Ventura 13.4.1 on M1. Even though I already installed the SciSharp.TensorFlow.Redist-OSX (using nuget), it still brings up the same exception messages.

No, I tried again referring to #1141 above, but it's still not working. Do you happen to know a solution?

FuzzyNat26 commented 11 months ago

Hello @sang416! Do you succeed in solving the issues? Currently I'm also using Ventura 13.4.1 on M1. Even though I already installed the SciSharp.TensorFlow.Redist-OSX (using nuget), it still brings up the same exception messages.

No, I tried again referring to #1141 above, but it's still not working. Do you happen to know a solution?

Nope. As I'm developing for my Unity project, I used Barracuda as the inference library for now. Although, it has its own issues too.

I'll update to this issue if there's any solution that I found 👍

infusixllc commented 9 months ago

I've installed the SciSharp.TensorFlow.Redist-OSX package which does indeed add the arm64 libtensorflow*.dylib but it puts them in the runtimes/osx-x64 directory. If you manually move these over to runtimes/osx-arm64 (which I did as a build step) it gets further. However there is something else wrong with the library

Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named 'TFC_GetHandleShapeAndType' in shared library 'tensorflow'.

This is at the fit step so it does get through creating the model so it does work somewhat. But this symbol TFC_GetHandleShapeAndType is not in the arm64 library at all (at least searched via strings) but it is in the linux x64 .so file.

ByMedion commented 5 months ago

Hello! Any news for Apple Silicon?