kendryte / nncase

Open deep learning compiler stack for Kendryte AI accelerators ✨
Apache License 2.0
753 stars 182 forks source link

RuntimeError: Allocator has ran out of memory #380

Closed rogerkuo1981 closed 3 years ago

rogerkuo1981 commented 3 years ago

Describe the bug RuntimeError: Allocator has ran out of memory

To Reproduce compile.py last_sim.onnx best_224_quant.kmodel --imgs_dir .\test --legacy --target k210

Expected behavior convert kmodel

Origin model and code

Environment (please complete the following information):

Additional context D:\Python\nncase-master\examples\yolox>tools\compile.py last_sim.onnx best_224_quant.kmodel --imgs_dir .\test --legacy --target k210 15784

  1. Import graph... 1.1 Pre-process... |Dequantize: |Letterbox: |Normalize:
  2. Optimize target independent...
  3. Optimize target dependent... 4.1. Add quantize annotation... 4.2. Run calibration... 4.2.1 Collecting ranges... 4.3. Quantize graph...
  4. Optimize target dependent after quantization...
  5. Optimize modules... 7.1. Merge module regions... 7.2. Optimize buffer fusion... 7.3. Optimize target dependent after buffer fusion...
  6. Generate code... Traceback (most recent call last): File "D:\Python\nncase-master\examples\yolox\tools\compile.py", line 103, in args.test_size, args.legacy, args.no_preprocess) File "D:\Python\nncase-master\examples\yolox\tools\compile.py", line 78, in main kmodel_bytes = compiler.gencode_tobytes() RuntimeError: Allocator has ran out of memory
rogerkuo1981 commented 3 years ago

Yolox转出onnx可以成功,但是yolov5转的onnx就报这个错误,是不能支持V5的onnx吗?

sunnycase commented 3 years ago

https://github.com/kendryte/nncase/blob/master/docs/FAQ_ZH.md#%E9%83%A8%E7%BD%B2%E6%A8%A1%E5%9E%8B 第2条

rogerkuo1981 commented 3 years ago

https://github.com/kendryte/nncase/blob/master/docs/FAQ_ZH.md#%E9%83%A8%E7%BD%B2%E6%A8%A1%E5%9E%8B 第2条

多谢多谢! VOC训练出来的模型太大,export_onnx时候已把test_size改为(224.224),最终生成的kmodel还是8M左右,对于K210来说仍然太大。编译时候报错 region `ram' overflowed by 4142448 bytes。 除了继续改小test_size之外,还有其他办法可以让模型变小一点吗

sunnycase commented 3 years ago

可以减少通道数、采用 DepthwiseConv2D 替换普通 Conv2D 等