Skip to content

Commit 1e4d95c

Browse files
authored
Merge pull request #8844 from jacquesqiao/add-timeling-profile-howto
add timeline profile howto
2 parents b1d2bf5 + 205cadf commit 1e4d95c

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
69 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## how to use timeline tool to do profile
2+
3+
1. Add `with profiler.profiler(...)` to the main training loop. After run, the code will generate a profile record file `/tmp/profile`. **Warning**: Please do not run too many batches when use profiler to record timeline information, for the profile record will grow with the batch number.
4+
5+
```python
6+
with profiler.profiler('All', 'total', '/tmp/profile') as prof:
7+
for pass_id in range(pass_num):
8+
for batch_id, data in enumerate(train_reader()):
9+
exe.run(fluid.default_main_program(),
10+
feed=feeder.feed(data),
11+
fetch_list=[],
12+
use_program_cache=True)
13+
...
14+
```
15+
16+
1. Run `python paddle/tools/timeline.py` to process `/tmp/profile`, it will generate another
17+
file `/tmp/timeline` by default. You can change the path by cmd parameter, please take a look at
18+
[timeline.py](https://github.com/PaddlePaddle/Paddle/blob/develop/tools/timeline.py) for details.
19+
20+
1. Open chrome and visit <chrome://tracing/>, use `load` button to load the generated `timeline` file.
21+
22+
![chrome tracing](./tracing.jpeg)
23+
24+
1. The resulting timeline should be like:
25+
26+
27+
![chrome timeline](./timeline.jpeg)
29.9 KB
Loading

0 commit comments

Comments
 (0)