tobegit3hub / simple_tensorflow_serving

Generic and easy-to-use serving service for machine learning models
https://stfs.readthedocs.io
Apache License 2.0
757 stars 192 forks source link

How can I solve this error: KeyError: u'BatchMatMulV2', model: BERT; tensorflow: 1.14. #89

Open zhoujiang2013 opened 3 years ago

zhoujiang2013 commented 3 years ago

Traceback (most recent call last): File "/usr/local/bin/simple_tensorflow_serving", line 11, in load_entry_point('simple-tensorflow-serving==0.6.6', 'console_scripts', 'simple_tensorflow_serving')() File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 487, in load_entry_point Create path to host static files: static return get_distribution(dist).load_entry_point(group, name) File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2728, in load_entry_point return ep.load() File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2346, in load return self.resolve() File "/usr/local/lib/python2.7/site-packages/pkg_resources/init.py", line 2352, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "/usr/local/lib/python2.7/site-packages/simple_tensorflow_serving-0.6.6-py2.7.egg/simple_tensorflow_serving/server.py", line 225, in model_name, model_base_path, custom_op_paths, session_config) File "/usr/local/lib/python2.7/site-packages/simple_tensorflow_serving-0.6.6-py2.7.egg/simple_tensorflow_serving/tensorflow_inference_service.py", line 72, in init self.load_saved_model_version(model_version) File "/usr/local/lib/python2.7/site-packages/simple_tensorflow_serving-0.6.6-py2.7.egg/simple_tensorflow_serving/tensorflow_inference_service.py", line 175, in load_saved_model_version session, [tf.saved_model.tag_constants.SERVING], model_file_path) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/saved_model/loader_impl.py", line 197, in load return loader.load(sess, tags, import_scope, saver_kwargs) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/saved_model/loader_impl.py", line 350, in load saver_kwargs) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/saved_model/loader_impl.py", line 278, in load_graph meta_graph_def, import_scope=import_scope, saver_kwargs) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1696, in _import_meta_graph_with_return_elements kwargs)) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/meta_graph.py", line 806, in import_scoped_meta_graph_with_return_elements return_elements=return_elements) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func return func(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 391, in import_graph_def _RemoveDefaultAttrs(op_dict, producer_op_list, graph_def) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 158, in _RemoveDefaultAttrs op_def = op_dict[node.op] KeyError: u'BatchMatMulV2'

tobegit3hub commented 3 years ago

It seems that your model has the op named 'BatchMatMulV2' but it can not be found in current TensorFlow version. Please make sure you use the same version of TensorFlow as the environment for exporting the BERT model or using 2.4.0+ which has supported BatchMatMulV2.