Skip to content
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

Feature/cpu profiling #5895

Merged
merged 3 commits into from
Nov 27, 2017
Merged

Conversation

reyoung
Copy link
Collaborator

@reyoung reyoung commented Nov 24, 2017

Fix #5878

Copy link
Contributor

@gongweibao gongweibao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

赞!
这些工具是否加入到我们的develop Docker Image中?


```text
4696 12.040 0.003 12.040 0.003 {built-in method run}
300005 0.874 0.000 1.681 0.000 /home/yuyang/perf_test/.env/lib/python2.7/site-packages/paddle/v2/dataset/mnist.py:38(reader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/yuyang/perf_test/.env

这个路径是不是没有必要暴露出来?另外其实也挺长的。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恩。这个事实际上profile程序的输出。我直接拷贝过来的。确实有点长,不过

  1. 这个路径是挺标准的linux路径,也不太涉密。
  2. 这个路径确实说明了 mnist.py这个文件38行的某个函数的耗时。

先这样吧。

使用`pip install cprofilev`安装`cprofilev`工具,进而使用如下命令开启HTTP服务

```bash
cprofilev -a 0.0.0.0 -p 3214 -f profile.out main.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 这里不指定pi和端口也是可以的,默认会http://127.0.0.1:4000
  2. 也可以这样使用python -m cprofilev main.py,会将结果输出到http://127.0.0.1:4000页面中,不过因为程序还在运行,所以需要手动刷新页面。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本地运行是可以的。。但是,我们经常会在服务器上调试程序,-a 0.0.0.0还是挺必要的。

| cumtime | 函数总时间。包含这个函数调用其他函数的时间 |
| percall | cumtime的每次调用平均时间 |
| filename:lineno(function) | 文件名, 行号,函数名 |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

查看性能分析结果也可以借用gprof2dot工具,该工具可将性能分析文件转成一张图,同时会通过颜色标记图中最耗时的结点了路径。
优点:更直观
缺点:只是一张图,无法查看更具体的调用关系

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool。要不然我这个PR merge了之后,麻烦你写一下gprof2dot的使用和效果。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以的

@reyoung
Copy link
Collaborator Author

reyoung commented Nov 27, 2017

这些工具是否加入到我们的develop Docker Image中?

@gongweibao Develop image加入性能调优的工具是挺有用的。不过,

  1. Docker似乎本身有一些安全性限制,不一定能直接进行调优。这个需要在docker下试验一下再看看。
  2. Docker启动前需要暴露的端口就确定了。而这个PR里会新开一些HTTP服务,用docker调试比较复杂。

这个PR里面的所有实验都是直接在Linux下进行的。没有进docker容器。

@dzhwinter
Copy link
Contributor

@typhoonzero 请教下在docker内部做profiler,得到数据是准确的吗?有没有坑需要注意

Copy link
Contributor

@chengduoZH chengduoZH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luotao1
Copy link
Contributor

luotao1 commented Nov 27, 2017

@dzhwinter 我们在docker内外测过CPU的性能,觉得误差基本可以忽略不计(最大是1.7%的diff)。#5148 (comment) GPU的还未实验过。

@reyoung reyoung merged commit 7c57f90 into PaddlePaddle:develop Nov 27, 2017
@reyoung reyoung mentioned this pull request Nov 27, 2017
20 tasks
@reyoung reyoung deleted the feature/cpu_profiling branch December 26, 2017 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants