You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Paddle/doc/fluid/howto/optimization/timeline_cn.md

1.4 KiB

如何使用timeline工具做性能分析

  1. 在训练的主循环外加上profiler.start_profiler(...)profiler.start_profiler(...)。运行之后,代码会在/tmp/profile目录下生成一个profile的记录文件。

    提示: 请不要在timeline记录信息时运行太多次迭代因为timeline中的记录数量和迭代次数是成正比的。

    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=[])
                ...
    
  2. 运行python paddle/tools/timeline.py来处理/tmp/profile,这个程序默认会生成一个/tmp/timeline文件,你也可以用命令行参数来修改这个路径,请参考timeline.py

python Paddle/tools/timeline.py --profile_path=/tmp/profile --timeline_path=timeline
  1. 打开chrome浏览器访问chrome://tracing/,用load按钮来加载生成的timeline文件。

    chrome tracing

  2. 结果如下图所示可以放到来查看timetime的细节信息。

    chrome timeline