Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.45k stars 4.16k forks source link

FATAL ERROR! pool allocator destroyed too early (nil) still in use #5306

Open SEMLLYCAT opened 9 months ago

SEMLLYCAT commented 9 months ago

error log | 日志或报错信息 | ログ

FATAL ERROR! pool allocator destroyed too early (nil) still in use

context | 编译/运行环境 | バックグラウンド

最新

how to reproduce | 复现步骤 | 再現方法

import torch as nn import torch.nn.functional as FF

def unfold(input): B, C, T, F = input.shape input = FF.pad(input, (1,1)) output = [] for i in range(C): output_c = torch.cat([input[:, i, :, :F], input[:, i, :, 1:F+1], input[:, i, :, 2:F+2], dim=1) output.append(output_C) output = torch.cat(output, dim=1) return output class D(nn.Module): def init(self, k=3): self.k = 3 def forward(self, x): x = unfold(x).reshape(x.shape[0], x.shape[1]*k, x.shape[2], x.shape[3]) y = unfold(x) return y if name == "main": device = torch.device("cpu") model = D.to(device).eval() x = torch.randn(1, 7, 1, 19) with torch.no_grad(): y = model(x)

more | 其他 | その他

问题:

  1. 将该模型转换为onnx并sim后,再转lpnn
  2. lpnn输出第一个unfold的结果是正常的,但是第二个unfold出现:FATAL ERROR! pool allocator destroyed too early (nil) still in use。 尝试了很多次不知道怎么解决这个问题,请各位大佬帮忙看下
SEMLLYCAT commented 9 months ago

@nihui

nihui commented 3 months ago

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx