- net_path = 'kitti_retinanet_78.pt'
- retinanet = torch.load(net_path, map_location=torch.device('cpu'))
- data = torch.rand(1, 3, 320, 1056)
- retinanet.eval()
- traced_script_module = torch.jit.trace(retinanet, example)
- torch.jit.save(traced_script_module, 'rknn_retinanet.pt')
- print(traced_script_module)
复制代码
接着通过如下的代码转换模型,- import numpy as np
- import cv2
- from rknn.api import RKNN
- import torchvision.models as models
- import torch
- import os
- model = './rknn_retinanet.pt'
- input_size_list = [[1, 3, 320, 1056]]
- # Create RKNN object
- rknn = RKNN(verbose=True)
- # Pre-process config
- print('--> Config model')
- rknn.config(mean_values=[0, 0, 0], std_values=[58.395, 58.395, 58.395])
- print('done')
- # Load model
- print('--> Loading model')
- ret = rknn.load_pytorch(model=model, input_size_list=input_size_list)
- if ret != 0:
- print('Load model failed!')
- exit(ret)
- print('done')
- # Build model
- print('--> Building model')
- ret = rknn.build(do_quantization=False, dataset='./dataset.txt')
复制代码
在执行rknn.build这个函数的时候报了segmetation fault的错误:- W __init__: rknn-toolkit2 version: 1.4.0-22dcfef4
- --> Config model
- W config: 'target_platform' is None, use rk3566 as default, Please set according to the actual platform!
- done
- --> Loading model
- PtParse: ███████████████████████████████████████████████▌ | 1214/1277 PtParse: 100%|█████████████████████████████████████████████████| 1277/1277 [00:09<00:00, 133.85it/s]
- done
- --> Building model
- I base_optimize ...
- Segmentation fault (core dumped)
复制代码
想请教一下会不会是模型太大了导致了这种错误?jefferyzhang 发表于 2023-3-17 17:18
debug的话可以自己用gdb跟下看下堆栈,这样发给npu部门查看的时候会更快定位问题。
然后你可以先把这个pt文 ...
欢迎光临 Toybrick (https://t.rock-chips.com/) | Powered by Discuz! X3.3 |