Giter Site home page Giter Site logo

Comments (6)

davmre avatar davmre commented on May 19, 2024 3

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!

from probability.

davmre avatar davmre commented on May 19, 2024 1

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

from probability.

davmre avatar davmre commented on May 19, 2024

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.

from probability.

matthew-mcateer avatar matthew-mcateer commented on May 19, 2024

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

from probability.

pochoi avatar pochoi commented on May 19, 2024

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.

from probability.

davmre avatar davmre commented on May 19, 2024

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.

from probability.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.