timeline_en.md 1.4 KB
Newer Older
W
weixing 已提交
1
# how to use timeline tool to do profile
Q
qiaolongfei 已提交
2

X
Xin Pan 已提交
3
1. Add `profiler.start_profiler(...)``profiler.stop_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.
Q
qiaolongfei 已提交
4 5

	```python
X
add doc  
Xin Pan 已提交
6 7 8 9 10 11 12 13 14
    for pass_id in range(pass_num):
        for batch_id, data in enumerate(train_reader()):
            if pass_id == 0 and batch_id == 5:
                profiler.start_profiler("All")
            elif pass_id == 0 and batch_id == 10:
                profiler.stop_profiler("total", "/tmp/profile")
            exe.run(fluid.default_main_program(),
                    feed=feeder.feed(data),
                    fetch_list=[])
Q
qiaolongfei 已提交
15 16 17 18 19 20 21
	            ...
	```

1. Run `python paddle/tools/timeline.py` to process `/tmp/profile`, it will generate another
file `/tmp/timeline` by default. You can change the path by cmd parameter, please take a look at
[timeline.py](https://github.com/PaddlePaddle/Paddle/blob/develop/tools/timeline.py) for details.

X
add doc  
Xin Pan 已提交
22 23 24 25
```python
python Paddle/tools/timeline.py --profile_path=/tmp/profile --timeline_path=timeline
```

Q
qiaolongfei 已提交
26 27 28 29 30 31 32 33
1. Open chrome and visit <chrome://tracing/>, use `load` button to load the generated `timeline` file.

	![chrome tracing](./tracing.jpeg)

1. The resulting timeline should be like:


	![chrome timeline](./timeline.jpeg)