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

Can't call main_program when full_graph=False. Use paddle.jit.to_static(full_graph=True) instead. #8941

Open
2 of 3 tasks
zhenzi0322 opened this issue Apr 20, 2024 · 2 comments
Assignees

Comments

@zhenzi0322
Copy link

zhenzi0322 commented Apr 20, 2024

问题确认 Search before asking

  • 我已经查询历史issue,没有发现相似的bug。I have searched the issues and found no similar bug report.

Bug组件 Bug Component

No response

Bug描述 Describe the Bug

使用导出模型发生异常:

python tools/export_model.py -c configs/yolov3/yolov3_mobilenet_v1_roadsign.yml --output_dir=inference_model -o weights=https://paddledet.bj.bcebos.com/models/yolov3_mobilenet_v1_270e_coco.pdparams

异常如下:

Traceback (most recent call last):
  File "E:\python\test\PaddleDetection\tools\export_model.py", line 118, in <module>
    main()
  File "E:\python\test\PaddleDetection\tools\export_model.py", line 114, in main
    run(FLAGS, cfg)
  File "E:\python\test\PaddleDetection\tools\export_model.py", line 80, in run
    trainer.export(FLAGS.output_dir, for_fd=FLAGS.for_fd)
  File "E:\python\test\PaddleDetection\ppdet\engine\trainer.py", line 1229, in export
    static_model, pruned_input_spec = self._get_infer_cfg_and_input_spec(
  File "E:\python\test\PaddleDetection\ppdet\engine\trainer.py", line 1181, in _get_infer_cfg_and_input_spec
    input_spec, static_model.forward.main_program,
  File "D:\python\Envs\test-2Ti2Q\lib\site-packages\paddle\jit\dy2static\program_translator.py", line 768, in main_program
    raise_error_template("main_program")()
  File "D:\python\Envs\test-2Ti2Q\lib\site-packages\paddle\jit\dy2static\program_translator.py", line 704, in _raise_error
    raise RuntimeError(error_template.format(func=func_str))
RuntimeError: Can't call main_program when full_graph=False. Use paddle.jit.to_static(full_graph=True) instead.

复现环境 Environment

拉取分支release/2.7代码。然后按下面的步骤进行即可复现异常。

python tools/train.py -c configs/yolov3/yolov3_mobilenet_v1_roadsign.yml --eval -o use_gpu=true

python tools/export_model.py -c configs/yolov3/yolov3_mobilenet_v1_roadsign.yml --output_dir=inference_model -o weights=https://paddledet.bj.bcebos.com/models/yolov3_mobilenet_v1_270e_coco.pdparams

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!
@zhiboniu
Copy link
Collaborator

可能版本有更新,加上full_graph=True这个参数试一下呢

@Dat0901
Copy link

Dat0901 commented Apr 25, 2024

In ppdet/engine/trainer.py
find
if prune_input:
static_model = paddle.jit.to_static(
self.model, input_spec=input_spec)
change to
if prune_input:
static_model = paddle.jit.to_static(
self.model, input_spec=input_spec, full_graph=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants