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

AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike' #135

Closed
aik7 opened this issue Apr 6, 2021 · 10 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@aik7
Copy link
Collaborator

aik7 commented Apr 6, 2021

If I used develop or h2o_cluster_new branch, I get the following error, am I using different version of tensorflow?

 Traceback (most recent call last):
  File "driver/driver.py", line 15, in <module>
    exa_learner = erl.ExaLearner(comm)
  File "/home/kagawa/ExaRL/exarl/learner_base.py", line 65, in __init__
    self.agent, self.env, self.workflow = self.make()
  File "/home/kagawa/ExaRL/exarl/learner_base.py", line 83, in make
    agent = agents.make(self.agent_id, env=env)
  File "/home/kagawa/ExaRL/agents/registration.py", line 97, in make
    return registry.make(id, **kwargs)
  File "/home/kagawa/ExaRL/agents/registration.py", line 57, in make
    agent = spec.make(**kwargs)
  File "/home/kagawa/ExaRL/agents/registration.py", line 42, in make
    agent = cls(**_kwargs)
  File "/home/kagawa/ExaRL/agents/agent_vault/dqn.py", line 129, in __init__
    self.target_model = self._build_model()
  File "/home/kagawa/ExaRL/agents/agent_vault/dqn.py", line 155, in _build_model
    return build_model(self)
  File "/home/kagawa/ExaRL/agents/agent_vault/_build_lstm.py", line 14, in build_model
    return_sequences=True, input_shape=(1, self.env.observation_space.shape[0])))
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/engine/sequential.py", line 166, in add
    layer(x)
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/layers/recurrent.py", line 541, in __call__
    return super(RNN, self).__call__(inputs, **kwargs)
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 75, in symbolic_fn_wrapper
    return func(*args, **kwargs)
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/engine/base_layer.py", line 446, in __call__
    self.assert_input_compatibility(inputs)
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/engine/base_layer.py", line 310, in assert_input_compatibility
    K.is_keras_tensor(x)
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 695, in is_keras_tensor
    if not is_tensor(x):
  File "/home/kagawa/.local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 703, in is_tensor
    return isinstance(x, tf_ops._TensorLike) or tf_ops.is_dense_tensor_like(x)
AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike'
@aik7 aik7 added the invalid This doesn't seem right label Apr 6, 2021
@aik7 aik7 assigned aik7 and schr476 and unassigned aik7 Apr 6, 2021
@jmohdyusof
Copy link
Collaborator

Post the exact command line being used

@aik7
Copy link
Collaborator Author

aik7 commented Apr 6, 2021

python driver/driver.py

using EnvCH-v0 env.

@schr476
Copy link
Contributor

schr476 commented Apr 6, 2021

can you please provide your conda list

@aik7
Copy link
Collaborator Author

aik7 commented Apr 6, 2021

# packages in environment at /home/kagawa/anaconda3/envs/exarl:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_tflow_select             2.3.0                       mkl  
absl-py                   0.12.0           py37h06a4308_0  
aiohttp                   3.7.4            py37h27cfd23_1  
asteval                   0.9.23                   pypi_0    pypi
astunparse                1.6.3                      py_0  
async-timeout             3.0.1            py37h06a4308_0  
attrs                     20.3.0             pyhd3eb1b0_0  
autopep8                  1.5.6                    pypi_0    pypi
blas                      1.0                         mkl  
blinker                   1.4              py37h06a4308_0  
brotlipy                  0.7.0           py37h27cfd23_1003  
c-ares                    1.17.1               h27cfd23_0  
ca-certificates           2021.1.19            h06a4308_1  
cached-property           1.5.2                    pypi_0    pypi
cachetools                4.2.1              pyhd3eb1b0_0  
certifi                   2020.12.5        py37h06a4308_0  
cffi                      1.14.5           py37h261ae71_0  
chardet                   3.0.4           py37h06a4308_1003  
click                     7.1.2              pyhd3eb1b0_0  
cloudpickle               1.6.0                    pypi_0    pypi
coverage                  5.5              py37h27cfd23_2  
cryptography              3.4.6            py37hd23ed53_0  
cycler                    0.10.0                   pypi_0    pypi
cython                    0.29.22          py37h2531618_0  
exarl                     0.0.1                     dev_0    <develop>
flake8                    3.9.0                    pypi_0    pypi
future                    0.18.2                   pypi_0    pypi
gast                      0.4.0                      py_0  
google-auth               1.27.1             pyhd3eb1b0_0  
google-auth-oauthlib      0.4.3              pyhd3eb1b0_0  
google-pasta              0.2.0                      py_0  
grpcio                    1.36.1           py37h2157cd5_1  
gym                       0.18.0                   pypi_0    pypi
h5py                      3.2.1                    pypi_0    pypi
hdf5                      1.10.6               hb1b8bf9_0  
idna                      2.10               pyhd3eb1b0_0  
image-structure           0.1                      pypi_0    pypi
importlib-metadata        3.7.3            py37h06a4308_1  
iniconfig                 1.1.1                    pypi_0    pypi
intel-openmp              2020.2                      254  
joblib                    1.0.1                    pypi_0    pypi
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.2              pyhd3eb1b0_0  
kiwisolver                1.3.1                    pypi_0    pypi
ld_impl_linux-64          2.33.1               h53a641e_7  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libllvm10                 10.0.1               hbcb73fb_5  
libprotobuf               3.14.0               h8c45485_0  
libstdcxx-ng              9.1.0                hdf63c60_0  
llvmlite                  0.36.0           py37h612dafd_4  
lmfit                     1.0.2                    pypi_0    pypi
markdown                  3.3.4            py37h06a4308_0  
matplotlib                3.3.4                    pypi_0    pypi
mccabe                    0.6.1                    pypi_0    pypi
mkl                       2020.2                      256  
mkl-service               2.3.0            py37he8ac12f_0  
mkl_fft                   1.3.0            py37h54f3939_0  
mkl_random                1.1.1            py37h0573a6f_0  
mpi4py                    3.0.3                    pypi_0    pypi
multidict                 5.1.0            py37h27cfd23_2  
ncurses                   6.2                  he6710b0_1  
numba                     0.53.0           py37ha9443f7_0  
numpy                     1.20.1                   pypi_0    pypi
numpy-base                1.19.2           py37hfa32c7d_0  
oauthlib                  3.1.0                      py_0  
openssl                   1.1.1j               h27cfd23_0  
opt_einsum                3.1.0                      py_0  
packaging                 20.9                     pypi_0    pypi
pandas                    1.2.3                    pypi_0    pypi
pillow                    7.2.0                    pypi_0    pypi
pip                       21.0.1           py37h06a4308_0  
pluggy                    0.13.1                   pypi_0    pypi
protobuf                  3.14.0           py37h2531618_1  
py                        1.10.0                   pypi_0    pypi
pyasn1                    0.4.8                      py_0  
pyasn1-modules            0.2.8                      py_0  
pycodestyle               2.7.0                    pypi_0    pypi
pycparser                 2.20                       py_2  
pyflakes                  2.3.1                    pypi_0    pypi
pyglet                    1.5.0                    pypi_0    pypi
pyjwt                     1.7.1                    py37_0  
pyopenssl                 20.0.1             pyhd3eb1b0_1  
pyparsing                 2.4.7                    pypi_0    pypi
pysocks                   1.7.1                    py37_1  
pytest                    6.2.3                    pypi_0    pypi
python                    3.7.10               hdb3f193_0  
python-dateutil           2.8.1                    pypi_0    pypi
python-flatbuffers        1.12               pyhd3eb1b0_0  
pytz                      2021.1                   pypi_0    pypi
pyyaml                    5.4.1                    pypi_0    pypi
readline                  8.1                  h27cfd23_0  
requests                  2.25.1             pyhd3eb1b0_0  
requests-oauthlib         1.3.0                      py_0  
rsa                       4.7.2              pyhd3eb1b0_1  
scikit-learn              0.24.1                   pypi_0    pypi
scipy                     1.6.1            py37h91f5cce_0  
seaborn                   0.11.1                   pypi_0    pypi
setuptools                52.0.0           py37h06a4308_0  
six                       1.15.0           py37h06a4308_0  
sklearn                   0.0                      pypi_0    pypi
sqlite                    3.35.1               hdfb4753_0  
tbb                       2020.3               hfd86e86_0  
tensorboard               2.4.0              pyhc547734_0  
tensorboard-plugin-wit    1.6.0                      py_0  
tensorflow                2.4.1           mkl_py37h2d14ff2_0  
tensorflow-base           2.4.1           mkl_py37h43e0292_0  
tensorflow-estimator      2.4.1              pyheb71bc4_0  
termcolor                 1.1.0            py37h06a4308_1  
threadpoolctl             2.1.0                    pypi_0    pypi
tk                        8.6.10               hbc83047_0  
toml                      0.10.2                   pypi_0    pypi
typing-extensions         3.7.4.3              hd3eb1b0_0  
typing_extensions         3.7.4.3            pyh06a4308_0  
uncertainties             3.1.5                    pypi_0    pypi
urllib3                   1.26.4             pyhd3eb1b0_0  
werkzeug                  1.0.1              pyhd3eb1b0_0  
wheel                     0.36.2             pyhd3eb1b0_0  
wrapt                     1.12.1           py37h7b6447c_1  
xz                        5.2.5                h7b6447c_0  
yarl                      1.6.3            py37h27cfd23_0  
zipp                      3.4.1              pyhd3eb1b0_0  
zlib                      1.2.11               h7b6447c_3 

@jmohdyusof
Copy link
Collaborator

You dont' have tensorflow-gpu installed:
(exarl) [jamal@cn140 ExaRL]$ conda list | grep tensorflow
tensorflow 2.2.0 gpu_py37h1a511ff_0
tensorflow-base 2.2.0 gpu_py37h8a81be8_0
tensorflow-estimator 2.2.0 pyh208ff02_0
tensorflow-gpu 2.2.0 h0d30ee6_0

@aik7
Copy link
Collaborator Author

aik7 commented Apr 6, 2021

Thanks, I have these packages.

tensorflow                2.4.1           gpu_py37ha2e99fa_0  
tensorflow-base           2.4.1           gpu_py37h29c2da4_0  
tensorflow-estimator      2.4.1              pyheb71bc4_0  
tensorflow-gpu            2.4.1                h30adc30_0 

but AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike' is still there. Is this because I am using 2.4.1 instead of 2.2.0?

@jmohdyusof
Copy link
Collaborator

jmohdyusof commented Apr 6, 2021

With newer tensorflow, you have to make sure you don't have any 'import keras', you need to import tensorflow.keras
I also see some comments online that updating to 2.4.3 fixes it

@aik7
Copy link
Collaborator Author

aik7 commented Apr 6, 2021

Thanks. that is what I was reading:
tensorflow/models#6177

I will try to upgrade to 2.4.3.

@aik7
Copy link
Collaborator Author

aik7 commented Apr 6, 2021

maybe the exact version of tensorflow, etc. should be specified to avoid this error?

@jmohdyusof
Copy link
Collaborator

Yeah, 2.2.0 seems to work, it looks like 2.4.3 is not yet available on conda channels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants