Toybrick

rknn.load_pytorch 模型加载接口报错

ivanzheng

注册会员

积分
65
楼主
发表于 2020-4-20 10:39:44    查看: 17633|回复: 9 | [复制链接]    打印 | 只看该作者

Hi 你好,
我在将pytorch 模型转换成 rknn模型时,出现以下错误, 看错误信息好像是PixelShuffle 算子不支持, 如果想把这个模型(超分辨率)跑在 rk3399pro 上面,需要如何处理,请指教,多谢

rknn 版本: 1.3

模型repo:
https://github.com/thstkdgus35/EDSR-PyTorch

错误信息:
E Catch exception when loading pytorch model: ./edsr_baseline_x2_pytorch.pt!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 567, in rknn.api.rknn_base.RKNNBase.load_pytorch
E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 95, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 517, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.__init__
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 601, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.model_simplify
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 104, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 139, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 247, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.convolution_shape
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 104, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 139, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 247, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.convolution_shape
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 104, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.shape_pick
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 139, in rknn.base.RKNNlib.converter.convert_pytorch.torch_inference_engine.__ir_shape_inference
E KeyError: 'aten::pixel_shuffle'
Load pytorch model failed!


回复

使用道具 举报

jefferyzhang

版主

积分
13578
沙发
发表于 2020-4-20 11:05:07 | 只看该作者
请问下pyTorch的版本号是多少
回复

使用道具 举报

ivanzheng

注册会员

积分
65
板凳
 楼主| 发表于 2020-4-20 11:20:35 | 只看该作者
jefferyzhang 发表于 2020-4-20 11:05
请问下pyTorch的版本号是多少

pytorch 版本:1.2.0
回复

使用道具 举报

jefferyzhang

版主

积分
13578
地板
发表于 2020-4-20 11:29:50 | 只看该作者

解决方法:
1. 我会把这个op报给相关部门支持,要等未来版本出来大家才能用到。
2. 自己修改模型绕过这个OP
3. 用其他的框架试试,例如pytorch转onnx再转rknn
4. 尝试自己支持,我们rknn支持自定op,可以自己根据op的逻辑写一个op出来。
回复

使用道具 举报

ivanzheng

注册会员

积分
65
5#
 楼主| 发表于 2020-4-20 11:41:41 | 只看该作者
jefferyzhang 发表于 2020-4-20 11:29
解决方法:
1. 我会把这个op报给相关部门支持,要等未来版本出来大家才能用到。
2. 自己修改模型绕过这个 ...

好的,感谢, 下一个发布版本会支持嘛? 下个版本预计什么时候发布哈?
另外, 如果是tensorflow 实现的这个模型,  PixelShuffle  算子 rknn 目前支持不?
回复

使用道具 举报

jefferyzhang

版主

积分
13578
6#
发表于 2020-4-20 11:49:34 | 只看该作者
ivanzheng 发表于 2020-4-20 11:41
好的,感谢, 下一个发布版本会支持嘛? 下个版本预计什么时候发布哈?
另外, 如果是tensorflow 实现的这 ...

这个我也不确定,我不是NPU部门的,我也只是一个rknn的开发者之一。只能说试试。
回复

使用道具 举报

jefferyzhang

版主

积分
13578
7#
发表于 2020-4-24 15:37:42 | 只看该作者
NPU部门回复:

1.请用1.3.3_beta2版本:
链接: https://pan.baidu.com/s/12ayycMiZGvJnpcD13DmH9g 密码: fe2w
2.rknn.config里加上optimization_level=2
回复

使用道具 举报

topology

新手上路

积分
30
8#
发表于 2021-1-11 15:02:19 | 只看该作者
rknn.config(channel_mean_value='123.675 116.28 103.53 58.82', reorder_channel='0 1 2')  
Input_Size = [[3,640,640]]
ret = rknn.load_pytorch(model='weights/best_person_plate_clean.pt',input_size_list=Input_Size) 出错
weights/best_person_plate_clean.pt ********************
E Catch exception when loading pytorch model: weights/best_person_plate_clean.pt!
E Traceback (most recent call last):
E   File "rknn/api/rknn_base.py", line 611, in rknn.api.rknn_base.RKNNBase.load_pytorch
E   File "rknn/base/RKNNlib/app/importer/import_pytorch.py", line 97, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E   File "rknn/base/RKNNlib/converter/convert_pytorch.py", line 592, in rknn.base.RKNNlib.converter.convert_pytorch.convert_pytorch.__init__
E   File "/home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/jit/__init__.py", line 162, in load
E     cpp_module = torch._C.import_ir_module(cu, f, map_location, _extra_files)
E RuntimeError: [enforce fail at inline_container.cc:137] . PytorchStreamReader failed reading zip archive: failed finding central directory
E frame #0: c10::ThrowEnforceNotMet(char const*, int, char const*, std::string const&, void const*) + 0x5b (0x7f6d5e8d7bcb in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libc10.so)
E frame #1: caffe2::serialize:yTorchStreamReader::valid(char const*) + 0x6b (0x7f6d6842202b in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libtorch.so)
E frame #2: caffe2::serialize:yTorchStreamReader::init() + 0x9a (0x7f6d68425ada in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libtorch.so)
E frame #3: caffe2::serialize:yTorchStreamReader:yTorchStreamReader(std::string const&) + 0x60 (0x7f6d68428b40 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libtorch.so)
E frame #4: torch::jit::import_ir_module(std::shared_ptr<torch::jit::script::CompilationUnit>, std::string const&, c10:ptional<c10:evice>, std::unordered_map<std::string, std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, std::string> > >&) + 0x38 (0x7f6d69507928 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libtorch.so)
E frame #5: <unknown function> + 0x4d6903 (0x7f6d8f705903 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
E frame #6: <unknown function> + 0x1c8316 (0x7f6d8f3f7316 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/torch/lib/libtorch_python.so)
E <omitting python frames>
E frame #11: <unknown function> + 0x21266 (0x7f6d9679c266 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/base/RKNNlib/converter/convert_pytorch.cpython-36m-x86_64-linux-gnu.so)
E frame #12: <unknown function> + 0x22c07 (0x7f6d9679dc07 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/base/RKNNlib/converter/convert_pytorch.cpython-36m-x86_64-linux-gnu.so)
E frame #13: <unknown function> + 0x75ccd (0x7f6d967f0ccd in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/base/RKNNlib/converter/convert_pytorch.cpython-36m-x86_64-linux-gnu.so)
E frame #19: <unknown function> + 0x6dec (0x7f6d96e3adec in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/base/RKNNlib/app/importer/import_pytorch.cpython-36m-x86_64-linux-gnu.so)
E frame #20: <unknown function> + 0xd6a1 (0x7f6d96e416a1 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/base/RKNNlib/app/importer/import_pytorch.cpython-36m-x86_64-linux-gnu.so)
E frame #21: <unknown function> + 0x1388c (0x7f6d96e4788c in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/base/RKNNlib/app/importer/import_pytorch.cpython-36m-x86_64-linux-gnu.so)
E frame #22: <unknown function> + 0x21f4d (0x7f6e1eda5f4d in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/api/rknn_base.cpython-36m-x86_64-linux-gnu.so)
E frame #23: <unknown function> + 0x23b99 (0x7f6e1eda7b99 in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/api/rknn_base.cpython-36m-x86_64-linux-gnu.so)
E frame #24: <unknown function> + 0xa085c (0x7f6e1ee2485c in /home/denghui/anaconda3/envs/rknn/lib/python3.6/site-packages/rknn/api/rknn_base.cpython-36m-x86_64-linux-gnu.so)
E frame #39: __libc_start_main + 0xf0 (0x7f6e5cc36840 in /lib/x86_64-linux-gnu/libc.so.6)
Load model failed!
回复

使用道具 举报

topology

新手上路

积分
30
9#
发表于 2021-1-11 15:04:34 | 只看该作者
请教是什么问题?环境python:3.6,torch:1.2.0,torchvision:0.4.0,rknn:1.3.3b2,tensorflow:1.11.0
回复

使用道具 举报

liuyiyiyiyi

新手上路

积分
27
10#
发表于 2021-8-30 18:25:10 | 只看该作者
topology 发表于 2021-1-11 15:02
rknn.config(channel_mean_value='123.675 116.28 103.53 58.82', reorder_channel='0 1 2')  
Input_Size  ...

你好,这个问题解决了嘛
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表