Addons: import tensorflow_addons gives AttributeError: module 'tensorflow_core._api.v2.random' has no attribute 'Generator'

Created on 14 Jun 2020  路  4Comments  路  Source: tensorflow/addons

System information
I am running my this on a docker container which has these specifications:

  • OS Platform and Distribution: Linux Ubuntu 16.04.
  • TensorFlow version: 2.1.0
  • TensorFlow-Addons version: I think it's the lastest, bc I installed it with pip install tensorflow-addons
  • Python version: Python 3.6.9
  • Is GPU used?: Yes

Describe the bug
I am running a simple command import tensorflow_addons as tfa on my docker container, but this error. I don't why this is happening. Other people got the same problem like me. (for example this). I have no idea why this is happening!
Code to reproduce the issue

root@admin:/config# python -c 'import tensorflow_addons as tfa'
2020-06-14 03:27:48.281948: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic lib
rary 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory; LD_LIBRAR
Y_PATH: /usr/local/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
2020-06-14 03:27:48.282118: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic lib
rary 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or direct
ory; LD_LIBRARY_PATH: /usr/local/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
2020-06-14 03:27:48.282159: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT librar
ies. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are ins
talled properly.
/usr/local/lib/python3.6/dist-packages/tensorflow_addons/utils/ensure_tf_install.py:68: UserWarning: Tensorflow Addons
 supports using Python ops for all Tensorflow versions above or equal to 2.2.0 and strictly below 2.3.0 (nightly versi
ons are not supported).
 The versions of TensorFlow you are currently using is 2.1.0 and is not supported.
Some things might work, some things might not.
If you were to encounter a bug, do not file an issue.
If you want to make sure you're using a tested and supported configuration, either change the TensorFlow version or th
e TensorFlow Addons's version.
You can find the compatibility matrix in TensorFlow Addon's readme:
https://github.com/tensorflow/addons
  UserWarning,
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_addons/__init__.py", line 21, in <module>
    from tensorflow_addons import activations
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_addons/activations/__init__.py", line 22, in <module>
    from tensorflow_addons.activations.rrelu import rrelu
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_addons/activations/rrelu.py", line 28, in <module>
    rng: Optional[tf.random.Generator] = None,
AttributeError: module 'tensorflow_core._api.v2.random' has no attribute 'Generator'

Most helpful comment

I'm sorry. I was wrong. I was using TF 2.1. I downgraded to TFA 0.9.1 and the problem solved.

All 4 comments

I think the problem is with my Tensorflow version. I should upgrade it to 2.2.0 or above.

UserWarning: Tensorflow Addons supports using Python ops for all Tensorflow versions above or equal to 2.2.0 and strictly below 2.3.0 (nightly versi ons are not supported). The versions of TensorFlow you are currently using is 2.1.0 and is not supported.

TFA still throws this error in TensorFlow-mkl 2.2 on windows.

TFA still throws this error in TensorFlow-mkl 2.2 on windows.

Hi @k1moradi, can you open a new issue for it with your detailed addons version? Thanks!

I'm sorry. I was wrong. I was using TF 2.1. I downgraded to TFA 0.9.1 and the problem solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanpmorgan picture seanpmorgan  路  3Comments

iskorini picture iskorini  路  4Comments

facaiy picture facaiy  路  3Comments

seanpmorgan picture seanpmorgan  路  4Comments

seanpmorgan picture seanpmorgan  路  3Comments