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

Installation on Colab.research.google.com? #35

Closed
junpenglao opened this issue May 10, 2018 · 6 comments
Closed

Installation on Colab.research.google.com? #35

junpenglao opened this issue May 10, 2018 · 6 comments

Comments

@junpenglao
Copy link
Contributor

junpenglao commented May 10, 2018

I am trying to install tensorflow-probability with the following script on a Colab notebook:

!pip3 install -q --user --upgrade tfp-nightly
import tensorflow_probability as tfp

However it doesnt work:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-791d55ac0b39> in <module>()
      1 get_ipython().system('pip3 install -q --user --upgrade tfp-nightly')
----> 2 import tensorflow_probability as tfp

ModuleNotFoundError: No module named 'tensorflow_probability'

---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------

Am I doing it correctly? Is it possible to install it on Colab?

@davmre
Copy link
Contributor

davmre commented May 10, 2018

Hi Junpeng, that's a great question! The install works for me just running "!pip3 install tfp-nightly" -- I believe the '--user' flag isn't necessary in colab since everything is run in a sandbox by default. However, once installed, I'm seeing the import itself still fail with "ImportError: cannot import name 'seed_stream'" from tensorflow.contrib.distributions.python.ops, which seems to indicate that Colab is preferring its own version of TensorFlow over the nightly package which TFP depends on.

We're certainly interested in making sure TFP works from Colab; we'll engage with the Colab team internally to work this out, and keep you posted. If you or anyone else discovers a workaround in the meantime, feel free to share!

@davmre
Copy link
Contributor

davmre commented May 11, 2018

For what it's worth, using a Python2.7 colab seems to work fine for me, running "!pip install tfp-nightly", so that's an (admittedly imperfect) potential workaround.

@davmre
Copy link
Contributor

davmre commented May 14, 2018

After some discussion with the Colab team: there's a TF release bug that's causing Python 3 colabs to pull in an outdated version of tf-nightly. When this is fixed, !pip install tfp-nightly will work in Python 3 colabs just as it currently does in Python 2 colabs.

(in the slightly longer term we hope to include TFP in the default colab install, but this should wait until we have a release that depends on stable Tensorflow).

@matthew-mcateer
Copy link
Contributor

matthew-mcateer commented May 19, 2018

It looks like the Colabs now update with more up-to-date TFP packages. This one can probably be closed.

@pochoi
Copy link
Contributor

pochoi commented Jun 18, 2018

On Google Colab Python 2 without GPU, I run

!pip install --upgrade tfp-nightly

Then in import tensorflow as tf I got the error in #46.
In import tensorflow_probability as tfp, I got

ImportErrorTraceback (most recent call last)
<ipython-input-2-41494c8c96ff> in <module>()
----> 1 import tensorflow_probability as tfp

/usr/local/lib/python2.7/dist-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

/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/__init__.py in <module>()
     19 from __future__ import print_function
     20 
---> 21 from tensorflow_probability.python import distributions
     22 from tensorflow_probability.python import edward2
     23 from tensorflow_probability.python import glm

/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/distributions/__init__.py in <module>()
     20 # pylint: disable=unused-import,line-too-long,g-importing-member
     21 
---> 22 from tensorflow_probability.python.distributions import bijectors
     23 
     24 from tensorflow_probability.python.distributions.autoregressive import Autoregressive

/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/distributions/bijectors/__init__.py in <module>()
     21 # pylint: disable=unused-import,wildcard-import,line-too-long,g-importing-member
     22 
---> 23 from tensorflow_probability.python.distributions.bijectors.absolute_value import AbsoluteValue
     24 from tensorflow_probability.python.distributions.bijectors.affine import Affine
     25 from tensorflow_probability.python.distributions.bijectors.affine_linear_operator import AffineLinearOperator

/usr/local/lib/python2.7/dist-packages/tensorflow_probability/python/distributions/bijectors/absolute_value.py in <module>()
     19 from __future__ import print_function
     20 
---> 21 import tensorflow as tf
     22 from tensorflow.python.ops import control_flow_ops
     23 from tensorflow.python.ops.distributions import bijector

/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py in <module>()
     20 
     21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
     23 from . import app
     24 from . import bitwise

/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py in <module>()
     47 import numpy as np
     48 
---> 49 from tensorflow.python import pywrap_tensorflow
     50 
     51 # Protocol buffers

ImportError: cannot import name pywrap_tensorflow

On Google Colab Python 3 without GPU, I do the same thing.
Not sure why, after !pip, I need to "Restart runtime..." before import tensorflow and tensorflow_probability. Then I can successfully import them without the errors appear in Python 2 Colab.

@davmre
Copy link
Contributor

davmre commented Nov 19, 2018

FYI: TFP releases are now installed by default in Colab, so import tensorflow_probability as tfp should 'just work' now without any installation steps.

Closing this issue; feel free to reopen if you run into problems.

@davmre davmre closed this as completed Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants