简体   繁体   中英

Alternating errors using HDF5 library and h5py module

I have created a CNN model and am trying to save it as an .h5 file, then later load the model. I am working within a virtual environment in Anaconda. The funny thing is, I can do everything in a Jupyter Notebook within the virtual environment with no problem. However, when I try running it in the terminal (loading the model, then evaluating it), it does not work. I am having a set of alternating errors which have solutions on the web, but these solutions either lead to dead ends, or lead to the other error.

The first error:

Traceback (most recent call last):
  File "MNIST.py", line 64, in <module>
    main()
  File "MNIST.py", line 62, in main
    evaluate_model()
  File "MNIST.py", line 54, in evaluate_model
    model = models.load_model('final_model.h5')
  File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper
    return load_function(*args, **kwargs)
  File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\engine\saving.py", line 582, in load_model
    if H5Dict.is_supported_type(filepath):
  File "C:\Users\Josh Cruz\Documents\.conda\envs\tensorflow\lib\site-packages\keras\utils\io_utils.py", line 209, in is_supported_type
    isinstance(path, h5py.Group) or
AttributeError: module 'h5py' has no attribute 'Group'

I haven't found a specific fix for fixing Attribute Error: module 'h5py' has no attribute 'Group' , but I did find similar issues online whose solutions suggest that I should update h5py to 2.10.0 using conda install -c conda-forge h5py . This makes sense to me, as groups seem to be part of the 2.10.0 h5py documentation.

Upon installing this comes up:

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
h5py-2.9.0                 |nompi_py36h9dfa0df_1103         909 KB  conda-forge
------------------------------------------------------------
                                       Total:         909 KB

The following NEW packages will be INSTALLED:

  h5py               conda-forge/win-64::h5py-2.9.0-nompi_py36h9dfa0df_1103

The following packages will be SUPERSEDED by a higher-priority channel:

  certifi              pkgs/main::certifi-2019.11.28-py36_1 --> conda-forge::certifi-2019.11.28- 
py36h9f0ad1d_1

I'm confused, because I thought I was installing the 2.10.0 version. I install anyways, try to re-run my program and get a completely new error:

Headers are 1.10.4, library is 1.10.5
        SUMMARY OF THE HDF5 CONFIGURATION
        =================================

General Information:
-------------------
               HDF5 Version: 1.10.5
              Configured on: 2019-03-04
              Configured by: Visual Studio 14 2015 Win64
                Host system: Windows-10.0.17763
          Uname information: Windows
                   Byte sex: little-endian
         Installation point: C:/Program Files/HDF5

For the sake of space, I didn't include the whole error, but the whole error can be found in this question . The suggestion there is to do pip install h5py --upgrade --no-dependencies --force , but doing that leads to the same error. Another source (which I can't find right now), says there might be issues juggling both installs of pip and conda, so I run pip uninstall h5py , and the error persists. Then, using a suggestion here , I run conda install -c anaconda hdf5=1.10.4 so that the library matches the header. I get stuck here, because even if I run my program again, I still get the same exact error. I don't understand why, shouldn't the library now be 1.10.4?

Other places have then suggested I uninstall, then reinstall. If I uninstall, I get the first error that I wrote down. when I reinstall, the cycle begins again. Any help would be appreciated.

Have you already tried running using hdf5=1.10.5 in this conda install -c anaconda hdf5=1.10.5 instead of using hdf5=1.10.4 ?

You have 1.10.4 hdf5 library installed in a conda environment, some dependency of Tensorflow has newer hdf5 1.10.5 header files.

Try to update your conda hdf5 library to newer 1.10.5 or alternatively use the command:

set HDF5_DISABLE_VERSION_CHECK=2 

This should disable the warning but doesn't offer any warranty of correct execution, so It's better to update the hdf5 library to the same version 1.10.5.

If that was not enough, try also this workaround:

First, try to remove the update for h5py 2.10.0 version revert it back to original and

upgrade hdf5 to the 1.10.5 version via:

conda install -c anaconda hdf5=1.10.5

And uninstall a double (if you have double h5py installed) installation of h5py via:

conda uninstall h5py
pip uninstall h5py

If you only have one then uninstall it

Finally, upgrade to the hdf5 2.10.0 version again by

conda install -c conda-forge h5py

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM