[Tensorflow] tensorflow.python.framework.errors_impl.FailedPreconditionError: Could not find variable 52/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized.
See original GitHub issueVersion: LPOT 1.5, Tensorflow 2.5, Intel-Tensorflow 2.5 Env: Google Colab
I was using a Keras saved model for quantization, and the following error occurs:
2021-07-23 03:49:12 [WARNING] There is no quantizable op type!!!
2021-07-23 03:49:12 [INFO] Getting FP32 model baseline...
2021-07-23 03:49:12 [INFO] Start to evaluate Tensorflow model...
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 1375, in _do_call
return fn(*args)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 1360, in _run_fn
target_list, run_metadata)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 1453, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Could not find variable 52/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status=Not found: Container localhost does not exist. (Could not find resource: localhost/52/kernel)
[[{{node model/52/Conv2D/ReadVariableOp}}]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 110, in <module>
evaluate_opt_graph.run()
File "main.py", line 94, in run
q_model = quantizer()
File "/usr/local/lib/python3.7/dist-packages/lpot/experimental/quantization.py", line 177, in __call__
self.strategy.traverse()
File "/usr/local/lib/python3.7/dist-packages/lpot/strategy/strategy.py", line 286, in traverse
self.baseline = self._evaluate(self.model)
File "/usr/local/lib/python3.7/dist-packages/lpot/strategy/strategy.py", line 424, in _evaluate
val = self.objective.evaluate(eval_func, model)
File "/usr/local/lib/python3.7/dist-packages/lpot/objective.py", line 213, in evaluate
acc = eval_func(model)
File "/usr/local/lib/python3.7/dist-packages/lpot/utils/create_obj_from_config.py", line 131, in eval_func
tensorboard, fp32_baseline)
File "/usr/local/lib/python3.7/dist-packages/lpot/adaptor/tensorflow.py", line 210, in evaluate
predictions = model.sess.run(output_tensor, feed_dict)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 968, in run
run_metadata_ptr)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 1191, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 1369, in _do_run
run_metadata)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/session.py", line 1394, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Could not find variable 52/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status=Not found: Container localhost does not exist. (Could not find resource: localhost/52/kernel)
[[{{node model/52/Conv2D/ReadVariableOp}}]]
Also, I don’t know why the system prints [WARNING] There is no quantizable op type!!!
, because my model contains Conv2D operations and Matmul operations, which are clearly quantizable.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Failed precondition: Could not find variable Variable
(0) Failed precondition: Could not find variable Variable. This could mean that the variable has been deleted. In TF1, it can also mean...
Read more >Could not find variable dense_24/bias. This could mean that ...
I think it's a keras reference problem, you should correctly import: import tensorflow as tf from tensorflow import keras.
Read more >Load a savedmodel in tensorFlow - Support - OpenNMT Forum
FailedPreconditionError : Could not find variable _AnonymousVar5. This could mean that the variable has been deleted. In TF1, it can also ...
Read more >Doesn't seem to do anything. The API seems to end with the ...
FailedPreconditionError : Error while reading resource variable Block8_6_Conv2d_1x1/bias from Container: localhost. This could mean that the ...
Read more >Introduction to Tensor with Tensorflow - GeeksforGeeks
Variable (). Note that you can not run sess.run(my_var), this would result in an error. Because TensorFlow operates with computational graphs, we ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As for the version of Tensorflow & Intel-Tensorflow, both are 2.5.0:
My subgraph structure looks somewhat like below: (Here I used ONNX model converted from the Keras saved model for its better readability, but they are of the same structure essentially)
Is “Conv2D + LeakyRelu” a supported pattern in Tensorflow? On the other hand, LPOT recognizeds Matmul in my model as quantizable, but when quantizaing it always prints
Unknown Matmul
.No feedback over 2 weeks, closed at first. Please reopen if issue still there.