Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导出onnx报错 Couldn't export Python operator _ModulatedDeformConv #36

Closed
ChungTak opened this issue May 17, 2021 · 8 comments
Closed

Comments

@ChungTak
Copy link

成功训练了模型,但运行"projects/speedup/centerX2onnx.py"导出 onnx 报错
"RuntimeError: ONNX export failed: Couldn't export Python operator _ModulatedDeformConv"

请问是什么导致?

@ChungTak
Copy link
Author

运行 centerX2pt.py 也不行
Could not export Python function call '_ModulatedDeformConv'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to constants:

@CPFLAME
Copy link
Collaborator

CPFLAME commented May 17, 2021

这是因为deformconv的原因,它不是一个常规的卷积层,各大平台对deform的支持也不够好。
如果要转onnx的话 建议把deformconv去掉,重新训练一个不带deformconv的model就可以了。
在yaml里面把USE_DEFORM设置为False,然后重新训练一个model就可以了

@ChungTak
Copy link
Author

USE_DEFORM设置为False重新训练,导出onnx出现了另外一个错误,网上搜索找不到解决办法~

  File "projects/speedup/centerX2onnx.py", line 143, in <module>
    onnx_model = export_onnx_model(model, inputs)
  File "projects/speedup/centerX2onnx.py", line 132, in export_onnx_model
    all_passes = onnx.optimizer.get_available_passes()
AttributeError: module 'onnx' has no attribute 'optimizer'

还有个新手问题`~~看到有导出onnx,caffe和pt的脚本,但没看见导出TensorRT的,请问要怎样转化为TensorRT文件?

@CPFLAME
Copy link
Collaborator

CPFLAME commented May 18, 2021

尝试一下用 pip install onnxruntime-gpu 呢。
onnx转tensorRT是我用的同事给我的docker环境转的,但是由于公司原因不能放出来。你可以自己搜一下网上从onnx转tensorRT的github,像centernet这种只有卷积+反卷积的结构转起来应该没有什么坑的。

@ChungTak
Copy link
Author

终于可以了原来默认安装的onnx 1.9.0版本太新,需要指定旧版
The optimizer code in onnx/onnx repo will be removed in 1.9 release.

@CPFLAME
Copy link
Collaborator

CPFLAME commented May 18, 2021

好滴 谢谢反馈

@CPFLAME CPFLAME closed this as completed May 18, 2021
@PiPiNam
Copy link

PiPiNam commented May 27, 2021

终于可以了原来默认安装的onnx 1.9.0版本太新,需要指定旧版
The optimizer code in onnx/onnx repo will be removed in 1.9 release.

兄弟,你后来装的是哪个版本的onnx解决的这个问题呀?谢谢!

@CPFLAME
Copy link
Collaborator

CPFLAME commented Jun 11, 2021

@PiPiNam 1.8.0的版本应该可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants