日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

高性能Numpy/Scipy加速:使用Intel MKL和Intel Compilers或OpenBLAS(待续)

發布時間:2023/12/13 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 高性能Numpy/Scipy加速:使用Intel MKL和Intel Compilers或OpenBLAS(待续) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Numpy/Scipy加速:使用Intel MKL和Intel Compilers



1.獲取Intel Parallel Studio XE


Intel免費軟件工具提供免費的軟件包,其中包括完整的Intel編譯器和計算庫及其激活碼,軟件和激活碼一一對應。注意需要使用教育郵箱注冊,否則不予通過。


2.安裝過程


解壓后在終端進入./install_GUI.sh,按照提示進行就好,其中激活的步驟需要聯網,且最多只能激活5次。最后整個庫會安裝在\opt\intel路徑下,重要的是配置環境變量。


首先加入Intel編譯器icc的路徑

export INTELCOMP=/opt/intel/bin export PATH=$INTELCOMP:$PATH

接著加入共享庫的路徑,其中庫的名稱一定要有對應的版本號,這里是.2.174

export MKLHOME=/opt/intel/mkl/lib/intel64 export LIB1=/opt/intel/compilers_and_libraries_2017.2.174/linux/mkl/lib/intel64_lin export LIB2=/opt/intel/compilers_and_libraries_2017.2.174/linux/compiler/lib/intel64_lin export LD_LIBRARY_PATH=$MKLHOME:$LIB1:$LIB2:$LD_LIBRARY_PATH

注意:如果使用中還有一些.so庫找不到,則可以定位這些庫然后加入到LD_LIBRARY_PATH中。如果需要有全局的作用,則可以編輯/etc/ld.so.conf文件,增加這些路徑,并用ldconfig刷新。


構建numpy和scipy


下載 NumPy & SciPy libraries

git clone https://github.com/numpy/numpy.git numpy git clone https://github.com/scipy/scipy.git scipy

Build instructions
Building From Source on Linux


主要依據Numpy/Scipy with Intel? MKL and Intel? Compilers官網提示。總結起來就是在numpy的安裝路徑下增加site.cfg文件,內容如下:


cd numpy sudo gedit site.cfg

添加如下代碼

[mkl] library_dirs = /opt/intel/compilers_and_libraries_2017.2.174/linux/mkl/lib/intel64 include_dirs = /opt/intel/compilers_and_libraries_2017.2.174/linux/mkl/include mkl_libs = mkl_rt lapack_libs =

接著更改numpy/distutils/intelccompiler.py文件中的self.cc_exe語句,如果是64位,則在IntelEM64TCCompiler類中將之改為

self.cc_exe = 'icc -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost'

然后就可以編譯安裝numpy了

$ python setup.py config --compiler=intelem build_clib --compiler=intelem build_ext --compiler=intelem install

構建安裝scipy可以直接進行

python setup.py config --compiler=intelem --fcompiler=intelem build_clib --compiler=intelem --fcompiler=intelem build_ext --compiler=intelem --fcompiler=intelem install

Numpy/Scipy加速:使用OpenBLAS



1. Install OpenBLAS


~$ git clone git://github.com/xianyi/OpenBLAS ~$ cd OpenBLAS && make FC=gfortran ~$ sudo make PREFIX=/opt/OpenBLAS install

2. 配置環境變量


sudo gedit ~/.bashrc

添加

export LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH

The LD_LIBRARY_PATH environment variable will be updated when you start a new terminal session

source ~/.bashrc

to force an update within the same session


sudo gedit /etc/profile

添加

export LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH

生效

source /etc/profile

another option that will work for multiple users is to create a .conf file

~$ sudo -s "echo '/opt/OpenBLAS/lib' > /etc/ld.so.conf.d/openblas.conf"

生成鏈接

sudo ldconfig -v

3. 安裝numpy

~$ git clone https://github.com/numpy/numpy ~$ cd numpy

Copy site.cfg.example to site.cfg and edit the copy

~$ cp site.cfg.example site.cfg ~$ nano site.cfg

Check configuration, build, install (optionally in a virutalenv)

~$ python setup.py config

Then just build and install:

~$ python setup.py build && python setup.py install

參考文獻


Numpy/Scipy with Intel? MKL and Intel? Compilers

高性能Numpy/Scipy:使用Intel MKL和Intel Compilers

如何在 Linux* 中安裝英特爾? 數據分析加速庫(英特爾? DAAL)的 Python* 版本

caffe 上OpenBLAS的安裝使用

安裝OpenBlas(ubuntu 14.04)

OpenBLAS,Numpy,Scipy For Linux

安裝線性計算庫、numPy和sciPy的編譯方法(推薦)

Python accelerated (using Intel? MKL)

Intel Distribution for Python 正式版windows

官網Intel? Distribution for Python

Numpy使用MKL庫提升計算性能

總結

以上是生活随笔為你收集整理的高性能Numpy/Scipy加速:使用Intel MKL和Intel Compilers或OpenBLAS(待续)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。