[BUG Report]: RuntimeError: Tensorflow.NET cannot find a backend.
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
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:
- Upgrade your runtime version (net core is recommended).
- Find the nuget package under the folder
C:\users\xxx\.nuget\packagesand then extract thetensorflow.dllfrom it. Finally put the dll in the output directory of your project (or add an reference).
This can also be caused by missing visual c++ redist https://aka.ms/vs/17/release/vc_redist.x64.exe
none of the proposed works in my case
Facing same issude right now. @AsakusaRinne
Hello, the dll file cannot be referenced, VS pop-up error
@ @AsakusaRinne
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