管理接口平台,提高工作效率的关键解决方案
621
2022-09-07
【pytorch】——Could not export Python function call ‘Scatter‘(pytorch命令)
pytorch
用pytorch的 trace 导出模型的时候,报错
error
RuntimeError: Could not export Python function call 'Scatter'. 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__:/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(13): scatter_map/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(15): scatter_map/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(28): scatter/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(36): scatter_kwargs/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/data_parallel.py(168): scatter/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/data_parallel.py(157): forward/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(709): _slow_forward/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(725): _call_impl/usr/local/lib/python3.7/dist-packages/torch/jit/_trace.py(940): trace_module/usr/local/lib/python3.7/dist-packages/torch/jit/_trace.py(742): trace
解决方案
将model改为
model = model.module
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~