{"action":"created","comment":{"url":"https://api.github.com/repos/mxnet-zh/blog/pulls/comments/178612273","pull_request_review_id":108695983,"id":178612273,"diff_hunk":"@@ -0,0 +1,62 @@\n+---\n+title: 用 Intel MKL-DNN 加速 CPU 上的深度学习\n+author: 郑达 Amazon AI Applied Scientist\n+---\n+\n+Intel最近发布了开源的深度学习软件包 [MKL-DNN](https://github.com/intel/mkl-dnn)，来替换之前的 MKLML。MKL-DNN 专门优化了一系列深度学习里的操作符。现在 Apache MXNet 集成了 MKL-DNN 来加速 CPU 上的深度学习。这次 MXNet 团队和 Intel 团队通过更紧密的合作，不仅提高 MXNet 在 CPU 上的性能，同时也希望让系统比之前使用 MKLML 更加稳定。鉴于现在 inference 主要还是依赖 CPU，希望这次的优化能给需要 inference 的朋友带来更多的帮助。\n+\n+MKL-DNN 优化的操作符多用于 CNN 模型，其中包括 Convolution, Inner Product, Pooling, Batch Normalization, Activation。Intel 团队在不久之后会加入 RNN cell 和 LSTM cell 来提升 RNN 模型在 CPU 上的性能。为了得到更好的性能，MKL-DNN 使用了定制的数据格式，这也使得与 MXNet 的集成变得复杂，因为 MXNet 里自带的操作符不能够理解 MKL-DNN 的定制的数据格式。为了不修改 MXNet 里其他的操作符，MXNet 的执行引擎需要能够自动的转变数组里的格式，同时为了得到最好的性能，MXNet 需要在各种操作符混用的情况下尽量减少格式的转换。\n+\n+\n+现在我将手把手展示如何在 MXNet 里使用 MKL-DNN 来提升性能。如果用户是自己手动编译 MXNet，用户首先需要用[安装教程](http://mxnet.incubator.apache.org/install/index.html)里的命令来安装 MXNet 需要的软件包。另外用户要另外安装 cmake，因为 MKL-DNN 使用 cmake 编译。另外编译 MXNet 的时候需要加上 USE_MKLDNN=1。\n+```shell\n+sudo apt-get install -y cmake\n+make USE_BLAS=openblas USE_MKLDNN=1\n+```\n+\n+当然用户也可以直接安装事先编译好的带 MKL-DNN 的 MXNet。\n+```shell\n+pip install —-pre mxnet-mkl\n+```","path":"_posts/2018-03-30-mkldnn.md","position":20,"original_position":20,"commit_id":"a64d9a1902a3c4402d438d57de002b8921abed6c","original_commit_id":"a64d9a1902a3c4402d438d57de002b8921abed6c","user":{"login":"mli","id":421857,"avatar_url":"https://avatars1.githubusercontent.com/u/421857?v=4","gravatar_id":"","url":"https://api.github.com/users/mli","html_url":"https://github.com/mli","followers_url":"https://api.github.com/users/mli/followers","following_url":"https://api.github.com/users/mli/following{/other_user}","gists_url":"https://api.github.com/users/mli/gists{/gist_id}","starred_url":"https://api.github.com/users/mli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mli/subscriptions","organizations_url":"https://api.github.com/users/mli/orgs","repos_url":"https://api.github.com/users/mli/repos","events_url":"https://api.github.com/users/mli/events{/privacy}","received_events_url":"https://api.github.com/users/mli/received_events","type":"User","site_admin":false},"body":"把这个放前面。告诉这是推荐的使用。把手动安装放在放在文末。","created_at":"2018-04-02T18:27:06Z","updated_at":"2018-04-02T18:30:22Z","html_url":"https://github.com/mxnet-zh/blog/pull/3#discussion_r178612273","pull_request_url":"https://api.github.com/repos/mxnet-zh/blog/pulls/3","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mxnet-zh/blog/pulls/comments/178612273"},"html":{"href":"https://github.com/mxnet-zh/blog/pull/3#discussion_r178612273"},"pull_request":{"href":"https://api.github.com/repos/mxnet-zh/blog/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/mxnet-zh/blog/pulls/3","id":178717676,"html_url":"https://github.com/mxnet-zh/blog/pull/3","diff_url":"https://github.com/mxnet-zh/blog/pull/3.diff","patch_url":"https://github.com/mxnet-zh/blog/pull/3.patch","issue_url":"https://api.github.com/repos/mxnet-zh/blog/issues/3","number":3,"state":"open","locked":false,"title":"Add a blog for MKLDNN.","user":{"login":"zheng-da","id":70481,"avatar_url":"https://avatars1.githubusercontent.com/u/70481?v=4","gravatar_id":"","url":"https://api.github.com/users/zheng-da","html_url":"https://github.com/zheng-da","followers_url":"https://api.github.com/users/zheng-da/followers","following_url":"https://api.github.com/users/zheng-da/following{/other_user}","gists_url":"https://api.github.com/users/zheng-da/gists{/gist_id}","starred_url":"https://api.github.com/users/zheng-da/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zheng-da/subscriptions","organizations_url":"https://api.github.com/users/zheng-da/orgs","repos_url":"https://api.github.com/users/zheng-da/repos","events_url":"https://api.github.com/users/zheng-da/events{/privacy}","received_events_url":"https://api.github.com/users/zheng-da/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-01T07:31:36Z","updated_at":"2018-04-02T18:30:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"23360a91436bc20136ea04bb9cc3a33093e02251","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mxnet-zh/blog/pulls/3/commits","review_comments_url":"https://api.github.com/repos/mxnet-zh/blog/pulls/3/comments","review_comment_url":"https://api.github.com/repos/mxnet-zh/blog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mxnet-zh/blog/issues/3/comments","statuses_url":"https://api.github.com/repos/mxnet-zh/blog/statuses/a64d9a1902a3c4402d438d57de002b8921abed6c","head":{"label":"zheng-da:mkldnn","ref":"mkldnn","sha":"a64d9a1902a3c4402d438d57de002b8921abed6c","user":{"login":"zheng-da","id":70481,"avatar_url":"https://avatars1.githubusercontent.com/u/70481?v=4","gravatar_id":"","url":"https://api.github.com/users/zheng-da","html_url":"https://github.com/zheng-da","followers_url":"https://api.github.com/users/zheng-da/followers","following_url":"https://api.github.com/users/zheng-da/following{/other_user}","gists_url":"https://api.github.com/users/zheng-da/gists{/gist_id}","starred_url":"https://api.github.com/users/zheng-da/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zheng-da/subscriptions","organizations_url":"https://api.github.com/users/zheng-da/orgs","repos_url":"https://api.github.com/users/zheng-da/repos","events_url":"https://api.github.com/users/zheng-da/events{/privacy}","received_events_url":"https://api.github.com/users/zheng-da/received_events","type":"User","site_admin":false},"repo":{"id":127510091,"name":"mxnet-zh-blog","full_name":"zheng-da/mxnet-zh-blog","owner":{"login":"zheng-da","id":70481,"avatar_url":"https://avatars1.githubusercontent.com/u/70481?v=4","gravatar_id":"","url":"https://api.github.com/users/zheng-da","html_url":"https://github.com/zheng-da","followers_url":"https://api.github.com/users/zheng-da/followers","following_url":"https://api.github.com/users/zheng-da/following{/other_user}","gists_url":"https://api.github.com/users/zheng-da/gists{/gist_id}","starred_url":"https://api.github.com/users/zheng-da/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zheng-da/subscriptions","organizations_url":"https://api.github.com/users/zheng-da/orgs","repos_url":"https://api.github.com/users/zheng-da/repos","events_url":"https://api.github.com/users/zheng-da/events{/privacy}","received_events_url":"https://api.github.com/users/zheng-da/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zheng-da/mxnet-zh-blog","description":"MXNet Blog in Chinese","fork":true,"url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog","forks_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/forks","keys_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/teams","hooks_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/hooks","issue_events_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/issues/events{/number}","events_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/events","assignees_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/assignees{/user}","branches_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/branches{/branch}","tags_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/tags","blobs_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/statuses/{sha}","languages_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/languages","stargazers_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/stargazers","contributors_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/contributors","subscribers_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/subscribers","subscription_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/subscription","commits_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/issues/comments{/number}","contents_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/contents/{+path}","compare_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/merges","archive_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/downloads","issues_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/issues{/number}","pulls_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/pulls{/number}","milestones_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/milestones{/number}","notifications_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/labels{/name}","releases_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/releases{/id}","deployments_url":"https://api.github.com/repos/zheng-da/mxnet-zh-blog/deployments","created_at":"2018-03-31T07:35:34Z","updated_at":"2018-04-01T04:29:46Z","pushed_at":"2018-03-31T07:36:58Z","git_url":"git://github.com/zheng-da/mxnet-zh-blog.git","ssh_url":"git@github.com:zheng-da/mxnet-zh-blog.git","clone_url":"https://github.com/zheng-da/mxnet-zh-blog.git","svn_url":"https://github.com/zheng-da/mxnet-zh-blog","homepage":"https://zh.mxnet.io/blog","size":63,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mxnet-zh:master","ref":"master","sha":"6aae230c3b684a6be85866818b8ff64a0f18fd64","user":{"login":"mxnet-zh","id":37725891,"avatar_url":"https://avatars3.githubusercontent.com/u/37725891?v=4","gravatar_id":"","url":"https://api.github.com/users/mxnet-zh","html_url":"https://github.com/mxnet-zh","followers_url":"https://api.github.com/users/mxnet-zh/followers","following_url":"https://api.github.com/users/mxnet-zh/following{/other_user}","gists_url":"https://api.github.com/users/mxnet-zh/gists{/gist_id}","starred_url":"https://api.github.com/users/mxnet-zh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxnet-zh/subscriptions","organizations_url":"https://api.github.com/users/mxnet-zh/orgs","repos_url":"https://api.github.com/users/mxnet-zh/repos","events_url":"https://api.github.com/users/mxnet-zh/events{/privacy}","received_events_url":"https://api.github.com/users/mxnet-zh/received_events","type":"Organization","site_admin":false},"repo":{"id":126533708,"name":"blog","full_name":"mxnet-zh/blog","owner":{"login":"mxnet-zh","id":37725891,"avatar_url":"https://avatars3.githubusercontent.com/u/37725891?v=4","gravatar_id":"","url":"https://api.github.com/users/mxnet-zh","html_url":"https://github.com/mxnet-zh","followers_url":"https://api.github.com/users/mxnet-zh/followers","following_url":"https://api.github.com/users/mxnet-zh/following{/other_user}","gists_url":"https://api.github.com/users/mxnet-zh/gists{/gist_id}","starred_url":"https://api.github.com/users/mxnet-zh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxnet-zh/subscriptions","organizations_url":"https://api.github.com/users/mxnet-zh/orgs","repos_url":"https://api.github.com/users/mxnet-zh/repos","events_url":"https://api.github.com/users/mxnet-zh/events{/privacy}","received_events_url":"https://api.github.com/users/mxnet-zh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mxnet-zh/blog","description":"MXNet Blog in Chinese","fork":false,"url":"https://api.github.com/repos/mxnet-zh/blog","forks_url":"https://api.github.com/repos/mxnet-zh/blog/forks","keys_url":"https://api.github.com/repos/mxnet-zh/blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mxnet-zh/blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mxnet-zh/blog/teams","hooks_url":"https://api.github.com/repos/mxnet-zh/blog/hooks","issue_events_url":"https://api.github.com/repos/mxnet-zh/blog/issues/events{/number}","events_url":"https://api.github.com/repos/mxnet-zh/blog/events","assignees_url":"https://api.github.com/repos/mxnet-zh/blog/assignees{/user}","branches_url":"https://api.github.com/repos/mxnet-zh/blog/branches{/branch}","tags_url":"https://api.github.com/repos/mxnet-zh/blog/tags","blobs_url":"https://api.github.com/repos/mxnet-zh/blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mxnet-zh/blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mxnet-zh/blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/mxnet-zh/blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mxnet-zh/blog/statuses/{sha}","languages_url":"https://api.github.com/repos/mxnet-zh/blog/languages","stargazers_url":"https://api.github.com/repos/mxnet-zh/blog/stargazers","contributors_url":"https://api.github.com/repos/mxnet-zh/blog/contributors","subscribers_url":"https://api.github.com/repos/mxnet-zh/blog/subscribers","subscription_url":"https://api.github.com/repos/mxnet-zh/blog/subscription","commits_url":"https://api.github.com/repos/mxnet-zh/blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/mxnet-zh/blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/mxnet-zh/blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/mxnet-zh/blog/issues/comments{/number}","contents_url":"https://api.github.com/repos/mxnet-zh/blog/contents/{+path}","compare_url":"https://api.github.com/repos/mxnet-zh/blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mxnet-zh/blog/merges","archive_url":"https://api.github.com/repos/mxnet-zh/blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mxnet-zh/blog/downloads","issues_url":"https://api.github.com/repos/mxnet-zh/blog/issues{/number}","pulls_url":"https://api.github.com/repos/mxnet-zh/blog/pulls{/number}","milestones_url":"https://api.github.com/repos/mxnet-zh/blog/milestones{/number}","notifications_url":"https://api.github.com/repos/mxnet-zh/blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mxnet-zh/blog/labels{/name}","releases_url":"https://api.github.com/repos/mxnet-zh/blog/releases{/id}","deployments_url":"https://api.github.com/repos/mxnet-zh/blog/deployments","created_at":"2018-03-23T20:04:56Z","updated_at":"2018-04-01T14:11:39Z","pushed_at":"2018-04-02T18:28:25Z","git_url":"git://github.com/mxnet-zh/blog.git","ssh_url":"git@github.com:mxnet-zh/blog.git","clone_url":"https://github.com/mxnet-zh/blog.git","svn_url":"https://github.com/mxnet-zh/blog","homepage":"https://zh.mxnet.io/blog","size":63,"stargazers_count":20,"watchers_count":20,"language":"CSS","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":4,"open_issues":3,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mxnet-zh/blog/pulls/3"},"html":{"href":"https://github.com/mxnet-zh/blog/pull/3"},"issue":{"href":"https://api.github.com/repos/mxnet-zh/blog/issues/3"},"comments":{"href":"https://api.github.com/repos/mxnet-zh/blog/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/mxnet-zh/blog/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/mxnet-zh/blog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mxnet-zh/blog/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/mxnet-zh/blog/statuses/a64d9a1902a3c4402d438d57de002b8921abed6c"}},"author_association":"NONE"}}
{"actor":{"display_login":"mli"}}