Skip to content

ONNX export regression: examples/fast_neural_style fails to export (pytorch_nightly) #19374

@borisfom

Description

@borisfom

🐛 Bug

ONNX export regression: examples/fast_neural_style fails to export (pytorch_nightly)

To Reproduce

Steps to reproduce the behavior:

  1. cd pytorch/examples/fast_neural_style
  2. python3 neural_style/neural_style.py eval --content-image test,jpg --output-image res.jpg --cuda 1 --export_onnx mosaic.onnx --model saved_models/mosaic.pth

Traceback (most recent call last):
File "neural_style/neural_style.py", line 240, in
main()
File "neural_style/neural_style.py", line 236, in main
stylize(args)
File "neural_style/neural_style.py", line 147, in stylize
output = torch.onnx._export(style_model, content_image, args.export_onnx).cpu()
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/init.py", line 19, in _export
result = utils._export(*args, **kwargs)
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 338, in _export
_retain_param_name)
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 260, in _model_to_graph
graph = _optimize_graph(graph, operator_export_type)
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 178, in _optimize_graph
Graph = Torch._C._jit_pass_onnx(graph, operator_export_type)
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/init.py", line 50, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 563, in _run_symbolic_function
return fn(g, *inputs, **attrs)
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/symbolic.py", line 130, in wrapper
args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/symbolic.py", line 130, in
args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
File "/home/bfomitchev/anaconda3/lib/python3.6/site-packages/torch/onnx/symbolic.py", line 90, in _parse_arg
raise RuntimeError("Failed to export an ONNX attribute, "
RuntimeError: Failed to export an ONNX attribute, since it's not constant, please try to make things (e.g., kernel size) static if possible

Expected behavior

Environment

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
  • PyTorch Version (e.g., 1.0): pytorch_nightly
  • OS (e.g., Linux): Linux
  • How you installed PyTorch (conda, pip, source): conda install -c pytorch pytorch-nightly
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version: 10.0/7.4
  • GPU models and configuration: Volta, Turing
  • Any other relevant information: This export worked since forever, broke at some point last month

Additional context

Metadata

Metadata

Assignees

Labels

module: onnxRelated to torch.onnxtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions