TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

[BUG Report]: RuntimeError: Tensorflow.NET cannot find a backend.

Open nikescar1 opened this issue 2 years ago • 8 comments

Description

I make a fresh project, install the packages, run the example code, and get the following error.

System.TypeInitializationException HResult=0x80131534 Message=The type initializer for 'Tensorflow.Binding' threw an exception. Source=Tensorflow.Binding StackTrace: at Tensorflow.Binding.get_tf() at Tensorflow.NumPy.AutoNumPyAttribute.OnEntry(MethodExecutionArgs args) at Tensorflow.NumPy.np.array[T](T[] data) at TensorFlowTesting.Program.Main(String[] args) in C:\Users\nikes\Documents\source\repos\TensorFlowTesting\Program.cs:line 23

This exception was originally thrown at this call stack: Tensorflow.tensorflow.tensorflow() Tensorflow.Binding.Binding()

Inner Exception 1: 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

If any other info is needed I'd be glad to provide it.

Reproduction Steps

I installed packages like so: Install-Package TensorFlow.NET Install-Package TensorFlow.Keras Install-Package SciSharp.TensorFlow.Redist

When I run the example code I get the above error.

Known Workarounds

No response

Configuration and Other Information

  • Windows 11 PC
  • Visual Studio 17.7.2
  • New Console App using .Net Framework 4.7.2

nikescar1 avatar Sep 25 '23 04:09 nikescar1

Many apologizes for seeing this late. I'm too busy these days to watch all the issues. This is a known problem that .NET Framework does not have good support for backend package. There're generally two ways to solve it:

  1. Upgrade your runtime version (net core is recommended).
  2. Find the nuget package under the folder C:\users\xxx\.nuget\packages and then extract the tensorflow.dll from it. Finally put the dll in the output directory of your project (or add an reference).

SanftMonster avatar Oct 27 '23 08:10 SanftMonster

This can also be caused by missing visual c++ redist https://aka.ms/vs/17/release/vc_redist.x64.exe

OwenSSH avatar Jan 08 '24 19:01 OwenSSH

none of the proposed works in my case

jaroslav-hook avatar Jan 10 '24 16:01 jaroslav-hook

Facing same issude right now. @AsakusaRinne

Folasayo-Samuel avatar May 27 '24 07:05 Folasayo-Samuel

Hello, the dll file cannot be referenced, VS pop-up error 1716818981238 @ @AsakusaRinne

nihao-git avatar May 27 '24 14:05 nihao-git

To resolve the issue with macOS:

CPU version for MacOS

PM> Install-Package SciSharp.TensorFlow.Redist-OSX

CPU version for Windows and Linux

PM> Install-Package SciSharp.TensorFlow.Redist

GPU version for Windows (CUDA and cuDNN are required)

PM> Install-Package SciSharp.TensorFlow.Redist-Windows-GPU

GPU version for Linux (CUDA and cuDNN are required)

PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU

Folasayo-Samuel avatar Jun 30 '24 18:06 Folasayo-Samuel