Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Dependency in C# Tensorflow.NET #7869

Open
4 tasks done
LouisSzeto opened this issue Mar 22, 2024 · 0 comments
Open
4 tasks done

Missing Dependency in C# Tensorflow.NET #7869

LouisSzeto opened this issue Mar 22, 2024 · 0 comments

Comments

@LouisSzeto
Copy link
Collaborator

Actual Behavior

C# Tensorflow.NET package only handles Tensorflow.Numpy.NDArray but not NumSharp.NDArray type. Lean is not able to handle Tensorflow.Numpy.NDArray with the following error:

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 Tensorflow.NumPy.AutoNumPyAttribute.OnEntry(MethodExecutionArgs args)
   at Tensorflow.NumPy.np.zeros(Shape shape, TF_DataType dtype)
   at Submission#6.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   at Tensorflow.Binding.get_tf()
   at Tensorflow.NumPy.AutoNumPyAttribute.OnEntry(MethodExecutionArgs args)
   at Tensorflow.NumPy.np.zeros(Shape shape, TF_DataType dtype)
   at Submission#6.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)

And also cannot load the Tensorflow backend

System.DllNotFoundException: Unable to load shared library 'tensorflow' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libtensorflow: cannot open shared object file: No such file or directory
   at Tensorflow.c_api.TF_NewGraph()
   at Tensorflow.Graph..ctor()
   at Tensorflow.DefaultGraphStack.get_default()
   at Tensorflow.ops.get_default_graph()
   at Tensorflow.Keras.Utils.base_layer_utils.get_default_graph_uid_map()
   at Tensorflow.Keras.Utils.base_layer_utils.unique_layer_name(String name, Dictionary`2 name_uid_map, String[] avoid_names, Boolean zero_based)
   at Tensorflow.Keras.Engine.Layer._init_set_name(String name, Boolean zero_based)
   at Tensorflow.Keras.Engine.Layer.Initialize(LayerArgs args)
   at Tensorflow.Keras.Engine.Layer..ctor(LayerArgs args)
   at Tensorflow.Keras.Layers.InputLayer..ctor(InputLayerArgs args)
   at Tensorflow.Keras.Layers.LayersApi.Input(Shape shape, Int32 batch_size, String name, TF_DataType dtype, Boolean sparse, Tensor tensor, Boolean ragged, TypeSpec type_spec, Shape batch_input_shape, Shape batch_shape)
   at Tensorflow.Keras.KerasInterface.Input(Shape shape, Int32 batch_size, String name, TF_DataType dtype, Boolean sparse, Tensor tensor, Boolean ragged, TypeSpec type_spec, Shape batch_input_shape, Shape batch_shape)
   at Submission#7.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
   at Tensorflow.c_api.TF_NewGraph()
   at Tensorflow.Graph..ctor()
   at Tensorflow.DefaultGraphStack.get_default()
   at Tensorflow.ops.get_default_graph()
   at Tensorflow.Keras.Utils.base_layer_utils.get_default_graph_uid_map()
   at Tensorflow.Keras.Utils.base_layer_utils.unique_layer_name(String name, Dictionary`2 name_uid_map, String[] avoid_names, Boolean zero_based)
   at Tensorflow.Keras.Engine.Layer._init_set_name(String name, Boolean zero_based)
   at Tensorflow.Keras.Engine.Layer.Initialize(LayerArgs args)
   at Tensorflow.Keras.Engine.Layer..ctor(LayerArgs args)
...
   at Tensorflow.Keras.Layers.LayersApi.Input(Shape shape, Int32 batch_size, String name, TF_DataType dtype, Boolean sparse, Tensor tensor, Boolean ragged, TypeSpec type_spec, Shape batch_input_shape, Shape batch_shape)
   at Tensorflow.Keras.KerasInterface.Input(Shape shape, Int32 batch_size, String name, TF_DataType dtype, Boolean sparse, Tensor tensor, Boolean ragged, TypeSpec type_spec, Shape batch_input_shape, Shape batch_shape)
   at Submission#7.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)

Potential Solution

Install the tensorflow backend (python?)

Reproducing the Problem

https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_3b956d04556623f3e73a03e5b7905d58.html
Run the notebook

System Information

QC cloud

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants