stefanradev93 / BayesFlow

A Python library for amortized Bayesian workflows using generative neural networks.
https://bayesflow.org/
MIT License
286 stars 45 forks source link

Dependency problems #148

Closed vpratz closed 4 months ago

vpratz commented 4 months ago

It seems that updates to TensorFlow, TensorFlow probability or Keras introduce installation problems.

When I install the current Development branch in a fresh Python 3.10 environment with pip install -e ., it installs tensorflow-2.16.1, tensorflow-probability-0.24.0 and keras-3.0.5. The resulting error below is similar to what is observed in this thread, so it seems to affect regular users as well. Just adding the dependency does not work and seems to introduce different problems.

$ python  
Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bayesflow
[...]

Failed to import TF-Keras. Please note that TF-Keras is not installed by default when you install TensorFlow Probability. This is so that JAX-only users do not have to install TensorFlow or TF-Keras. To use TensorFlow Probability with TensorFlow, please install the tf-keras or tf-keras-nightly package.
This can be be done through installing the tensorflow-probability[tf] extra.

WARNING:root:Some dependencies failed to load. BayesFlow modules may not work properly!
WARNING:root:No module named 'tf_keras'

I'd suggest we track down a working combination and pin the dependencies until we figure out how to move on.

For tensorflow-probability==0.23.0 I get AttributeError: module 'keras._tf_keras.keras' has no attribute '__internal__' which is referenced here.

Tagging @LarsKue: Which versions are you using for the changes you are currently working on? Will your changes resolve this problem or is this something we have to resolve independently?

vpratz commented 4 months ago

Already resolved by @LarsKue in 8971780, I hadn't pulled the commit yet