tensorflow: Bug: Op type not registered 'BlockLSTM' in binary
Describe the problem
I want to load and run a single tensorflow model within another C++ project. To do this, I defined the tensorflow_all library in tensorflow/BUILD which should include all the necessary dependencies. (Details below)
When loading the tensorflow model via the C++ API (LoadSavedModel), the following runtime error occurs:
2017-07-28 13:36:41.875493: I tensorflow/cc/saved_model/loader.cc:284] Loading SavedModel: fail. Took 43550 microseconds.
terminate called after throwing an instance of 'std::runtime_error'
what(): Not found: Op type not registered 'BlockLSTM' in binary running on myMachine.
Make sure the Op and Kernel are registered in the binary running in this process.
I found that the BlockLSTM Op is registered in tensorflow/contrib/rnn/ops/lstm_ops.cc.
However, I could not find a way to include the operation BlockLSTM in my C++ library tensorflow_all.
Bear with me if this is actually not a bug (or even a feature request). I am still getting started with tensorflow.
Since my implementation is part of another larger project, it is currently difficult for me to give an easy to reproduce example. However, if this is necessary, I will do it as soon as I find the time.
System information
-
Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
Yes, a colleague of mine trained a tensorflow graph which uses the BlockLSTM Op from
tensorflow/contrib/rnn/using the python API.As mentioned before, I added code to the
tensorflow/BUILDto create a librarytensorflow_all. This library is used to load the graph externally.cc_binary( name = "libtensorflow_all.so", linkshared = 1, linkopts = ["-Wl,--version-script=tensorflow/tf_version_script.lds"], deps = [ "//tensorflow/cc:cc_ops", "//tensorflow/cc:client_session", "//tensorflow/cc/saved_model:loader", "//tensorflow/cc/saved_model:tag_constants", "//tensorflow/core:all_kernels", "//tensorflow/core:framework_internal", "//tensorflow/core:tensorflow", "//tensorflow/contrib:contrib_kernels", "//tensorflow/contrib:contrib_ops_op_lib", ], )I was hoping that
BlockLSTMwas included in"//tensorflow/contrib:contrib_ops_op_lib", but that appears not to be the case. -
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04.2 LTS
-
TensorFlow installed from (source or binary): source
-
TensorFlow version: Master branch (commit bb88ec7ecc4dc7ba72548a5115fb86e20b14de5b)
-
Python version: 3.5
-
Bazel version (if compiling from source): 0.4.5
-
CUDA/cuDNN version: 5.1
-
GPU model and memory: GeForce GTX 980, 4GB
-
Exact command to reproduce: Sorry. Not that easy to reproduce.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (13 by maintainers)
It works for me with the following changes (also for gru_ops_kernels).
And adding
"//tensorflow/contrib/rnn:gru_ops_kernels"and/or"//tensorflow/contrib/rnn:lstm_ops_kernels"to the deps of the respective binary.(using r1.3)
@dkurt You could try adding
to freeze_graph.py.
@yanggeng1995 , the needed changes are: https://github.com/songmeixu/tensorflow/commit/c8341fb2b2f410f3fbd31b2e02463ed4499d54bc, https://github.com/songmeixu/tensorflow/commit/ab800e2ccc71191ec7b2057b5d51fd4e44841791
and for anyone run into this error when compile an android TF c++ lib, more needed changes are: https://github.com/songmeixu/tensorflow/commit/e85c30b3550d2b8b84ffe72165f56f41b72c9a20
@pks hi, I used your method to add operation “BlockLSTM” and compile successfully, but loading the model in c++ doesn’t seem to work, have you ever been in this situation? Look forward to your reply!