paddlex训练模型时报错

mgdq6dx1  于 2023-02-04  发布在  其他
关注(0)|答案(2)|浏览(380)

使用paddle版本为paddle-gpu2.2.2
paddlex版本为1.3.11
cuda版本为11.2
cudnn版本为11.2
现存在以下问题,在我还没有安装cuda的时候尝试过使用cpu训练模型,运行成功并且成功导出模型。此时使用的是paddle不是gpu版本。
此后我安装了paddle的gpu版本以及cuda和cudnn但是再次训练的时候出现了报错。我尝试了如下几种解决办法均出现同样的报错信息
第1种解决办法:换paddle的cpu版本继续运行,未解决。
第2种解决办法:拆卸cuda,未解决。
第3种解决办法:重装整个python环境,未解决。
以上是我的所以解决方案,均未解决报错,并且报错信息均为一样,在aistudio上又能导出模型。
报错代码如下,均为完成一个epoch之后导出模型时出现
0%| | 0/3426 [00:00<?, ?it/s]
Traceback (most recent call last):
File "F:/python/first python/VOC_YOLO_RseNeXt.py", line 40, in
model.train(
File "F:\python\lib\site-packages\paddlex\cv\models\yolo_v3.py", line 168, in train
return super(YOLOv3, self).train(
File "F:\python\lib\site-packages\paddlex\cv\models\ppyolo.py", line 356, in train
self.train_loop(
File "F:\python\lib\site-packages\paddlex\cv\models\base.py", line 577, in train_loop
self.eval_metrics, self.eval_details = self.evaluate(
File "F:\python\lib\site-packages\paddlex\cv\models\ppyolo.py", line 427, in evaluate
outputs = self.exe.run(
File "F:\python\lib\site-packages\paddle\fluid\executor.py", line 1262, in run
six.reraise(*sys.exc_info())
File "F:\python\lib\site-packages\six.py", line 703, in reraise
raise value
File "F:\python\lib\site-packages\paddle\fluid\executor.py", line 1250, in run
return self._run_impl(
File "F:\python\lib\site-packages\paddle\fluid\executor.py", line 1394, in _run_impl
return self._run_program(
File "F:\python\lib\site-packages\paddle\fluid\executor.py", line 1491, in _run_program
self._default_executor.run(program.desc, scope, 0, True, True,
ValueError: In user code:

File "F:/python/first python/VOC_YOLO_RseNeXt.py", line 40, in <module>
  model.train(
File "F:\python\lib\site-packages\paddlex\cv\models\yolo_v3.py", line 168, in train
  return super(YOLOv3, self).train(
File "F:\python\lib\site-packages\paddlex\cv\models\ppyolo.py", line 346, in train
  self.build_program()
File "F:\python\lib\site-packages\paddlex\cv\models\base.py", line 113, in build_program
  self.test_inputs, self.test_outputs = self.build_net(
File "F:\python\lib\site-packages\paddlex\cv\models\ppyolo.py", line 175, in build_net
  model_out = model.build_net(inputs)
File "F:\python\lib\site-packages\paddlex\cv\nets\detection\yolo_v3.py", line 512, in build_net
  head_outputs = self._head(feats, self.mode == 'train')
File "F:\python\lib\site-packages\paddlex\cv\nets\detection\yolo_v3.py", line 141, in _head
  block = fluid.layers.concat(input=[route, block], axis=1)
File "F:\python\lib\site-packages\paddle\fluid\layers\tensor.py", line 375, in concat
  helper.append_op(
File "F:\python\lib\site-packages\paddle\fluid\layer_helper.py", line 43, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "F:\python\lib\site-packages\paddle\fluid\framework.py", line 3178, in append_op
  op = Operator(
File "F:\python\lib\site-packages\paddle\fluid\framework.py", line 2224, in __init__
  for frame in traceback.extract_stack():

InvalidArgumentError: The 2-th dimension of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1, 256, 20, 20], input[1]'s shape = [1, 256, 19, 19].
  [Hint: Expected inputs_dims[0][j] == inputs_dims[i][j], but received inputs_dims[0][j]:20 != inputs_dims[i][j]:19.] (at ..\paddle/fluid/operators/concat_op.h:63)
  [operator < concat > error]
mznpcxlj

mznpcxlj1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

7uhlpewt

7uhlpewt2#

hi @gznc-lhl ,

根据错误提示,是您模型代码中的concat算子的输入不符合要求

File "F:\python\lib\site-packages\paddlex\cv\nets\detection\yolo_v3.py", line 141, in _head
  block = fluid.layers.concat(input=[route, block], axis=1)

根据错误提示:

The 2-th dimension of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1, 256, 20, 20], input[1]'s shape = [1, 256, 19, 19].
  [Hint: Expected inputs_dims[0][j] == inputs_dims[i][j], but received inputs_dims[0][j]:20 != inputs_dims[i][j]:19.] (at ..\paddle/fluid/operators/concat_op.h:63)
  [operator < concat > error]

模型代码输入这里的 input=[route, block] 中route的shape为 [1, 256, 20, 20] 而block的shape为 [1, 256, 19, 19] , 在axis=1的情况下,是沿着数值为256的维度进行算子联结,因此其他维度的形状须一致。

建议检查您代码中的数据和处理逻辑使得concat算子的输入shape符合要求。

相关问题