{"id":414,"date":"2016-11-17T15:53:47","date_gmt":"2016-11-17T07:53:47","guid":{"rendered":"https:\/\/yyshell.com\/?p=414"},"modified":"2016-11-17T15:53:47","modified_gmt":"2016-11-17T07:53:47","slug":"%e5%9f%ba%e4%ba%8eintel%e7%bc%96%e8%af%91%e5%99%a8%e5%92%8cmkl%e6%9e%84%e5%bb%banumpy%e5%92%8cscipy%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=414","title":{"rendered":"\u57fa\u4e8eIntel\u7f16\u8bd1\u5668\u548cMKL\u6784\u5efaNumPy\u548cSciPy\u6559\u7a0b"},"content":{"rendered":"<p>NumPy\u548cSciPy\u76ee\u524d\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u5b66\u8ba1\u7b97\u3001\u5206\u6790\u9886\u57df\uff0cIntel\u7684MKL\u662f\u4e00\u4e2a\u6570\u5b66\u5e93\uff0c\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u901f\u548c\u5e76\u884c\u8ba1\u7b97\u529f\u80fd\u3002\u672c\u4f8b\u4e2d\uff0c\u6211\u5c06\u7528CentOS6\uff08\u5df2\u5b89\u88c5python2.7\uff09\u5b89\u88c5Intel Parallel Studio XE 2015 Cluster Edition\u8f6f\u4ef6\uff0c\u4f7f\u7528Intel\u7f16\u8bd1\u5668\u548cMKL\u7f16\u8bd1NumPy\u548cSciPy\u3002<\/p>\n<p><a href=\"https:\/\/yyshell.com\/?p=265\">CentOS6\u4e0b\u5b89\u88c5Python2.7<\/a>\u7684\u6559\u7a0b\u6211\u4eec\u4e4b\u524d\u63d0\u5230\u8fc7\uff0c\u8fd9\u91cc\u5c31\u4e0d\u8d58\u8ff0\u4e86\u3002<\/p>\n<h3>\u5b89\u88c5Intel Parallel Studio XE 2015 Cluster Edition<\/h3>\n<p>\u65b0\u5efa\u6587\u4ef6\u5939\u4f5c\u4e3a\u6302\u8f7d\u70b9\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# mkdir \/mnt\/iso<\/pre>\n<p>\u6b63\u662f\u6302\u8f7diso\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# mount -o loop Intel.Parallel.Studio.XE.2015.Cluster.Edition.Linux.iso \/mnt\/iso<\/pre>\n<p>\u5f00\u59cb\u5b89\u88c5\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# \/mnt\/iso\/install.sh<\/pre>\n<p>\u6574\u4e2a\u5b89\u88c5\u8fc7\u7a0b\u6ce8\u610f\u770b\u63d0\u793a\u8bf4\u660e\uff0c\u5b89\u88c5\u7684\u7ec4\u4ef6\uff0c\u8def\u5f84\u7b49\u4fe1\u606f\uff0c\u9ed8\u8ba4\u8def\u5f84\u662f\/opt\/intel\uff0c\u6211\u4eec\u6b64\u6b21\u91c7\u7528\u7684\u5c31\u662f\u9ed8\u8ba4\u8def\u5f84\u3002<\/p>\n<p>\u7531\u4e8eIntel\u7f16\u8bd1\u5668\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5\u5728\/usr\/bin\u7b49\u6807\u51c6\u7684\u8def\u5f84\u4e0b\uff0c\u6240\u4ee5\u4f60\u65e0\u6cd5\u76f4\u63a5\u4f7f\u7528icc\u7b49\u547d\u4ee4\uff0c\u540c\u6837\uff0c\u8981\u8fd0\u884c\u4e0eintel\u5e93\u94fe\u63a5\u7684\u7a0b\u5e8f\uff0c\u5fc5\u987b\u4fdd\u8bc1\u94fe\u63a5\u5668\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf<span class=\"enlighterEnlighterJS EnlighterJS\"><span class=\"\">LD_LIBRARY_PATH<\/span><\/span>\u6765\u67e5\u627e\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u6765\u4e34\u65f6\u8bbe\u7f6e\u4e0b\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@template ~]# source \/opt\/intel\/bin\/iccvars.sh intel64 -platform linux<\/pre>\n<p>\u6216\u8005\u81ea\u5df1\u624b\u52a8\u6307\u5b9a\u4e5f\u53ef\u4ee5\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">export LD_LIBRARY_PATH=\/opt\/intel\/composer_xe_2015.0.090\/compiler\/lib\/intel64:\/opt\/intel\/composer_xe_2015.0.090\/mpirt\/lib\/intel64:\/opt\/intel\/composer_xe_2015.0.090\/ipp\/lib\/intel64:\/opt\/intel\/composer_xe_2015.0.090\/mkl\/lib\/intel64:\/opt\/intel\/composer_xe_2015.0.090\/tbb\/lib\/intel64\/gcc4.4:$LD_LIBRARY_PATH<\/pre>\n<p>\u6ce8\u610f\uff1a\u6211\u8fd9\u91cc\u624b\u52a8\u8bbe\u7f6e\u53d8\u91cf\u4e2d\u7684\u8def\u5f84\u90fd\u662f\u7edd\u5bf9\u8def\u5f84\u3002<\/p>\n<p>\u6d4b\u8bd5\u4e0bintel\u7f16\u8bd1\u5668\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# icc -v\r\nicc version 15.0.0 (gcc version 4.4.7 compatibility)<\/pre>\n<h3>\u7f16\u8bd1numpy<\/h3>\n<p>\u4e0b\u8f7dnumpy\u6e90\u7801\u5305\uff1anumpy-1.11.2.tar.gz<\/p>\n<p>\u89e3\u538b\u5e76cd\u5230\u6e90\u7801\u76ee\u5f55\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# tar xf numpy-1.11.2.tar.gz\r\n[root@template ~]# cd numpy-1.11.2\/\r\n[root@template numpy-1.11.2]#<\/pre>\n<p>\u590d\u5236\u4e00\u4efdsite.cfg\u6587\u4ef6<\/p>\n<pre class=\"lang:sh decode:true \">[root@template numpy-1.11.2]# cp site.cfg.example site.cfg<\/pre>\n<p>\u7f16\u8f91site.cfg\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u4fe1\u606f\uff1a<\/p>\n<pre class=\"lang:ini decode:true \">[mkl]\r\nlibrary_dirs = \/opt\/intel\/mkl\/lib\/intel64\/\r\ninclude_dirs = \/opt\/intel\/mkl\/include\/\r\nmkl_libs = mkl_rt\r\nlapack_libs =<\/pre>\n<p>\u7f16\u8f91\u6e90\u7801\u5b50\u76ee\u5f55\u7684numpy\/distutils\/intelccompiler.py\u6587\u4ef6\uff1a<\/p>\n<p>\u539f\u5148\u7684\u5185\u5bb9\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">        self.cc_exe = ('icc -fPIC -fp-model strict -O3 '\r\n                       '-fomit-frame-pointer -openmp')<\/pre>\n<p>\u53d8\u6210\u8fd9\u6837\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">        self.cc_exe = ('icc -fPIC -fp-model strict -O3 '\r\n                       '-fomit-frame-pointer -openmp -xHost')<\/pre>\n<p>\u4fee\u6539numpy\u6e90\u7801\u5b57\u6bcd\u7684numpy\/distutils\/fcompiler\/intel.py\u6587\u4ef6\uff0c\u67e5\u627eIntelEM64TFCompiler\u6807\u7b7e\uff0c\u628a\u4e0b\u9762\u7684\u5185\u5bb9\u4fee\u6539\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">    def get_flags_arch(self):\r\n        return ['']<\/pre>\n<p>\u4fee\u6539\u6210\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">    def get_flags_arch(self):\r\n        return ['-xHost']<\/pre>\n<p>\u7f16\u8bd1\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template numpy-1.11.2]# python setup.py \\\r\n&gt; config --compiler=intelem --fcompiler=intelem \\\r\n&gt; build_clib --compiler=intelem --fcompiler=intelem \\\r\n&gt; build_ext --compiler=intelem  --fcompiler=intelem\r\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7f16\u8bd1\u547d\u4ee4\u540e\u9762\u53ef\u4ee5\u76f4\u63a5\u52a0\u4e0ainstall\uff0c\u76f4\u63a5\u7f16\u8bd1\u5b8c\u6210\u540e\u5b89\u88c5\uff0c\u6211\u4eec\u6b64\u5904\u6ca1\u6709\u8fd9\u6837\u3002<\/p>\n<p>\u5b89\u88c5\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template numpy-1.11.2]# python setup.py install<\/pre>\n<p>\u8981\u5b89\u88c5\u5728\u522b\u7684\u76ee\u5f55\uff0c\u53ef\u4ee5\u5728\u540e\u9762\u52a0\u4e0a&#8211;prefix\u6807\u7b7e\uff0c\u4f8b\u5982\u8981\u5b89\u88c5\u5728\u7528\u6237\u81ea\u5df1\u7684home\u76ee\u5f55\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">python setup.py install --prefix=~<\/pre>\n<p>\u8981\u4f7f\u7528\u8fd9\u4e9b\u5b89\u88c5\u5728\u975e\u6807\u51c6\u76ee\u5f55\u7684\u5305\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e0b\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">export PYTHONPATH=~\/lib\/python2.7\/site-packages<\/pre>\n<h3>\u7f16\u8bd1SciPy<\/h3>\n<p>\u5148\u4e0b\u8f7dscipy\u6e90\u7801\u5305scipy-0.18.1.tar.gz\uff0c\u518d\u89e3\u538b\u5e76\u5207\u6362\u5230\u6e90\u7801\u76ee\u5f55\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# tar xf scipy-0.18.1.tar.gz\r\n[root@template ~]# cd scipy-0.18.1\/\r\n[root@template scipy-0.18.1]#<\/pre>\n<p>\u7f16\u8bd1\u5b89\u88c5\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">python setup.py config --compiler=intelem --fcompiler=intelem build_clib --compiler=intelem --fcompiler=intelem build_ext --compiler=intelem --fcompiler=intelem<\/pre>\n<p>\u8fd8\u662f\u548c\u4ee5\u524d\u4e00\u6837\uff0c\u5982\u679c\u60f3\u7f16\u8bd1\u4e4b\u540e\u76f4\u63a5\u5b89\u88c5\uff0c\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u6700\u540e\u52a0\u4e0ainstall\u5373\u53ef\uff0c\u6b64\u5904\u6211\u4eec\u5148\u7f16\u8bd1\u6d4b\u8bd5\u4e0b\u3002<\/p>\n<p>\u6b63\u5f0f\u5b89\u88c5\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@template scipy-0.18.1]# python setup.py install<\/pre>\n<p>\u8fd8\u662f\u548c\u4e0a\u9762\u4e00\u6837\uff0c\u5982\u679c\u8981\u5b89\u88c5\u5728\u7528\u6237\u81ea\u5df1\u7684home\u76ee\u5f55\uff0c\u5219\u4f7f\u7528\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">python setup.py install --prefix=~<\/pre>\n<p>\u53ef\u4ee5\u7528\u6d4b\u8bd5\u811a\u672c\u6d4b\u8bd5\u4e0b\uff1a<\/p>\n<pre class=\"lang:python decode:true \">import numpy as np  \r\nimport time   \r\nN = 6000  \r\nM = 10000  \r\n  \r\nk_list = [64, 80, 96, 104, 112, 120, 128, 144, 160, 176, 192, 200, 208, 224, 240, 256, 384]  \r\n  \r\ndef get_gflops(M, N, K):  \r\n    return M*N*(2.0*K-1.0) \/ 1000**3  \r\n  \r\nnp.show_config()  \r\n  \r\nfor K in k_list:  \r\n    a = np.array(np.random.random((M, N)), dtype=np.double, order='C', copy=False)  \r\n    b = np.array(np.random.random((N, K)), dtype=np.double, order='C', copy=False)  \r\n    A = np.matrix(a, dtype=np.double, copy=False)  \r\n    B = np.matrix(b, dtype=np.double, copy=False)  \r\n  \r\n    C = A*B  \r\n  \r\n    start = time.time()  \r\n  \r\n    C = A*B  \r\n    C = A*B  \r\n    C = A*B  \r\n    C = A*B  \r\n    C = A*B  \r\n  \r\n    end = time.time()  \r\n  \r\n    tm = (end-start) \/ 5.0  \r\n  \r\n    print ('{0:4}, {1:9.7}, {2:9.7}'.format(K, tm, get_gflops(M, N, K) \/ tm))<\/pre>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">  64, 0.08944516,  85.19186\r\n  80, 0.09361682,  101.9048\r\n  96,  0.105599,  108.5237\r\n 104, 0.1081362,  114.8552\r\n 112, 0.1157708,  115.5732\r\n 120, 0.1222016,  117.3471\r\n 128, 0.1230086,  124.3816\r\n 144, 0.1358574,  126.7506\r\n 160, 0.1499454,  127.6465\r\n 176, 0.1642118,   128.249\r\n 192, 0.1824996,  125.9181\r\n 200, 0.1848712,  129.4956\r\n 208, 0.1959402,  127.0796\r\n 224, 0.2016638,  132.9936\r\n 240,  0.265302,  108.3294\r\n 256,  0.281865,  108.7755\r\n 384, 0.3804388,  120.9656<\/pre>\n<p>\u5df2\u7ecf\u5b89\u88c5\u4e86\u57fa\u4e8eIntel\u7f16\u8bd1\u5668\u548cMKL\u6784\u5efaNumPy\u548cSciPy\u540e\uff0c\u5982\u679c\u60f3\u5b89\u88c5\u666e\u901a\u7684numpy\u548cscipy\uff0c\u53ef\u4ee5\u7528pip\u6765\u5b89\u88c5\uff0c\u4f8b\u5982\uff0c\u628anumpy\u5b89\u88c5\u5728home\u76ee\u5f55\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">pip install --install-option=\"--prefix=~\" --ignore-installed numpy<\/pre>\n<p>\u5b89\u88c5\u5b8c\u540e\uff0c\u7528\u6237\u7684home\u76ee\u5f55\u7684lib\u6587\u4ef6\u5939\u4e0b\uff0c\u5c31\u662f\u5b89\u88c5\u7684numpy\u8f6f\u4ef6\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NumPy\u548cSciPy\u76ee\u524d\u5e7f\u6cdb\u5e94\u7528\u4e8e\u6570\u5b66\u8ba1\u7b97\u3001\u5206\u6790\u9886\u57df\uff0cIntel\u7684MKL\u662f\u4e00\u4e2a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6],"tags":[45,63,64,65,61,62],"class_list":["post-414","post","type-post","status-publish","format-standard","hentry","category-linux","category-6","tag-centos6","tag-intel","tag-mkl","tag-parallel-studio","tag-python","tag-scipy"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=414"}],"version-history":[{"count":1,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions"}],"predecessor-version":[{"id":415,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions\/415"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}