I tried to convert tf frozen model to ir, but it failed.
Platform (like ubuntu 16.04/win10): docker image mmdnn/mmdnn:cpu.small Python version: python 3.5 Source framework with version (like Tensorflow 1.4.1 with GPU): tf 1.7 with GPU optimized by tensorRT, not very sure the version of tf Destination framework with version (like CNTK 2.3 with GPU): I want to convert the frozen pb to ir first, then convert it to saved model for tensorflow serving Pre-trained model path (webpath or webdisk path): https://developer.download.nvidia.com/devblogs/tftrt_sample.tar.xz Running scripts:
mmtoir -f tensorflow --frozen_pb resnetV150_TRTFP32.pb --inNodeName input --inputShape 224 224 3 --dstNodeName dstNode -o resnet150-ir
Traceback (most recent call last): File "/usr/local/bin/mmtoir", line 11, in
sys.exit(_main()) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 184, in _main ret = _convert(args) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 48, in _convert parser = TensorflowParser2(args.frozen_pb, args.inputShape, args.inNodeName, args.dstNodeName) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/tensorflow/tensorflow_frozenparser.py", line 108, in init placeholder_type_enum = dtypes.float32.as_datatype_enum) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/tools/strip_unused_lib.py", line 86, in strip_unused output_node_names) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/graph_util_impl.py", line 174, in extract_sub_graph _assert_nodes_are_present(name_to_node, dest_nodes) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/graph_util_impl.py", line 133, in _assert_nodes_are_present assert d in name_to_node, "%s is not in graph" % d AssertionError: dstNode is not in graph
Any ideas? Or does mmdnn support converting tensorRT optimized tf frozen model? Thanks.
Hi @elvys-zhang ,as you can see from the traceback, "dstNode is not in graph" .Please check your dstNodename.
@namizzz Thanks for your reply. I am a starter of tf. I tried the tools 'mmvismeta' to check dstNodeName, but another error occured
Traceback (most recent call last): File "/usr/local/bin/mmvismeta", line 11, in
sys.exit(_main()) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/examples/tensorflow/vis_meta.py", line 36, in _main visualize(sys.argv[1], sys.argv[2]) File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/examples/tensorflow/vis_meta.py", line 9, in visualize tf.train.import_meta_graph(model_filename) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 1947, in import_meta_graph meta_graph_def = meta_graph.read_meta_graph_file(meta_graph_or_file) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/meta_graph.py", line 643, in read_meta_graph_file text_format.Merge(file_content.decode("utf-8"), meta_graph_def) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 191: invalid start byte
Could you please suggest some ways for me to check what the dstNodeName is? Thanks.
I have figured it out. But there was another error
Traceback (most recent call last):
File "/usr/local/bin/mmtoir", line 11, in <module>
sys.exit(_main())
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 184, in _main
ret = _convert(args)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/_script/convertToIR.py", line 48, in _convert
parser = TensorflowParser2(args.frozen_pb, args.inputShape, args.inNodeName, args.dstNodeName)
File "/usr/local/lib/python3.5/dist-packages/mmdnn/conversion/tensorflow/tensorflow_frozenparser.py", line 122, in __init__
tensorflow.import_graph_def(model, name='')
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/deprecation.py", line 432, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 489, in import_graph_def
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.NotFoundError: Op type not registered 'TRTEngineOp' in binary running on f9ccb16d346e. Make sure the Op and Kernel are registered in the binary running in this process.
Hi @elvys-zhang ,I find this. Maybe you can add this line to load your model successfully. I tried in my machine. It works !
import tensorflow.contrib.tensorrt as trt
But in the tensorRT optimized model file(.pb). There is a TRTEngineOp including almost the whole graph, MMdnn can not handle it now. Thanks!
Name and type of all nodes

@namizzz Thanks for your reply. It did work. So is there any plan to support converting TRT optimized model? Looking forward to it. Thank you.
Hi @elvys-zhang , TRTEngineOp includes almost the whole graph in a serialized string of the engine. We can't deserialized it. Thanks!
@namizzz Thanks. It seems that the newest tensorflow source has already supported converting saved model to TRT optimized saved model. I will try it.