Last active
October 5, 2017 20:48
-
-
Save akisatok/7a5fdb9370428e980f0f to your computer and use it in GitHub Desktop.
numpy・scipyでマルチスレッドBLAS・LAPACKを使う ref: http://qiita.com/_akisato/items/d5de60e38b5a69387bde
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.linalg import flapack | |
clapack = flapack | |
_use_force_clapack = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.linalg import flapack | |
from scipy.linalg import clapack | |
_use_force_clapack = 1 | |
if hasattr(clapack,'empty_module'): | |
clapack = flapack | |
_use_force_clapack = 0 | |
elif hasattr(flapack,'empty_module'): | |
flapack = clapack'' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget http://prs.ism.ac.jp/~nakama/SurviveGotoBLAS2/SurviveGotoBLAS2_3.14.tar.gz | |
# tar xzf SurviveGotoBLAS2_3.14.tar.gz | |
# cd survivegotoblas2_3.14 | |
# vim Makefile.rule | |
TARGET=X86_64 | |
BINARY=64 | |
USE_THREAD=1 | |
USE_OPENMP=1 | |
NUM_THREADS=12 # CPUの数に応じて調節する | |
NO_CBLAS=1 # CBLASはあとでビルドする | |
NO_LAPACK=1 # LAPACKもあとでビルドする | |
# make all -j 4 | |
# cp libgoto2.a ~/lib # 永続的に残す場所(ここでは~/lib)へコピー |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mkdir tmp | |
# cd tmp | |
# cp ../libgoto2.a . | |
# ar -x libgoto2.a # .aを.oに分解 | |
# gfortran -shared -lpthread -lgomp -o libgoto2.so *.o | |
# cp libgoto2.so ~/lib # 永続的に残す場所へコピー | |
# export BLAS=~/lib/libgoto2.so # なくても良いかも |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python setup.py build | |
# python setup.py install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python -c "import numpy; numpy.test(verbose=2)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget http://www.netlib.org/blas/blast-forum/cblas.tgz | |
# tar xzf cblas.tgz | |
# cd CBLAS | |
# cp Makefile.LINUX Makefile.in | |
# vim Makefile.in | |
BLLIB = ~/lib/libgoto2.a # ここでBLASを参照 | |
CBLIB = ../lib/libcblas.a # CBLASの出力先 | |
LOADER = $(FC) -lpthread | |
CFLAGS = -O3 -m64 -fPIC -DADD_ | |
FFLAGS = -O3 -m64 -fPIC | |
# make all -j 4 | |
# cp lib/libcblas.a ~/lib # 永続的に残す場所へコピー | |
# gfortran -L${HOME}/lib -lgoto2 -shared -o libcblas.so *.o | |
# cp libcblas.so ~/lib # 永続的に残す場所へコピー |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget http://www.netlib.org/lapack/lapack.tgz | |
# tar xzf lapack.tgz | |
# cd lapack | |
# cp INSTALL/make.inc.gfortran make.inc | |
# vi make.inc | |
OPTS = -O3 -m64 -fPIC | |
NOOPT = -O0 -m64 -fPIC | |
LOADOPTS = -L${HOME}/lib -lgoto2 -lcblas | |
# make lapacklib -j 4 | |
# cp liblapack.a ~/lib # 永続的に残す場所へコピー | |
# mkdir tmp | |
# cd tmp | |
# cp ../liblapack.a . | |
# ar -x liblapack.a # .aを.oに分解 | |
# gfortran -L${HOME}/lib -lgoto2 -lcblas -shared -o liblapack.so *.o | |
# cp liblapack.so ~/lib | |
# export LAPACK=~/lib/liblapack.so # なくても良いかも |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget http://sourceforge.net/projects/numpy/files/NumPy/1.9.0/numpy-1.9.0.tar.gz/download --no-check-certificate | |
# tar xzf numpy-1.9.0.tar.gz | |
# cd numpy-1.9.0 | |
# cp site.cfg.example site.cfg | |
# vim site.cfg | |
[DEFAULT] | |
library_dirs = ${HOME}/lib | |
[atlas] | |
atlas_libs = goto2,cblas | |
# python setup.py build | |
# python setup.py install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python -c "import numpy; numpy.test(verbose=2)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python test_numpy.py | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wget http://sourceforge.net/projects/scipy/files/scipy/0.14.0/scipy-0.14.0.tar.gz/download | |
# tar xzvf scipy-0.14.0.tar.gz | |
# cd scipy-0.14.0 | |
# vim site.cfg | |
[DEFAULT] | |
library_dirs = ${HOME}/lib | |
[atlas] | |
atlas_libs = lapack,goto2,cblas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment