0

I use Docker from Gadgetron to realize a Gadget with Keras. Theano as backend. Here is the Dockerfile and the result of pip list is

Package              Version    
-------------------- -----------
absl-py              0.7.1      
astor                0.8.0      
certifi              2019.6.16  
chardet              3.0.4      
cycler               0.10.0     
Cython               0.26.1     
decorator            4.4.0      
dicom                0.9.9.post1
dicom-numpy          0.1.6      
engineering-notation 0.6.0      
gast                 0.2.2      
google-pasta         0.1.7      
grpcio               1.21.1     
h5py                 2.9.0      
idna                 2.8        
imageio              2.5.0      
ismrmrd              1.6.1      
ismrmrd-python-tools 0.3        
joblib               0.13.2     
Keras                2.2.4      
Keras-Applications   1.0.8      
Keras-Preprocessing  1.1.0      
kiwisolver           1.1.0      
lxml                 4.2.1      
Markdown             3.1.1      
matplotlib           3.1.0      
networkx             2.3        
numpy                1.16.4     
opencv-python        4.1.0.25   
Pillow               6.0.0      
pip                  19.2.3     
protobuf             3.8.0      
psutil               5.4.2      
pydicom              1.2.2      
pygobject            3.26.1     
pynrrd               0.4.0      
pyparsing            2.4.0      
PyQt5                5.12.2     
PyQt5-sip            4.19.17    
python-apt           1.6.4      
python-dateutil      2.8.0      
pytz                 2019.2     
PyWavelets           1.0.3      
PyXB                 1.2.6      
PyYAML               5.1.1      
pyzmq                18.0.2     
requests             2.22.0     
scikit-image         0.15.0     
scikit-learn         0.21.2     
scipy                1.3.0      
setuptools           41.0.1     
six                  1.12.0     
sklearn              0.0        
tensorboard          1.14.0     
tensorboardX         1.8        
tensorflow           1.14.0     
tensorflow-estimator 1.14.0     
tensorflow-gpu       1.14.0     
termcolor            1.1.0      
Theano               1.0.4      
tk-tools             0.11.0     
torch                1.1.0      
torchfile            0.1.0      
torchvision          0.3.0      
tornado              6.0.3      
urllib3              1.25.3     
visdom               0.1.8.8    
websocket-client     0.56.0     
Werkzeug             0.15.4     
wheel                0.33.4     
wrapt                1.11.2     

Mycode is like this:

from keras.models import model_from_json

with open('/opt/data/model.json', 'r') as f:
    model = model_from_json(f.read())
model.load_weights('/opt/data/weight.h5')

When loading the weights, an error appeared:

File "/opt/data/CNNArt/Gadgetron/gadget_cnnart.py", line 29, in process
    model.load_weights('/opt/data/weight.h5')

  File "/usr/local/lib/python3.6/dist-packages/keras/engine/network.py", line 1157, in load_weights
    with h5py.File(filepath, mode='r') as f:

  File "/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py", line 391, in __init__
    fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0, **kwds)

  File "/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py", line 108, in make_fapl
    plist.set_libver_bounds(low, high)

  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper

  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper

  File "h5py/h5p.pyx", line 1140, in h5py.h5p.PropFAID.set_libver_bounds

ValueError: Invalid high library version bound (invalid high library version bound)

However, in Docker, when I opened python in the terminal, I can load the model and its parameters.

>>> from keras.models import model_from_json
>>> with open('/opt/data/model.json', 'r') as f:
...     model = model_from_json(f.read())
...
>>> model.load_weights('/opt/data/weight.h5')
>>> 

I have tried to reinstall h5py with pip, but it doesn't work.

The problem is it works directly in python interaction terminal but doesn't work in Gadget script.

1
  • you need to show your Dockerfile
    – LinPy
    Sep 20, 2019 at 5:25

3 Answers 3

1

Uninstall h5py and reinstall with this command:

pip install --no-binary=h5py h5py 

Source

0

I have a similar problem and I solve it with installing

sudo apt-get install python3-h5py

and make sure that numpy version is compatible with h5py

0

I also encountered this problem when using tensorflow.

as mentioned by @so2liu, Please try:

pip install --no-binary=h5py h5py

however, Make sure you choose a version compatible with tensorflow or some other lib, for example:

pip install --no-binary=h5py h5py==2.10.0

At last, remeber checke your env, as you might runing your code in venv / conda / docker but you installed h5py in the wrong env

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.