tensorflow / probability

Probabilistic reasoning and statistical analysis in TensorFlow
https://www.tensorflow.org/probability/
Apache License 2.0
4.27k stars 1.11k forks source link

seed_stream.py ImportError & Cannot upgrade to anything later than tf-nightly 1.8.x #39

Closed matthew-mcateer closed 6 years ago

matthew-mcateer commented 6 years ago

I've been running into a bit of trouble with installing tensorflow_probability.

Installation works fine on Ubuntu 16.04, but trying to install it on Windows or Google Colab (for Python3, at least).

Whenever I try to import tensorflow_probability, it runs into an error like the following:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-31-d5c6f05abbe6> in <module>()
     10 
     11 import tensorflow as tf # importing Tensorflow
---> 12 import tensorflow_probability as tfp # and Tensorflow probability
     13 from tensorflow_probability import edward2 as ed # Edwardlib extension
     14 import warnings

/content/.local/lib/python3.6/site-packages/tensorflow_probability/__init__.py in <module>()
     19 
     20 # from tensorflow_probability.google import staging  # DisableOnExport
---> 21 from tensorflow_probability.python import *  # pylint: disable=wildcard-import

/content/.local/lib/python3.6/site-packages/tensorflow_probability/python/__init__.py in <module>()
     22 from tensorflow_probability.python import glm
     23 from tensorflow_probability.python import layers
---> 24 from tensorflow_probability.python import mcmc
     25 from tensorflow_probability.python import monte_carlo
     26 from tensorflow_probability.python import optimizer

/content/.local/lib/python3.6/site-packages/tensorflow_probability/python/mcmc/__init__.py in <module>()
     24 from tensorflow_probability.python.mcmc.hmc import UncalibratedHamiltonianMonteCarlo
     25 from tensorflow_probability.python.mcmc.kernel import TransitionKernel
---> 26 from tensorflow_probability.python.mcmc.langevin import MetropolisAdjustedLangevinAlgorithm
     27 from tensorflow_probability.python.mcmc.langevin import UncalibratedLangevin
     28 from tensorflow_probability.python.mcmc.metropolis_hastings import MetropolisHastings

/content/.local/lib/python3.6/site-packages/tensorflow_probability/python/mcmc/langevin.py in <module>()
     28 from tensorflow_probability.python.mcmc import util as mcmc_util
     29 
---> 30 from tensorflow.contrib.distributions.python.ops import seed_stream
     31 from tensorflow.python.ops.distributions import util as distributions_util
     32 

ImportError: cannot import name 'seed_stream'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

It appears that on Ubuntu, tf-nightly==1.9.0.dev20180509, tfp-nightly==0.0.1.dev20180510, & tb-nightly==1.9.0a20180426 are correctly installing. On any other machine, however, no version beyond 1.8.x is available from pip. This appears to be the source of the dependency errors, but so far it's defied installation using Anaconda and on Google Colab.

Any ideas what might be causing this? (the reason I've been trying to install it in other environments is that my specific Ubuntu machine just doesn't have decent CPU capacity, not to mention nonexistenc GPU capacity)

michalisfrangos commented 6 years ago

Hi Matthew , just referencing this issue as I have been trying to solve this for a while now.. #24 latest comment.

srvasude commented 6 years ago

I'm sending a patch to directly import SeedStream (from tf.contrib.distributions).

To me an issue like this means that there are some non-hermetic assumptions we are making (i.e. we can import tensorflow internals) which don't seem to break internally, and break in some cases externally.

Trying to figure out what the best way forward for this is (I suspect even the line below: from tensorflow.python.ops.distributions import util as distributions_util, will cause an error after this change).

srvasude commented 6 years ago

@matthew-mcateer

Hi Matthew, Tensorflow Probability currently depends on tf-nightly at the moment, hence right now the best way forward is to install tfp by pip install --upgrade tfp-nightly

The reason this (and other issues) are coming up is some of our code is in tensorflow core (tf distributions) and some lies in this repo. Hence, when we make changes to core and use them, we require tfp to depend on tf-nightly (so that we have these new changes). In the near future, we'll be having more stable TFP releases, depending on stable TF versions, so this will hopefully not be so much of an issue.

@michalisfrangos Just to confirm, what is the nightly version here (is this a recent nightly, or is this dependent on tf 1.8)?

michalisfrangos commented 6 years ago

Hi Srinivas,

There was another upgrade from tfp-nightly I believe... I have just upgraded using pip install --upgrade tfp-nightly:

srvasude commented 6 years ago

Ok I think I have full picture here now:

For Google Colab, there's a known issue with Python 3 colabs that are using an older version of tf-nightly #35. What's recommended is to use Python 2 colabs, and that issue should go away.

For Windows, I think the windows version of tf-nightly is also behind (although for another reason).

I think right now what is recommended is either use Google colab with python 2, and/or pip install in a Linux environment.

I apologize for the back and forth on this! I think once we move to a more stable release cycle, issues like these will disappear.

matthew-mcateer commented 6 years ago

Okay, it seems like this particular import problem has been fixed. There are a few others that have replaced it, but I think for now I'll close this issue.