Hi I'm having some problems running TensorFlow Hub models. I am getting DataLossError
when running sess.run
. I am using Ubuntu 16.04, Python3.6 with tensorflow==1.8.0
and tensorflow_hub=0.1.0
.
However, when I run it on a macOS machine, the script below works without problems.
In [1]: import tensorflow as tf
...: import tensorflow_hub as hub
...:
In [2]: from tensorflow.python.client import device_lib
...: print(device_lib.list_local_devices())
...:
2018-04-30 13:53:30.576282: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFl
ow binary was not compiled to use: AVX2 FMA
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 9094741255132568752
]
In [3]: print("TensorFlow version: {}".format(tf.VERSION))
...: print("Eager execution: {}".format(tf.executing_eagerly()))
...:
TensorFlow version: 1.8.0
Eager execution: False
In [4]: ENGLISH_WORD2VEC = 'https://tfhub.dev/google/nnlm-en-dim128/1'
...:
In [5]: # switch here
...: embedding_module = ENGLISH_WORD2VEC
...: embed = hub.Module(embedding_module, trainable=False)
...:
INFO:tensorflow:Using /tmp/tfhub_modules to cache modules.
INFO:tensorflow:Initialize variable module/embeddings/part_0:0 from checkpoint b'/tmp/tfhub_modules/32f2b2259e1cc8ca58c87692174836
1283e73997/variables/variables' with embeddings
In [6]: with tf.Session() as sess:
...: sess.run(tf.global_variables_initializer())
...: sess.run(tf.local_variables_initializer())
...: sess.run(tf.tables_initializer())
...:
...: print(sess.run(embeddings))
...:
DataLossError: Checksum does not match: stored 3328590665 vs. calculated on the restored bytes 94957053
[[Node: checkpoint_initializer = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](ch$
ckpoint_initializer/prefix, checkpoint_initializer/tensor_names, checkpoint_initializer/shape_and_slices)]]
Caused by op 'checkpoint_initializer', defined at:
File "~/venv/bin/ipython", line 11, in <module>
sys.exit(start_ipython())
File "~/venv/lib/python3.6/site-packages/IPython/__init__.py", line 119, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "~/venv/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "~/venv/lib/python3.6/site-packages/IPython/terminal/ipapp.py", line 355, in start
self.shell.mainloop()
File "~/venv/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 493, in mainloop
self.interact()
File "~/venv/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 484, in interact
self.run_cell(code, store_history=True)
File "~/venv/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2718, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "~/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2822, in run_ast_nodes
if self.run_code(code, result):
File "~/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2882, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-68aeaedb27fc>", line 4, in <module>
embed = hub.Module(embedding_module, trainable=False)
File "~/venv/lib/python3.6/site-packages/tensorflow_hub/module.py", line 126, in __init__
tags=self._tags)
File "~/venv/lib/python3.6/site-packages/tensorflow_hub/native_module.py", line 282, in _create_impl
name=name)
File "~/venv/lib/python3.6/site-packages/tensorflow_hub/native_module.py", line 338, in __init__
tf.train.init_from_checkpoint(self._checkpoint_path, self._variable_map)
File "~/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_utils.py", line 221, in i
nit_from_checkpoint
_set_variable_or_list_initializer(var, ckpt_file, tensor_name_in_ckpt)
File "~/venv/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_utils.py", line 335, in _
set_variable_or_list_initializer
_set_checkpoint_initializer(v, ckpt_file, tensor_name, slice_info.spec)
File "~/venv/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_utils.py", line 299, in _
set_checkpoint_initializer
ckpt_file, [tensor_name], [slice_spec], [base_type], name=name)[0]
File "~/venv/lib/python3.6/site-packages/tensorflow/python/ops/gen_io_ops.py", line 1463, in restore_v2
shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
File "~/venv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _a
pply_op_helper
op_def=op_def)
File "~/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op
op_def=op_def)
File "~/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1718, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
DataLossError (see above for traceback): Checksum does not match: stored 3328590665 vs. calculated on the restored bytes 94957053
[[Node: checkpoint_initializer = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](che
ckpoint_initializer/prefix, checkpoint_initializer/tensor_names, checkpoint_initializer/shape_and_slices)]]