-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
cuda graph support multi-stream for new executor #51389
Merged
pangyoki
merged 3 commits into
PaddlePaddle:develop
from
pangyoki:cuda_graph_support_multi_stream_for_new_exe
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -539,6 +539,11 @@ void InterpreterCore::BuildInplace() { | |
void InterpreterCore::PrepareForCUDAGraphCapture() { | ||
if (!FLAGS_new_executor_use_cuda_graph) return; | ||
#ifdef PADDLE_WITH_CUDA | ||
PADDLE_ENFORCE_EQ( | ||
platform::IsCUDAGraphCapturing(), | ||
false, | ||
platform::errors::PermissionDenied("CUDA Graph is not allowed to capture " | ||
"when running the first batch.")); | ||
PADDLE_ENFORCE_EQ(platform::is_gpu_place(place_), | ||
true, | ||
platform::errors::InvalidArgument( | ||
|
@@ -670,6 +675,20 @@ void InterpreterCore::Convert( | |
auto& op_func_node = nodes[op_idx]; | ||
auto* dev_ctx_ = stream_analyzer_.ParseDeviceContext(op_func_node); | ||
vec_instruction_.emplace_back(op_idx, std::move(op_func_node), *dev_ctx_); | ||
#ifdef PADDLE_WITH_CUDA | ||
if (FLAGS_new_executor_use_cuda_graph) { | ||
auto& op = op_func_node.operator_base_; | ||
auto& op_type = op->Type(); | ||
if (op_type == interpreter::kMemcpyD2H || | ||
op_type == interpreter::kMemcpyH2D) { | ||
PADDLE_THROW(paddle::platform::errors::Fatal( | ||
"op_type can't be memcpy d2h or h2d while using cuda graph.")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the dev_ctx_ is CUDAContext, and change the error msg to "Cuda Memory copy d2h/h2d is not allowed while using cuda graph". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in PR #51648 |
||
} | ||
// cuda graph needs to record all stream | ||
phi::backends::gpu::CUDAGraphContextManager::Instance() | ||
.RecordCapturingDeviceContext(dev_ctx_); | ||
} | ||
#endif | ||
} | ||
|
||
BuildOperatorDependences(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> CUDA Graph is not allowed to capture before prepare.
first batch is not clear and confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in PR #51648