Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 3 tasks
a-strong-python opened this issue Jul 12, 2023 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@a-strong-python
Copy link

问题确认 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

  • 我确认已经提供了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 a-strong-python added the bug Something isn't working label Jul 12, 2023
@wuyefeilin
Copy link
Collaborator

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

@wuyefeilin wuyefeilin self-assigned this Jul 13, 2023
@a-strong-python
Copy link
Author

是的

@a-strong-python
Copy link
Author

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

@1119042610
Copy link

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

@Ericgone
Copy link

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次: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)了。

@1119042610
Copy link

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次: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

@Programrookie33
Copy link

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次: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

@henryccl
Copy link

所以这个问题没有解决吗?我也遇到这个问题。而且前面的警告一直停不下来,好像是每轮报两次: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

@RannnC
Copy link

RannnC commented Oct 11, 2023

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

@Programrookie33
Copy link

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

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

@RannnC
Copy link

RannnC commented Oct 11, 2023

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

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

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

@yuzu16
Copy link

yuzu16 commented Jan 3, 2024

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

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

@TingquanGao
Copy link
Collaborator

Thanks for this issue. As it has been inactive for a long time, we would close it. If you has any questions, please feel free to reopen or new issue, and we will follow up and resolve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants