PaddleSeg icon indicating copy to clipboard operation
PaddleSeg copied to clipboard

paddleseg2.8根据官方文档跑默认的configs/quick_start/pp_liteseg_optic_disc_512x512_1k.yml配置报错

Open a-strong-python opened this issue 1 year ago • 12 comments

问题确认 Search before asking

Bug描述 Describe the Bug

当程序运行到第一次保存模型的轮数时,会报下面的警告和错误

I0712 14:24:21.198009 19039 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify 'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6.

2023-07-12 14:26:44 [INFO] [TRAIN] epoch: 17, iter: 500/10000, loss: 1.8821, lr: 0.000972, batch_cost: 0.4265, reader_cost: 0.30989, ips: 14.0681 samples/sec | ETA 01:07:31 2023-07-12 14:26:44 [INFO] Start evaluating (total_samples: 45, total_iters: 45)... Traceback (most recent call last): File "/home/aistudio/PaddleSeg/tools/train.py", line 195, in main(args) File "/home/aistudio/PaddleSeg/tools/train.py", line 170, in main train( File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddleseg/core/train.py", line 315, in train mean_iou, acc, _, _, _ = evaluate( File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddleseg/core/val.py", line 161, in evaluate intersect_area, pred_area, label_area = metrics.calculate_area( File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddleseg/utils/metrics.py", line 57, in calculate_area pred_area = paddle.concat(pred_area) File "/opt/conda/envs/python35-paddle120-env/lib/python3.10/site-packages/paddle/tensor/manipulation.py", line 1121, in concat return _C_ops.concat(input, axis) ValueError: (InvalidArgument) The axis is expected to be in range of [0, 0), but got 0 [Hint: Expected axis >= -rank && axis < rank == true, but received axis >= -rank && axis < rank:0 != true:1.] (at ../paddle/phi/infermeta/multiary.cc:961)

复现环境 Environment

  • OS: AI Studio
  • PaddlePaddle: 2.5.0
  • PaddleSeg: release/2.8

Bug描述确认 Bug description confirmation

  • [X] 我确认已经提供了Bug复现步骤、代码改动说明、以及环境信息,确认问题是可以复现的。I confirm that the bug replication steps, code change instructions, and environment information have been provided, and the problem can be reproduced.

是否愿意提交PR? Are you willing to submit a PR?

  • [ ] 我愿意提交PR!I'd like to help by submitting a PR!

a-strong-python avatar Jul 12 '23 10:07 a-strong-python

https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.8/docs/quick_start_cn.md 是根据教程用的官方提供的示例数据集吗

wuyefeilin avatar Jul 13 '23 03:07 wuyefeilin

是的

a-strong-python avatar Jul 14 '23 03:07 a-strong-python

在AI studio上面可以复现出来!

a-strong-python avatar Jul 14 '23 03:07 a-strong-python

同样的出错,在AiStudio上的PaddleSeg-2.6.0,我在不对模型进行评估的情况下可以正常保存模型,但是一旦对模型进行评估,--do_eval,就会报错

1119042610 avatar Jul 22 '23 06:07 1119042610

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次:I0712 14:24:21.198009 19039 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify 'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6. 愁死我了。这个警告一直在,关也关不掉。查看代码,Tensor.numpy()[0]早就改成了float(Tensor)了。

Ericgone avatar Aug 24 '23 02:08 Ericgone

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次:I0712 14:24:21.198009 19039 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify 'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6. 愁死我了。这个警告一直在,关也关不掉。查看代码,Tensor.numpy()[0]早就改成了float(Tensor)了。

关于这个警告,可以在训练前使用这个终端命令,使警告不出现。 export FLAGS_set_to_1d=False

1119042610 avatar Aug 24 '23 02:08 1119042610

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次:I0712 14:24:21.198009 19039 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify 'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6. 愁死我了。这个警告一直在,关也关不掉。查看代码,Tensor.numpy()[0]早就改成了float(Tensor)了。

具体的是:

PaddleSeg/paddleseg/core/train.py

1、 264行

avg_loss_list = [l.numpy() for l in loss_list] 改为

avg_loss_list = [l.item() for l in loss_list] 2、267行

avg_loss_list[i] += loss_list[i].numpy() 改为

avg_loss_list[i] += loss_list[i].item() 3、273行

avg_loss_list = [l[0] / log_iters for l in avg_loss_list] 此处是使用avg_loss_list中的值,因此要改l[0]为l

avg_loss_list = [l / log_iters for l in avg_loss_list] 这样就不会再报烦人的warning了 ———————————————— 版权声明:本文为CSDN博主「PL23K」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/pl23k/article/details/132614420

Programrookie33 avatar Sep 14 '23 13:09 Programrookie33

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次:I0712 14:24:21.198009 19039 eager_method.cc:140] Warning:: 0D Tensor cannot be used as 'Tensor.numpy()[0]' . In order to avoid this problem, 0D Tensor will be changed to 1D numpy currently, but it's not correct and will be removed in release 2.6. For Tensor contain only one element, Please modify 'Tensor.numpy()[0]' to 'float(Tensor)' as soon as possible, otherwise 'Tensor.numpy()[0]' will raise error in release 2.6. 愁死我了。这个警告一直在,关也关不掉。查看代码,Tensor.numpy()[0]早就改成了float(Tensor)了。

关于这个警告,可以在训练前使用这个终端命令,使警告不出现。 export FLAGS_set_to_1d=False

我遇到了同样的问题 但是使用这个命令并没有解决 image

henryccl avatar Sep 20 '23 03:09 henryccl

我也遇到了一样的问题,请问题主解决了吗

RannnC avatar Oct 11 '23 14:10 RannnC

我也遇到了一样的问题,请问题主解决了吗

详情请见 https://github.com/PaddlePaddle/PaddleSeg/issues/3408 我之前遇到同样的问题按照方式这个解决了

Programrookie33 avatar Oct 11 '23 14:10 Programrookie33

我也遇到了一样的问题,请问题主解决了吗

详情请见 #3408 我之前遇到同样的问题按照方式这个解决了

好嘞我试试,不过这个装得好慢啊~

RannnC avatar Oct 11 '23 15:10 RannnC

序运行到第一个保存模型的轮数时,会报下面的警告和

解决了吗 ?请问怎么解决的呀

yuzu16 avatar Jan 03 '24 09:01 yuzu16