手动安装

sudo rm -rf /usr/local/lib/python2.7/site-packages/numpy/
sudo rm -rf /usr/local/lib/python2.7/site-packages/numpy-*.egg*
sudo rm -rf /usr/local/bin/f2py pip安装
 sudo rm -rf /usr/local/lib/python2.7/dist-packages/numpy/
sudo rm -rf /usr/local/lib/python2.7/dist-packages/numpy-*.egg*
sudo rm -rf /usr/local/bin/f2py

export BLAS=~/.local/lib/libopenblas.a
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.local/lib/
30down voteaccepted

I just compiled numpy inside a virtualenv with OpenBLAS integration, and it seems to be working ok. This was my process:

  1. Compile OpenBlas:

    git clone git://github.com/xianyi/OpenBLAS
    cd OpenBLAS && make FC=gfortran
    sudo make PREFIX=/opt/OpenBLAS install
    sudo ldconfig
  2. Grab the numpy source code:

    git clone https://github.com/numpy/numpy
    cd numpy
  3. Copy site.cfg.example to site.cfg and edit the copy:

    cp site.cfg.example site.cfg
    nano site.cfg

    Uncomment these lines:

    ....
    [openblas]
    libraries = openblas
    library_dirs = /opt/OpenBLAS/lib
    include_dirs = /opt/OpenBLAS/include
    ....
  4. 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 = f77 FOUND:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/opt/OpenBLAS/lib']
    language = f77
    ...

    Then just build and install:

    python setup.py build && python setup.py install
  5. Optional: you can use this script to test performance for different thread counts.

    OMP_NUM_THREADS=1 python build/test_numpy.py
    
    FAST BLAS
    version: 1.8.0.dev-27690e3
    maxint: 9223372036854775807 dot: 0.100896406174 sec OMP_NUM_THREADS=8 python test_numpy.py FAST BLAS
    version: 1.8.0.dev-27690e3
    maxint: 9223372036854775807 dot: 0.0660264015198 sec

There seems to be a noticeable improvement in performance for higher thread counts. However, I haven't tested this very systematically, and it's likely that for smaller matrices the additional overhead would outweigh the performance benefit from a higher thread count.

answered Jan 18 '13 at 2:50
ali_m
7,0352055
 
1  
I apply what you did bu tending with foollowing error at your test script /linalg/lapack_lite.so: undefined symbol: zgelsd_ –  Erogol Jan 30 at 17:47 
1  
@Erogol Could you check that lapack_lite.so is correctly linked against the libopenblas.so you just built? You can call ldd /<path-to-site-packages>/numpy/linalg/lapack_lite.so - if you installed OpenBLAS with PREFIX=/usr/local you should see something like libopenblas.so.0 => /usr/local/lib/libopenblas.so.0 in the output. –  ali_m Jan 30 at 18:01 
1  
I have following line even I do strictly what you typed above answer. libopenblas.so.0 => /usr/lib/libopenblas.so.0 (0x00007f77e08fc000) –  Erogol Jan 30 at 18:06 
    
It sounds like numpy has not been built correctly. I would suggest you uninstall the broken copy of numpy, do a python setup.py clean and python setup.py build and look for any error messages during the compilation. –  ali_m Jan 30 at 18:14 
    
Also, you should probably call sudo ldconfig after installing OpenBLAS if you haven't already (I've added this line to my answer) –  ali_m Jan 30 at 18:21

OMP_NUM_THREADS=7 python test.py

#!/usr/bin/env python
import numpy
import sys
import timeit

try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'

print "version:", numpy.__version__
print "maxint:", sys.maxint
print

x = numpy.random.random((1000,1000))

setup = "import numpy; x = numpy.random.random((1000,1000))"
count = 5

t = timeit.Timer("numpy.dot(x, x.T)", setup=setup)
print "dot:", t.timeit(count)/count, "sec"

numpy delete的更多相关文章

  1. numpy delete方法

    import numpy as np lines = np.loadtxt(r'./test.txt',delimiter=',',dtype=int) print(lines) lines_copy ...

  2. python numpy sum函数用法

    numpy.sum numpy.sum(a, axis=None, dtype=None, out=None, keepdims=False)[source] Sum of array element ...

  3. NumPy 学习笔记(三)

    NumPy 数组操作: 1.修改数组形状 a.numpy.reshape(arr, newshape, order='C') 在不改变数据的条件下修改形状 b.numpy.ndarray.flat 是 ...

  4. Numpy学习笔记(二)

    (1)NumPy - 切片和索引 l  ndarray对象中的元素遵循基于零的索引. 有三种可用的索引方法类型: 字段访问,基本切片和高级索引. l  基本切片 Python 中基本切片概念到 n 维 ...

  5. Numpy 数组操作

    Numpy 数组操作 Numpy 中包含了一些函数用于处理数组,大概可分为以下几类: 修改数组形状 翻转数组 修改数组维度 连接数组 分割数组 数组元素的添加与删除 修改数组形状 函数 描述 resh ...

  6. Python常用库之一:Numpy

    Numpy支持大量的维度数组和矩阵运算,对数组运算提供了大量的数学函数库! Numpy比Python列表更具优势,其中一个优势便是速度.在对大型数组执行操作时,Numpy的速度比Python列表的速度 ...

  7. 1,Python常用库之一:Numpy

    Numpy支持大量的维度数组和矩阵运算,对数组运算提供了大量的数学函数库! Numpy比Python列表更具优势,其中一个优势便是速度.在对大型数组执行操作时,Numpy的速度比Python列表的速度 ...

  8. Python之Numpy详细教程

    NumPy - 简介 NumPy 是一个 Python 包. 它代表 “Numeric Python”. 它是一个由多维数组对象和用于处理数组的例程集合组成的库. Numeric,即 NumPy 的前 ...

  9. numpy tricks(二)—— 删除多维数组的行或列

    numpy.delete numpy 下的多维数组,如果要删除其中的某些行,或某些列,不可以用置空的方式,进行设置: A[1, :] = None, ⇒ 会将 A 中的第一行数据全部置为 Nan 1. ...

随机推荐

  1. openshift 容器云从入门到崩溃之九《容器监控-报警》

    容器状态监控 主要是监控POD的状态包括重启.不健康等等这些k8s api 状态本身会报出来,在配合zabbix报警 导入zabbix模板关联上oc master主机 <?xml version ...

  2. solr6.5.1搜索引擎的部署

    目录结构如下: 6.5.1版本的solr已经集成有jetty服务器(在server目录下),所以可以直接启动solr应用. 1.java环境配置好(这里不再累赘). 2.打开cmd,路径切换到bin目 ...

  3. Lua C/C++互相调用

    先来说下大致脚本引擎框架,此次采用如下,即运行C++代码启动程序,然后加载Lua脚本执行! 1.基础 Lua脚本中只能调用 int (*lua_CFunction) (lua_State *L) 这种 ...

  4. 使用fastdfs搭建文件服务器

    一:安装tracker 1. 拷贝安装目录下各个.gz文件到/usr/local/src下,解压各个install lib,例如tar zxvf xxx.tar.gz 2. 先安装libfastcom ...

  5. Android内存泄漏的检测流程、捕捉以及分析

    https://blog.csdn.net/qq_20280683/article/details/77964208 Android内存泄漏的检测流程.捕捉以及分析 简述: 一个APP的性能,重度关乎 ...

  6. LOJ #10130 点的距离

    在LOJ做的第一道题. 最开始想复杂了qwq 想的是在求LCA的过程中统计向上的步数 其实此题很裸--就是求出u,v的LCA, 再分别用两点深度减去LCA的深度,再加起来就好了qwq---化简--- ...

  7. Shell 常用技巧

    Shell 常用技巧 echo $RANDOM | cksum | cut -c - openssl rand -base64 | cksum | cut -c - date +%N | cut -c ...

  8. 剑指offer(36)两个链表中的第一个公共节点

    题目描述 输入两个链表,找出它们的第一个公共结点. 题目分析 我发现关于链表的题都涉及双指针,大家做的时候记得用双指针. 题目理解了就很好做了,比较简单,先在长的链表上跑,知道长的和短的一样长,再一起 ...

  9. libcurl返回常见错误码

    转载:https://blog.csdn.net/kenkao/article/details/46875571 转载:http://www.cnblogs.com/wainiwann/p/34929 ...

  10. UVA11468 Substring

    思路 AC自动机+概率dp 设f[i][j]表示当前在第i位在AC自动机的第j个节点,满足条件的概率 AC自动机上的一个节点能被转移到当且仅当这个节点不是中止节点且无法通过fail指针跳到任何一个中止 ...