OpenBLAS,Numpy,Scipy For Linux
来源:互联网 发布:淘宝客定向计划取名 编辑:程序博客网 时间:2024/05/19 14:18
Compile
OpenBLAS
:~$ git clone git://github.com/xianyi/OpenBLAS~$ cd OpenBLAS && make FC=gfortran~$ sudo make PREFIX=/opt/OpenBLAS install
If you don't have sudo rights you could set
PREFIX=
to a directory you have write privileges to (just modify the corresponding steps below accordingly).Make sure that the directory containing
libopenblas.so
is in your shared library search path.To do this locally, you could edit your
~/.bashrc
file to contain the lineexport 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 (use$ source ~/.bashrc
to force an update within the same session).you can also set the path in your /etc/profile to contain the bellow line:
export LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH
remember to use the command: source /etc/profile
Another option that will work for multiple users is to create a
.conf
file in/etc/ld.so.conf.d/
containing the line/opt/OpenBLAS/lib
, e.g.:~$ sudo -s "echo '/opt/OpenBLAS/lib' > /etc/ld.so.conf.d/openblas.conf"
Once you are done with either option, run
~$ sudo ldconfig
Install Numpy
Grab the
numpy
source code:~$ git clone https://github.com/numpy/numpy~$ cd numpy
Copy
site.cfg.example
tosite.cfg
and edit the copy:~$ cp site.cfg.example site.cfg~$ nano site.cfg
Uncomment these lines:
....[openblas]libraries = openblaslibrary_dirs = /opt/OpenBLAS/libinclude_dirs = /opt/OpenBLAS/include....
Check configuration, build, install (optionally in a
virutalenv
)~$ python setup.py config
The output should look something like this:
...openblas_info: FOUND: libraries = ['openblas', 'openblas'] library_dirs = ['/opt/OpenBLAS/lib'] language = c define_macros = [('HAVE_CBLAS', None)] FOUND: libraries = ['openblas', 'openblas'] library_dirs = ['/opt/OpenBLAS/lib'] language = c define_macros = [('HAVE_CBLAS', None)]...
Then just build and install:
~$ python setup.py build && python setup.py install
Install Scipy
将numpy使用的更改过的site.cfg文件拷贝到scipy根目录下,执行相同的编译和安装过程即可。
如果使用低版本的numpy,可以参考
OpenBLAS
git clone git://github.com/xianyi/OpenBLAS
Change into the new directory, then
make FC=gfortransudo make PREFIX=/usr/local/ install
The latest lapack release is downloaded, compiled and integreated into OpenBLAS automatically. Ready for the python part!
Numpy
git clone https://github.com/numpy/numpy
Usually one is interested in OpenBLAS because of its fast matrix-matrix multiplication. Whether numpy has a fast dot
function is indicated by the presence of core/_dotblas.so
. However, currently (June 2013) this file is only build, if site.cfg
has an [atlas]
section(also see here and here). There is an interesting thread here with a link to this fix in order to add support for using OpenBLAS for the _dotblas
function. However, right now dovi site.cfg
and:
[default]library_dirs = /usr/local/lib[atlas]atlas_libs = openblaslibrary_dirs = /usr/local/lib[lapack]lapack_libs = openblaslibrary_dirs = /usr/local/lib
Without the [lapack]
section there were problems with installing scipy
later on. Additionally:
export BLAS=/usr/local/lib/libopenblas.aexport LAPACK=/usr/local/lib/libopenblas.aexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
Check the detected configuration with python setup.py config
. You should see severalATLAS_INFO
paired with None
. If there is something like 3.8.2
instead of None
then you have an ATLAS install somewhere on your system and numpy won't use OpenBLAS. Get rid of this install (e.g. via apt-get purge
) and rerun the config
command. If ATLAS_INFO
is completely missing then numpy couldn't find your libopenblas*
libraries — you need to check all previous steps again. Now:
python setup.py build
If you look into build/numpy/core
, the file _dotblas.so
should be available.
sudo python setup.py install
installs a system wide numpy that uses OpenBLAS for dot products. This test produces
FAST BLASversion: 1.8.0.dev-3f10c36maxint: 9223372036854775807dot: 0.162246799469
You can change the number of cores OpenBLAS utilizes via OPENBLAS_NUM_THREADS
, e.g.export OPENBLAS_NUM_THREADS=2
results in
:::bashFAST BLASversion: 1.8.0.dev-3f10c36maxint: 9223372036854775807dot: 0.0949754238129 sec
Scipy
git clone https://github.com/scipy/scipy
Scipy can be installed without any workaround:
python setup.py buildsudo python setup.py install
Make sure that in your sudo
command the variables BLAS
, LAPACK
and LD_LIBRARY_PATH
are correctly set, as shown above! This test script (it has some room for improvement, though ...) works on my machine after the system wide install:
cholesky: 0.080588388443 secsvd: 1.13443040848 sec
Finally, if you feel good enough (and do a pip install nose
), you can run nose tests via
python -c "import numpy; numpy.test(verbose=2)"python -c "import scipy; scipy.test(verbose=2)"
祝你成功。。。
- OpenBLAS,Numpy,Scipy For Linux
- OpenBLAS,Numpy,Scipy For Linux(编译最新完成)
- openblas+lapack numpy scipy
- linux 下 numpy scipy 安装
- 高性能Numpy/Scipy加速:使用Intel MKL和Intel Compilers或OpenBLAS(待续)
- Scipy + Numpy
- Linux下安装scikit-learn numpy scipy
- Linux 下安装 numpy 和 scipy
- linux下安装numpy,scipy,matplotlib
- Linux 下安装 numpy 和 scipy
- linux下python3安装numpy与scipy
- Windows & Linux 安装 numpy/scipy/matplotlib
- Ubuntu-OpenBlas for Caffe
- linux python 安装 nose lapack atlas numpy scipy
- linux下安装Numpy,scipy,matplotlib的安装
- linux下python安装 nose lapack atlas numpy scipy sklearn
- 在linux上安装NumPy,Matplotlib,SciPy和IPython
- Linux环境下numpy,scipy,matplotlib的安装
- 面试中经常出现的算法1(整理)
- SQLite多线程使用总结
- grails+oracle 一次实际操作记录
- UIScreen获取两种类型画面尺寸
- Java实现文件拷贝的4种方法
- OpenBLAS,Numpy,Scipy For Linux
- linux 进程间通信之 消息队列
- Visual studio 2015 community + Windows Driver Kit 10 +Vmware 11 配置驱动开发环境
- cookie对象及其应用:
- 基于TarBarController控制器的跳转方法
- AE开发资料整理,源自网络!
- hdu4055 dp
- POJ 2299 Ultra-QuickSort
- eclipse快捷键