- Notifications
You must be signed in to change notification settings - Fork 5.9k
Add CUDA profiler tools in new framework. #5954
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
Conversation
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.
@qingqing01 Overall looks good to me.
In the issue description(#5953), could you please provide a couple of examples where this feature is useful? Especially where nvprof is not sufficient.
paddle/platform/cuda_profiler.h Outdated
| memcpy(buf.data(), tmpl.data(), tmpl.size()); | ||
| auto result = mktemp(buf.data()); | ||
| PADDLE_ENFORCE(strlen(result) != 0); | ||
| std::string config = result; |
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.
probably config -> config_file would be a better name.
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.
Done.
paddle/platform/cuda_profiler.h Outdated
| | ||
| void CudaProfilerStart() { PADDLE_ENFORCE(cudaProfilerStart()); } | ||
| | ||
| void CudaProfilerStop() { PADDLE_ENFORCE((cudaProfilerStop())); } |
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.
remove the parentheses.
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.
Done.
python/paddle/v2/fluid/profiler.py Outdated
| ] | ||
| | ||
| | ||
| def nvporf_init(output_file, output_mode=None, flags=None): |
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.
We currently use google style for Python comment.
http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
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.
Done. Move the comments to the refined CudaProfiler.
python/paddle/v2/fluid/profiler.py Outdated
| core.nvprof_stop() | ||
| | ||
| | ||
| class CudaProfiler(object): |
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.
This a good implementation.
I recently found a wonderful package named contextmanager. It can make the profiler to one function.
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.
Done. Cool! Thanks!
python/paddle/v2/fluid/profiler.py Outdated
| core.nvprof_init(output_file, output_mode, flags) | ||
| | ||
| | ||
| def nvporf_start(): |
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.
nvporf --> nvprof
| """ | ||
| Enables profiler collection by the active CUDA profiling tool. | ||
| """ | ||
| core.nvprof_start() |
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.
I think this function may not need wrap again in Python code.
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.
Done. Remove them.
python/paddle/v2/fluid/profiler.py Outdated
| self.out_file = output_file | ||
| nvporf_init(output_file, output_mode, flags) | ||
| | ||
| def __enter__(self): |
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.
these two functions can be replaced with contextmanager.
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.
Done.
| @tonyyang-svail I update the issue description(#5953) and give a simple example. And the output file needs to be made more human-readable 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.
Execellent.
Fix #5953
The usage is: