tensorflow: Tensorflow freeze_graph.py: NodeDef mentions attr 'Truncate' not in Op
Please go to Stack Overflow for help and support:
https://stackoverflow.com/questions/tagged/tensorflow
If you open a GitHub issue, here is our policy:
- It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).
- The form below must be filled out.
- It shouldn’t be a TensorBoard issue. Those go here.
Here’s why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOs High Sierra, MacBook Pro, 3.1 GHz Intel Core i5, 8 GB 2133 MHz LPDDR3, Intel Iris Plus Graphics 650 1536 MB
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow installed from (source or binary): pip install tensorflow==1.10
- TensorFlow version (use command below): v1.10.0-rc1-19-g656e7a2b34 1.10.0
- Python version: python 3.6
- Bazel version (if compiling from source): N/A
- GCC/Compiler version (if compiling from source): N/A
- CUDA/cuDNN version: N/A
- GPU model and memory: N/A
- Exact command to reproduce: python3 /Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py --input_graph=/Users/duckhahwang/Downloads/resnet_imagenet_v2_20180928/graph.pbtxt --input_binary=false --input_checkpoint=/Users/duckhahwang/Downloads/resnet_imagenet_v2_20180928/model.ckpt-56286 --input_binary=false --output_graph=/Users/duckhahwang/Downloads/frozen_graph.pb --output_node_names=softmax
You can collect some of this information using our environment capture script:
https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh
You can obtain the TensorFlow version with
python -c “import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)”
Describe the problem
Describe the problem clearly here. Be sure to convey here why it’s a bug in TensorFlow or a feature request.
I downloaded the pre-trained tensorflow model (ResNet-50 v2 (fp32)) from the below link
And using freeze_graph.py to freeze the pre-trained model. but I received the error message and not working.
Source code / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.
DUCKHAs-MacBook-Pro:site-packages duckhahwang$ python3 /Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py --input_graph=/Users/duckhahwang/Downloads/resnet_imagenet_v2_20180928/graph.pbtxt --input_binary=false --input_checkpoint=/Users/duckhahwang/Downloads/resnet_imagenet_v2_20180928/model.ckpt-56286 --input_binary=false --output_graph=/Users/duckhahwang/Downloads/frozen_graph.pb --output_node_names=softmax
/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.23) or chardet (3.0.4) doesn’t match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/importer.py”, line 418, in import_graph_def
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr ‘Truncate’ not in Op<name=Cast; signature=x:SrcT -> y:DstT; attr=SrcT:type; attr=DstT:type>; NodeDef: resnet_model/conv2d/kernel_cast = CastDstT=DT_HALF, SrcT=DT_FLOAT, Truncate=false, _output_shapes=[[7,7,3,64]]. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py”, line 382, in <module> run_main() File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py”, line 379, in run_main app.run(main=my_main, argv=[sys.argv[0]] + unparsed) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py”, line 125, in run _sys.exit(main(argv)) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py”, line 378, in <lambda> my_main = lambda unused_args: main(unused_args, flags) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py”, line 272, in main flags.saved_model_tags, checkpoint_version) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py”, line 254, in freeze_graph checkpoint_version=checkpoint_version) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/tools/freeze_graph.py”, line 99, in freeze_graph_with_def_protos _ = importer.import_graph_def(input_graph_def, name=“”) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py”, line 454, in new_func return func(*args, **kwargs) File “/Users/duckhahwang/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/importer.py”, line 422, in import_graph_def raise ValueError(str(e)) ValueError: NodeDef mentions attr ‘Truncate’ not in Op<name=Cast; signature=x:SrcT -> y:DstT; attr=SrcT:type; attr=DstT:type>; NodeDef: resnet_model/conv2d/kernel_cast = CastDstT=DT_HALF, SrcT=DT_FLOAT, Truncate=false, _output_shapes=[[7,7,3,64]]. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 36 (4 by maintainers)
Unassigning myself since I have no plans to work on this. Freezing is not an operation we’re planning to support going forward.
Hi, I am getting similar issue with resnet-101. Frozen graph is created on same version that it is run on TF 1.13. ValueError: NodeDef mentions attr ‘explicit_paddings’ not in Op<name=Conv2D; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_HALF, DT_BFLOAT16, DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=[“SAME”, “VALID”]; attr=data_format:string,default=“NHWC”,allowed=[“NHWC”, “NCHW”]; attr=dilations:list(int),default=[1, 1, 1, 1]>; NodeDef: {{node resnet_v1_101/conv1/Conv2D}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.)./home/t/MLxBench/Modules/Deep-Learning/workloads/resnet101/bin/run_task.py:37: UserWarning: genfromtxt: Empty input file: “/home/t/MLxBench/Modules/Deep-Learning/workloads/resnet101/result/output/resnet101_batch_1_fp32_concurrent_instance0.csv” csv_data = genfromtxt(path, delimiter=‘,’)
Same issue here, with TF 1.13 . I also tried to train with the same version, training on a Windows machine and predicting on a Linux machine, but it gives me the error above
@personableduck Hi, I suspect this issue is due to the difference in the tensorflow versions between trained model and the tensorflow version which you are using. Please install a lower version of tensorflow(to make sure both the tf versions are same) and reverify. Thank you !
i am also getting same error even though version is same how can i solve this problem ?
Same issue here using TF 1.8. How does one tell which version a frozen graph is saved in?
I have the same issue!! PS: I’v used the same version while training and using the trained model !!
Same issue. Version is same.