-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
🐛 Bug
Exporting ONNX model with dynamic axes complains on validation that the input/output names are not specified when they currently are.
To Reproduce
Steps to reproduce the behavior:
Attempt to export any model with dynamic axes feature.
input_names = ["input"]
output_names = ["output"]
dynamic_axes = {"input": {2: "h", 3: "w"}}
torch.onnx.export(
model,
dummy_input,
"test.onnx",
verbose=True,
input_names=input_names,
output_names=output_names,
dynamic_axes=dynamic_axes,
)
Output: Provided key input for dynamic axes is not a valid input/output name
Expected behavior
The specified parameters are expected to be valid and the model should export correctly given that the model contains supported ops.
Environment
PyTorch version: 1.2.0
Is debug build: No
CUDA used to build PyTorch: 10.0.130
OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
CMake version: version 3.13.2
Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: 10.0.130
GPU models and configuration:
GPU 0: TITAN RTX
GPU 1: TITAN RTX
GPU 2: TITAN RTX
Nvidia driver version: 430.34
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.0
Versions of relevant libraries:
[pip3] numpy==1.16.2
[pip3] pytorch-ignite==0.2.0
[pip3] torch==1.2.0
[pip3] torchvision==0.4.0+cu92
Additional context
For set[T]
, set.addexpects an object of type
T. In the function,
_validate_dynamic_axes (
/home/ryan/.local/share/virtualenvs/inokyo-OUoFAKa9/lib/python3.7/site-packages/torch/onnx/utils.py:695), the
set.addshould be changed to
set.update`
Activity
leimao commentedon Oct 3, 2019
I strongly believe this is a bug. Before setting dynamic axes, the name of the input/output tensors were not assigned. Therefore, it does not even know which tensor(s) should have dynamic axes.
Running the official code gets the following warnings (these should be errors!).
leimao commentedon Oct 3, 2019
Looks like this is a false warning/error. This should definitely be fixed because it is so confusing.
lzxzy commentedon Nov 7, 2019
Hi, I've met the warning too. So, have you found the solution for this? Thx.
kit1980 commentedon Nov 7, 2019
I think the "solution" now is just to ignore the warning if you know that the name is correct.
leimao commentedon Nov 7, 2019
The latest PyTorch 1.3.0 fixed this false warning if I recall it correctly.
lzxzy commentedon Nov 10, 2019
Thanks for your guys' reply. I found the problem may be caused by this
When I commented the code, it worked.
leimao commentedon Nov 12, 2019
onnx.checker.check_model
sometimes does not recognize the model exported from PyTorch, and I suggest don't be too serious about it.garymm commentedon Dec 23, 2021
According to comments from @leimao this is fixed. If not please add details about what's left to do, with full repro code.