0

I trained a model from Linux using GPU and save it using model.save('my_model.h5').

I have no issue opening the .h5 model in Linux machine with

from keras.models import load_model
model = load_model('my_model.h5')

However, I got issue when I load it on my Mac (which doesn't have GPU, and probably tensorflow is also not the one for GPU version):

OSError: Unable to open file (unable to open file: name = '⁨model0.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

Same command, same location when I work on jupyter notebook, same location where the .h5 file is stored, same file that I want to load. Does anyone know what's going on?

Thank you in advance.

Jason
  • 3,166
  • 3
  • 20
  • 37

1 Answers1

0

The Python from Linux: 3.6

The Python from Mac (with error shown above): 3.5

The Python from Mac (without error): 3.7

I guess it's the version of keras that I installed in my different virtual environment, causing some compatibility issue (keras' version cross 2 years or so). Once I change my virtual environment to 3.7, I could successfully load the model.

The lesson I learnt here is to make sure two machines should use same development environment in order to avoid the version compatibility issue. Even tho in this case, my tensorflow versions are for sure different as Mac doesn't have GPU, try to keep other packages as similar as possible.

Jason
  • 3,166
  • 3
  • 20
  • 37
  • Also, another potential issue was spotted and solved in this link about .h5 file: https://stackoverflow.com/questions/57469102/h5py-filepath-doesnt-recognize-folder-path – Jason Aug 13 '19 at 15:56