PaddleHub icon indicating copy to clipboard operation
PaddleHub copied to clipboard

自己训练的推理模型,图片验证的时候出现了这样的错误?

Open sunhufei opened this issue 5 years ago • 10 comments

欢迎您反馈PaddleHub使用问题,非常感谢您对PaddleHub的贡献! 在留下您的问题时,辛苦您同步提供如下信息:

  • 版本、环境信息 1)PaddleHub和PaddlePaddle版本:请提供您的PaddleHub和PaddlePaddle版本号,例如PaddleHub1.4.1,PaddlePaddle1.6.2 2)系统环境:请您描述系统类型,例如Linux/Windows/MacOS/,python版本
  • 复现信息:如为报错,请给出复现环境、复现步骤 paddle 1.8.5 paddlehub 1.7.1

D:\soft_path\Anaconda\lib\site-packages\win32\lib\pywintypes.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import sys, os,imp W0315 15:06:41.720773 21248 analysis_predictor.cc:1059] Deprecated. Please use CreatePredictor instead. e[37m--- fused 0 scale with matmule[0m e[37m--- Fused 0 ReshapeTransposeMatmulMkldnn patternse[0m e[37m--- Fused 0 ReshapeTransposeMatmulMkldnn patterns with transpose's xshapee[0m e[37m--- Fused 0 ReshapeTransposeMatmulMkldnn patterns with reshape's xshapee[0m e[37m--- Fused 0 ReshapeTransposeMatmulMkldnn patterns with reshape's xshape with transpose's xshapee[0m e[37m--- Fused 0 MatmulTransposeReshape patternse[0m e[37m--- fused 0 batch norm with relu activatione[0m Traceback (most recent call last): File "E:/Projection/unit3/predict_module/demo2.py", line 11, in result = seg.people_segmentation(images=[cv2.imread(img2)]) File "E:\Projection\unit3\predict_module\module.py", line 123, in people_segmentation self.segmentation_net.zero_copy_run() MemoryError: In user code:

File "D:\soft_path\Anaconda\lib\site-packages\paddle\fluid\framework.py", line 2604, in append_op
op = Operator(

File "D:\soft_path\Anaconda\lib\site-packages\paddle\fluid\layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)

File "D:\soft_path\Anaconda\lib\site-packages\paddle\fluid\layers\nn.py", line 2922, in conv2d
helper.append_op(

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\nets\libs.py", line 128, in conv
return fluid.layers.conv2d(*args, **kargs)

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\nets\libs.py", line 153, in separate_conv
input = conv(

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\nets\backbone\xception.py", line 268, in xception_block
data = separate_conv(

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\nets\backbone\xception.py", line 199, in middle_flow
data, short_cuts = self.xception_block(

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\nets\backbone\xception.py", line 81, in __call__
data = self.middle_flow(data)

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\nets\deeplabv3p.py", line 366, in build_net
data, decode_shortcuts = backbone_net(image)

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\models\humanseg.py", line 852, in build_net
model_out = model.build_net(inputs)

File "E:\Face_Detection\PaddleSeg-release-v0.7.0\PaddleSeg-release-v0.7.0\contrib\HumanSeg\models\load_model.py", line 43, in load_model
model.test_inputs, model.test_outputs = model.build_net(

File "export.py", line 37, in export
model = models.load_model(args.model_dir)

File "export.py", line 43, in <module>
export(args)


ResourceExhaustedError: Fail to alloc memory of 263380608 size.
  [Hint: p should not be null.] (at D:\v2.0.0\paddle\paddle\fluid\memory\detail\system_allocator.cc:69)
  [operator < conv2d > error]

Process finished with exit code 1

希望寻求帮助

sunhufei avatar Mar 15 '21 08:03 sunhufei

您好,请问是使用paddleseg时候有问题吗,如果是,请移步到paddleseg提issue,感谢您的配合https://github.com/PaddlePaddle/PaddleSeg

haoyuying avatar Mar 15 '21 09:03 haoyuying

就是推理模型

sunhufei avatar Mar 15 '21 09:03 sunhufei

请您把具体的使用模型以及您的用法提供给我们,从报错栈的信息来看,是load模型出现了问题

haoyuying avatar Mar 15 '21 10:03 haoyuying

这个怎么给呀,怎么上传

sunhufei avatar Mar 17 '21 00:03 sunhufei

您可以到百度aistudio上上传,您的报错信息是不是内存或者显存不足导致的,建议您在百度aistudio上建立一个复现环境,若该问题不是由于paddlehub提供的模型导致的,建议您到paddle相应的repo下提出问题,以便得到更好更专业的回复。 从您目前的报错信息来看,我的建议是:

para_state_dict = paddle.load(args.model_dir)
model_state_dict = model.state_dict()
keys = model_state_dict.keys()
num_params_loaded = 0
for k in keys:
    if k not in para_state_dict:
        print("{} is not in pretrained model".format(k))
    elif list(para_state_dict[k].shape) != list(
            model_state_dict[k].shape):
        print("[SKIP] Shape of pretrained params {} doesn't match.(Pretrained: {}, Actual: {})"
              .format(k, para_state_dict[k].shape,
                      model_state_dict[k].shape))
    else:
        model_state_dict[k] = para_state_dict[k]
        num_params_loaded += 1
model.set_dict(model_state_dict)
print('load model success')

看下模型和参数load是否存在不匹配问题

haoyuying avatar Mar 17 '21 02:03 haoyuying

但是我的模型是封装过的 ,这个好像实现不了

sunhufei avatar Mar 17 '21 13:03 sunhufei

那请您在aistudio上创建一个可复现问题的环境。

haoyuying avatar Mar 18 '21 01:03 haoyuying

你怎么可以看的到?

sunhufei avatar Mar 18 '21 13:03 sunhufei

您需要看什么呢?我可以帮您实现,您说一下您的疑点。

sunhufei avatar Mar 18 '21 13:03 sunhufei

paddle似乎很占显存

ljwmusclenlper avatar Sep 14 '22 09:09 ljwmusclenlper