正如标题所示,numpy.dot(我认为numpy是通用的)在更新我的系统后表现得慢得多.我正在运行比较的示例代码是:
from numpy import *
import time
A=random.random((1000,1000))
B=random.random((1000,1000))
st=time.time();dot(A,B);end=time.time();print end-st
Run Code Online (Sandbox Code Playgroud)
下面的代码在我的另一台计算机上需要~0.09s(有问题的计算机运行速度与另一台计算机一样快),但代码在计算机上需要大约0.26的问题.
以下是我尝试解决此问题的方法.我的第一个猜测是,1:ATLAS与numpy没有联系.所以,我使用synaptic,libatlas3-bas,libatlas-doc,libatlas-dev,libatlas3gf-bas,libatlas-bas-dev安装了atlas包.
安装完成后,我通过输入检查numpy是否与地图集相关联
import numpy.distutils.system_info as sysinfo
sysinfo.get_into('atlas')
Run Code Online (Sandbox Code Playgroud)
返回消息如下:
ATLAS version 3.10.1 built by buildd on Sat Jul 27 19:04:50 UTC 2013:
UNAME : Linux roseapple 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
INSTFLG : -1 0 -a 1 -l 1
ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_x86SSE2 -DATL_CPUMHZ=1596 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664
F2CDEFS : -DAdd_ -DF77_INTEGER=int -DStringSunStyle
CACHEEDGE: 1048576
F77 : /usr/bin/x86_64-linux-gnu-gfortran-4.8, version GNU Fortran …Run Code Online (Sandbox Code Playgroud) 这是我第一次尝试使用ATLAS.我无法正确链接.这是一个非常简单的sgemm程序:
...
#include <cblas.h>
const int M=10;
const int N=8;
const int K=5;
int main()
{
float *A = new float[M*K];
float *B = new float[K*N];
float *C = new float[M*N];
// Initialize A and B
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, 1.0, A, K, B, N, 0.0, C, N);
...
}
Run Code Online (Sandbox Code Playgroud)
当我在标准ATLAS安装的linux平台上编译它时,它会给出链接错误:
g++ test.c -lblas -lcblas -latlas -llapack
/tmp/cc1Gu7sr.o: In function `main':
test.c:(.text+0x29e): undefined reference to `cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, …Run Code Online (Sandbox Code Playgroud) 与链接到OpenBLAS的numpy相比,我试图改变与ATLAS相关联的numpy的性能.我得到了一些我在下面描述的ATLAS的奇怪结果.
用于评估矩阵 - 矩阵乘法(又名sgemm)的Python代码如下所示:
import sys
sys.path.insert(0, "numpy-1.8.1")
import numpy
import timeit
for i in range(100, 501, 100):
setup = "import numpy; m1 = numpy.random.rand(%d, %d).astype(numpy.float32)" % (i, i)
timer = timeit.Timer("numpy.dot(m1, m1)", setup)
times = timer.repeat(100, 1)
print "%3d" % i,
print "%7.4f" % numpy.mean(times),
print "%7.4f" % numpy.min(times),
print "%7.4f" % numpy.max(times)
Run Code Online (Sandbox Code Playgroud)
如果我运行这个脚本与numpy链接到ATLAS我测量的时间会有很大的变化.您可以在frist列中看到矩阵大小,然后通过运行矩阵矩阵乘法100倍获得的执行时间的均值,最小值和最大值:
100 0.0003 0.0003 0.0004
200 0.0023 0.0010 0.0073
300 0.0052 0.0026 0.0178
400 0.0148 0.0066 0.0283
500 0.0295 0.0169 0.0531
Run Code Online (Sandbox Code Playgroud)
如果我使用一个线程将numpy链接到OpenBLAS重复此过程,则运行时间会更稳定:
100 0.0002 …Run Code Online (Sandbox Code Playgroud) 在花了大量时间从源代码构建ATLAS之后,我在OpenSUSE 13.1存储库中发现了libopenblas和libatals.我的问题是
是否易于安装(无需在您自己的计算机上进行调整)存储库中的"libatlas"真的能提高计算性能吗?
OpenBLAS比ATLAS更好还是只比Linux中的易安装"libatlas"更好?请参阅更快的R使用OpenBLAS:比ATLAS更好,切换到Ubuntu很简单.
我跟着这篇文章使用OpenBLAS编译Numpy,但找不到"numpy.core._dotblas"模块.更多的我无法同时使用ATLAS和OpenBLAS构建Numpy.
有人可以发布.py文件或bash代码来进行ATLAS和OpenBLAS之间的比较吗?例如.
我使用自己的ATLAS构建了Numpy-1.9,从源代码编译了OpenBLAS,并在OpenSUSE 13.1的存储库中安装了"libopenblaso"(OpenMP版本)和"libopenblasp"(pthreads版本).如何配置链接和库,以便在不重建Numpy-1.9软件包的情况下告诉Numpy-1.9使用OpenBLAS而不是ATLAS.
注意:如果在存储库中安装"libatlas",则ATLAS不会针对您的计算机进行调整,并且计算性能不会太高.因此,我首先构建并调整了ATLAS,然后使用我自己的ATLAS构建了Numpy.之后,我尝试将OpenBLAS链接到Numpy,但失败了.
提前谢谢了!
谢谢@Dmitry的快速回复!但问题没有解决......
$ sudo zypper in libopenblasp0
The following NEW package is going to be installed:
libopenblasp0
1 new package to install.
Overall download size: 3.0 MiB. After the operation, additional 30.3 MiB will be used.
Continue? [y/n/? shows all options] (y):
Retrieving package libopenblasp0-0.2.11-11.1.x86_64 (1/1), 3.0 MiB ( 30.3 MiB unpacked)
Retrieving: libopenblasp0-0.2.11-11.1.x86_64.rpm ...........................[done (2.1 MiB/s)]
(1/1) …Run Code Online (Sandbox Code Playgroud) 我在Windows 7 64位上编译ATLAS时遇到一些困难,我们将不胜感激!我正在尝试将它链接到lapack-3.4.1.
我在Cygwin中使用的命令是:
../ATLAS/configure -D c -DWALL --with-netlib-lapack-tarfile=../lapack-3.4.1.tgz -b 64 -Si archdef 0 -Ss ADdir ../ATLAS/WINAD
Run Code Online (Sandbox Code Playgroud)
我得到的输出是:
make: `xconfig' is up to date.
./xconfig -d s /f/Coursework/Code/python/compile/built/../ATLAS/ -d b /f/Coursework/Code/python/compile/built -D c -DWALL -Si lapackref 1 -b 64 -Si archdef 0 -Ss ADdir ../ATLAS/WINAD
gcc.exe: error: /f/Coursework/Code/python/compile/built/../ATLAS//CONFIG/src/probe_asm.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
make: *** [probe_asm.o] Error 1
gcc.exe: error: /f/Coursework/Code/python/compile/built/../ATLAS//CONFIG/src/probe_vec.c: No such file or directory
gcc.exe: fatal error: no input files …Run Code Online (Sandbox Code Playgroud) 我成功安装了Numpy.但是在网站上,我必须做很多事情,例如构建Numpy,Scipy,下载ATLAS,LAPACK等.我真的很困惑,甚至我也检查了一些其他查询.仍然无法理解.
任何人都可以解释一下我到底应该怎么做?我在我的电脑上安装了cygwin.
非常感谢(提前).
我已经阅读了整个ATLAS安装指南,它表示构建共享(.so)库所需的只是将--shared标志传递给configure脚本.然而,当我建,唯一.so出现在我的文件lib夹是libsatlas.so和libtatlas.so,虽然指南说,应该有六人:
libatlas.so, libcblas.so, libf77blas.so, liblapack.so, libptcblas.so, libptf77blas.so
Run Code Online (Sandbox Code Playgroud)
安装后,某些测试失败,因为缺少这些库.此外,FFPACK在安装期间需要这些库.
有没有遇到过这个?我做错了什么?
TLDR:我可以在NumPy和SciPy中使用静态ATLAS/LAPACK库吗?
背景:
使用LAPACK构建ATLAS之后:
wget http://sourceforge.net/projects/math-atlas/files/Stable/3.10.1/atlas3.10.1.tar.bz2/download
wget http://www.netlib.org/lapack/lapack-3.4.2.tgz
tar -jxvf atlas3.10.1.tar.bz2
mkdir BUILD
cd BUILD
../ATLAS/configure -b 64 -Fa alg -fPIC \
--with-netlib-lapack-tarfile=../lapack-3.4.2.tgz \
--prefix=<ATLAS_INSTALL_PATH>
make
cd lib
make shared
make ptshared
cd ..
make install
Run Code Online (Sandbox Code Playgroud)
我得到以下文件BUILD/lib:
Make.inc@
Makefile
Run Code Online (Sandbox Code Playgroud)
.a 文件:
libatlas.a
libcblas.a
libf77blas.a
libptf77blas.a
libtstatlas.a
liblapack.a
libf77refblas.a
libptlapack.a
libptcblas.a
Run Code Online (Sandbox Code Playgroud)
.so 文件:
libsatlas.so*
libtatlas.so*
Run Code Online (Sandbox Code Playgroud)
我的第一个问题是,为什么我没有.so(共享动态库)文件lapack和cblas?
我的第二个问题是,NumPy使用以下哪两个文件?
libsatlas.so*
libtatlas.so*
Run Code Online (Sandbox Code Playgroud)
最后,如果我定义:
BLAS=/path_to_BUILD/lib/libcblas.a
LAPACK=/path_to_BUILD/lib/liblapack.a
ATLAS=/path_to_BUILD/lib/libatlas.a
Run Code Online (Sandbox Code Playgroud)
并在NumPy中添加/path_to_BUILD/lib到文件中LD_LIBRARY_PATH的library_dirs变量site.cfg.NumPy和SciPy会使用我的库吗?(即使它们是静态的?).
我在CentOS 6.5上从源代码构建numpy,没有root访问权限(python -V = 2.7.6).我有来自git的最新numpy源代码.我不能因为我的生活而得到numpy承认atlas libs.我有:
ls -1 /usr/lib64/atlas
libatlas.so.3
libatlas.so.3.0
libcblas.so.3
libcblas.so.3.0
libclapack.so.3
libclapack.so.3.0
libf77blas.so.3
libf77blas.so.3.0
liblapack.so.3
liblapack.so.3.0
libptcblas.so.3
libptcblas.so.3.0
libptf77blas.so.3
libptf77blas.so.3.0
Run Code Online (Sandbox Code Playgroud)
我不知道这些lib是如何产生的,但我只能假设atlas版本比我可以制作的任何标准BLAS/LAPACK版本更快.
将numpy指向这些库的正确方法是什么?我是否export ATLAS, BLAS, LAPACK=...将每个设置为相应的路径?或者我编辑site.cfg文件以包含以下内容:
[default]
library_dirs = /usr/lib64/atlas
[atlas]
library_dirs = /usr/lib64/atlas
atlas_libs = lapack, cblas, f77blas, atlas
Run Code Online (Sandbox Code Playgroud)
我已经尝试了上面的每一个变体,每次运行python setup.py config它都告诉我在我指定的路径中找不到每个库以及一堆其他默认搜索路径.我已经python setup.py config使用site.cfg上面的设置粘贴了运行结果,并且没有设置环境变量:http://pastebin.com/EL9CfaR7.任何帮助表示赞赏.
我使用以下过程将本地数据库迁移到地图集
mongoexport --db bla
--collection usersettings --jsonArray --out ~/Desktop/users.json命令逐个导出db集合mongoimport --host
cluster0-shard-00-00-c7jiq.mongodb.net:27017 --db Eltar --type json
--file ~/Desktop/userotp.json --authenticationDatabase admin --ssl --username name --password pass命令在atlas上导入这些集合现在,当我连接到本地mongo shell并运行查询时,db.users.find()它显示所有记录,但是当我db.users.find()在连接atlas shell后运行相同的查询时,它只显示一条记录.
记录显示在地图集上,但无法使用查询获取它们
不知道我在这里做错了什么,任何帮助将不胜感激谢谢.
atlas ×10
numpy ×6
blas ×5
python ×4
lapack ×3
scipy ×2
benchmarking ×1
c ×1
c++ ×1
compilation ×1
dbmigrate ×1
installation ×1
mingw ×1
mongo-shell ×1
mongodb ×1
openblas ×1
opensuse ×1
ubuntu ×1