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

import error #221

Open
worasom opened this issue Feb 12, 2020 · 3 comments
Open

import error #221

worasom opened this issue Feb 12, 2020 · 3 comments

Comments

@worasom
Copy link

worasom commented Feb 12, 2020

I installed tensorflow 2.1 and pymc4 on window 10 machine. The packages are install in a new venv environment. I can import tensorflow (with some warning), but when trying to import pymc4 I got this error "AttributeError: module 'tensorflow_core.compat.v2.math' has no attribute 'xlog1py'"
I check and found that tensorflow.math.xlog1py throws the same error. Please suggest.

import tensorflow
2020-02-11 09:55:38.474276: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-02-11 09:55:38.482351: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

import pymc4
Traceback (most recent call last):
File "", line 1, in
File "c:\Users\user\pyenv\py36\lib\site-packages\pymc4_init_.py", line 6, in
from . import distributions
File "c:\Users\user\pyenv\py36\lib\site-packages\pymc4\distributions_init_.py", line 1, in
from .continuous import *
File "c:\Users\user\pyenv\py36\lib\site-packages\pymc4\distributions\continuous.py", line 4, in
from tensorflow_probability import distributions as tfd
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability_init_.py", line 76, in
from tensorflow_probability.python import * # pylint: disable=wildcard-import
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python_init_.py", line 21, in
from tensorflow_probability.python import bijectors
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\bijectors_init_.py", line 23, in
from tensorflow_probability.python.bijectors.absolute_value import AbsoluteValue
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\bijectors\absolute_value.py", line 23, in
from tensorflow_probability.python.bijectors import bijector
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\bijectors\bijector.py", line 33, in
from tensorflow_probability.python.internal import distribution_util
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\distribution_util.py", line 28, in
from tensorflow_probability.python.internal import prefer_static
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\prefer_static.py", line 30, in
from tensorflow_probability.python.internal.backend import numpy as nptf
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\backend\numpy_init_.py", line 22, in
from tensorflow_probability.python.internal.backend.numpy import compat
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\compat.py", line 24, in
from tensorflow_probability.python.internal.backend.numpy import v1
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\v1.py", line 37, in
from tensorflow_probability.python.internal.backend.numpy.random_generators import set_seed
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\random_generators.py", line 27, in
from tensorflow_probability.python.internal.backend.numpy.numpy_math import softmax as _softmax
File "c:\Users\user\pyenv\py36\lib\site-packages\tensorflow_probability\python\internal\backend\numpy\numpy_math.py", line 912, in
tf.math.xlog1py,
AttributeError: module 'tensorflow_core.compat.v2.math' has no attribute 'xlog1py'
tensorflow.math.xlog1py
Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'tensorflow_core._api.v2.math' has no attribute 'xlog1py'

@tirthasheshpatel
Copy link
Contributor

tirthasheshpatel commented Feb 12, 2020

Just force upgrade your package using: pip install --upgrade --force tensorflow_probability.
If it doesn't work reinstalling TensorFlow Probability may help!

@worasom
Copy link
Author

worasom commented Feb 13, 2020

I tried upgrade and reinstall, but still does not work.

@lucianopaz
Copy link
Contributor

@worasom, although it will sound strange, the problem you are seeing is caused because you installed the tensorflow package. I'll explain why.

When we started developing pymc4, we made the package depend on tensorflow-nightly, because we wanted to profit from the latest unreleased v2 features. As pymc4 is still quite fluid and not ready for a beta release we haven't switched to depend on the latest official releases on tensorflow and tensorflow_probability.

You may be asking yourself why does this cause an error? The thing is that from pip's (and setuptools) point of view, tensorflow and tensorflow-nightly are two completely unrelated packages. The problem is that in fact they aren't. They both end up populating the exact same directory in your python's site-package directory. This means that if you try to install both tensorflow and tensorflow-nightly, pip will overwrite things incorrectly and you'll end up with a broken installation.
The sequence of things that lead to your error are:

  1. Pip installs tensorflow
  2. Try to pip install pymc4
  3. Pip looks up the pymc4 requirements and finds it needs to install tensorflow-nightly.
  4. Pip installs tensorflow-nightly and breaks the previous tensorflow installation, but pip thinks that everything went great because from its point of view, tensorflow and tensorflow-nightly are completely unrelated packages.
  5. When you try to import pymc4, python fails to import tensorflow and errors out.

How do you fix things? First you'll have to completely uninstall tensorflow. Then you just have to run pip install pymc4 and requirements will be handled automatically.

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

3 participants