Open lookup1980 opened 5 years ago
Hi @lookup1980 is it possible to share with us a stripped down version of your model for us to be used as a test case? Based on your error message, it looks like the root of the error must have occurred before the Sub op; so in this case stack trace may not help us much.. It does not even tell us whether the party at fault is onnx-tf or pytorch exporter.
Hi all! I'm also experiencing this issue.
Command:
onnx-tf convert -i yolov4_1_3_640_640_static.onnx -o tf
Output:
2021-02-25 16:28:39.604440: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-02-25 16:28:41,874 - onnx-tf - INFO - Start converting onnx pb to tf pb:
2021-02-25 16:28:41.951096: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-02-25 16:28:41.952217: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-02-25 16:28:42.033605: E tensorflow/stream_executor/cuda/cuda_driver.cc:328] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2021-02-25 16:28:42.033683: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (hidden): /proc/driver/nvidia/version does not exist
2021-02-25 16:28:42.034385: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-02-25 16:28:42.036234: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
Traceback (most recent call last):
File "/opt/conda/bin/onnx-tf", line 8, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.7/site-packages/onnx_tf/cli.py", line 20, in main
return onnx_tf.converter.main(args[1:])
File "/opt/conda/lib/python3.7/site-packages/onnx_tf/converter.py", line 20, in main
convert(**{k: v for k, v in vars(args).items() if v is not None})
File "/opt/conda/lib/python3.7/site-packages/onnx_tf/converter.py", line 135, in convert
tf_rep.export_graph(outdir)
File "/opt/conda/lib/python3.7/site-packages/onnx_tf/backend_rep.py", line 116, in export_graph
**self.signatures))
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 1299, in get_concrete_function
concrete = self._get_concrete_function_garbage_collected(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 1205, in _get_concrete_function_garbage_collected
self._initialize(args, kwargs, add_initializers_to=initializers)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 726, in _initialize
*args, **kwds))
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2969, in _get_concrete_function_internal_garbage_collected
graph_function, _ = self._maybe_define_function(args, kwargs)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 3361, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 3206, in _create_graph_function
capture_by_value=self._capture_by_value),
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 990, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 634, in wrapped_fn
out = weak_wrapped_fn().__wrapped__(*args, **kwds)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 3887, in bound_method_wrapper
return wrapped_fn(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py", line 977, in wrapper
raise e.ag_error_metadata.to_exception(e)
TypeError: in user code:
/opt/conda/lib/python3.7/site-packages/onnx_tf/backend_tf_module.py:98 __call__ *
output_ops = self.backend._onnx_node_to_tensorflow_op(onnx_node,
/opt/conda/lib/python3.7/site-packages/onnx_tf/backend.py:289 _onnx_node_to_tensorflow_op *
return handler.handle(node, tensor_dict=tensor_dict, strict=strict)
/opt/conda/lib/python3.7/site-packages/onnx_tf/handlers/handler.py:59 handle *
return ver_handle(node, **kwargs)
/opt/conda/lib/python3.7/site-packages/onnx_tf/handlers/backend/div.py:23 version_7 *
return [cls.make_tensor_from_onnx_node(node, **kwargs)]
/opt/conda/lib/python3.7/site-packages/onnx_tf/handlers/backend_handler.py:157 make_tensor_from_onnx_node *
return cls._run_tf_func(tf_func, inputs, attrs)
/opt/conda/lib/python3.7/site-packages/onnx_tf/handlers/backend_handler.py:237 _run_tf_func *
return tf_func(**kwargs)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py:201 wrapper **
return target(*args, **kwargs)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py:518 multiply
return gen_math_ops.mul(x, y, name)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_math_ops.py:6078 mul
"Mul", x=x, y=y, name=name)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:558 _apply_op_helper
inferred_from[input_arg.type_attr]))
TypeError: Input 'y' of 'Mul' Op has type int64 that does not match type float64 of argument 'x'.
This issue also occurs when trying to convert programmatically.
The .onnx
is a slightly modified tiny YOLOv4 that was trained through Darknet and is generated through this project. The onnx is valid I think, because the test image that was generated through the conversion from Darknet to Onnx is correct.
Do you have any suggestions on how to fix this issue? Thanks in advance!
Can you provide the onnx file, yolov4_1_3_640_640_static.onnx, for investigation?
Hi @chinhuang007 ! Thanks for your answer. I sent you an email with the file. Thanks in advance!
@JeremyKeustersML6 Thanks for providing the file! It helps to identify a bug, which is fixed in this patch, https://github.com/onnx/onnx-tensorflow/pull/876. Feel free to try it out before it is landed.
Kudos for the swift answer and solution @chinhuang007
Describe the bug
When I convert an ONNX model (which was converted from PyTorch), I got following error:
TypeError: Input 'y' of 'Sub' Op has type float32 that does not match type int64 of argument 'x'.
To Reproduce
The full error stack:
ONNX model file
Can't share the model
Python, ONNX, ONNX-TF, Tensorflow version
This section can be obtained by running
get_version.py
from util folder.