Skip to content

h5py==3.0.0 causes issues with keras model loads in tensorflow 2.1.0 #44467

Closed
@danzafar

Description

@danzafar

h5py released version 3.0.0 today and it causes this code to fail:

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/keras/saving/hdf5_format.py#L182
with error:

File "/databricks/python/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/save.py", line 146, in load_model
return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
File "/databricks/python/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 166, in load_model_from_hdf5
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

It looks like in version 2.1.0 the h5py version is not pinned (it is pinned in master), which is causing the issue.

Activity

bhack

bhack commented on Oct 30, 2020

@bhack
Contributor

I think it will be hard to expect a backport on 2.1.0.

danzafar

danzafar commented on Oct 30, 2020

@danzafar
Author

the new h5py version just came out today: https://pypi.org/project/h5py/#history

Pinning it to a version <3.0.0 (or at least throwing a warning) is a very lightweight change with no risk.

bhack

bhack commented on Oct 30, 2020

@bhack
Contributor

the new h5py version just came out today: https://pypi.org/project/h5py/#history

Pinning it to a version <3.0.0 (or at least throwing a warning) is a very lightweight change with no risk.

Yes but as you know generally we had very few patch releases (e.g. 2.1.x) so It Is quite hard to have wheels with these fixes on old versions.

danzafar

danzafar commented on Oct 31, 2020

@danzafar
Author

@bhack I'm not going to add any more messages after this, but I think you can see based on these other issues the Keras API is essentially broken because h5py new release. I'm not sure why the version was not pinned as it is in master, but I strongly advise that you pin to h5py==2.10.0 this for all TF >= 2.1.

bhack

bhack commented on Oct 31, 2020

@bhack
Contributor

/cc @mihaimaruseac @angerson there are many Dockerfile and other file not constrained.

yan12125

yan12125 commented on Nov 1, 2020

@yan12125

FWIW, I got a similar error message with h5py 3.0, and removing .decode('utf-8') from tensorflow/python/keras/saving/hdf5_format.py allows me to load Keras models as before.

137 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @yekm@mihaimaruseac@CMCDragonkai@bhack@lakshmanok

    Issue actions

      h5py==3.0.0 causes issues with keras model loads in tensorflow 2.1.0 · Issue #44467 · tensorflow/tensorflow