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

fix RecordStreamForGC nullptr exception #54606

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

engineer1109
Copy link
Contributor

PR types

Bug fixes

PR changes

Others

Description

某种情况下,同时打开GPU和CUSTOM_DEVICE的编译选项

cmake .. -DWITH_GPU=ON -DWITH_CUSTOM_DEVICE=ON -DWITH_TENSORRT=ON

使用Custom Device进行推理。
会出现空指针的异常。

I0613 13:41:04.066522 3527536 interpretercore.cc:237] New Executor is Running.
I0613 13:41:04.432148 3527536 conditional_block_op.cc:98] [ControlFlow][ConditionalBlock] New Executor is Running.
W0613 13:41:04.549906 3528349 interpretercore.cc:1022] memcpy_h2d raises an exception paddle::PD_Exception, the gpu stream is nullptr.
  [/media/wjl/D2/github/fork/Paddle/paddle/phi/backends/gpu/gpu_context.cc:324]
W0613 13:41:04.552162 3527536 operator.cc:804] while raises an exception std::exception, std::exception
terminate called after throwing an instance of 'std::exception'
  what():  std::exception

原因是 paddle/fluid/framework/new_executor/interpretercore.cc
RecordStreamForGC 这个函数里
有这样一行代码

 gpuStream_t stream =
      reinterpret_cast<const phi::GPUContext&>(instr.DeviceContext()).stream();

不管是GPUContext还是CustomContext 都会执行。

目前仅在这个模型下发现这个问题。
链接: https://pan.baidu.com/s/1CSqbKXVlT1gwIyCkAkDBJg?pwd=twk5 提取码: twk5
修复补丁确认可以修复。

@paddle-bot
Copy link

paddle-bot bot commented Jun 13, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Jun 13, 2023
@engineer1109
Copy link
Contributor Author

@luotao1 有空能否review一下

@luotao1
Copy link
Contributor

luotao1 commented Jun 15, 2023

@engineer1109 后续可以直接 @qili93@ronny1996 review哈

@engineer1109
Copy link
Contributor Author

@ronny1996 How about this PR?

Copy link
Contributor

@ronny1996 ronny1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ronny1996 ronny1996 merged commit 5f92cc5 into PaddlePaddle:develop Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants