手动安装

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. this inspection detects names that should resolved but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are sup

    输入第一行代码:import logging;logging.basicConfig(level==logging.INFO) 提示:this inspection detects names tha ...

  2. 从零开始一起学习SLAM | 给点云加个滤网

    对VSLAM和三维重建感兴趣的在计算机视觉life"公众号菜单栏回复"三维视觉"进交流群. 小白:师兄,上次你讲了点云拼接后,我回去费了不少时间研究,终于得到了和你给的参 ...

  3. Vue+element 实现文件导出xlsx格式

    傻瓜教程:   第一步:安装两个依赖包 npm install --save xlsx file-saver 第二步:建立一个Vue文件,导入以下代码即可 <template> <d ...

  4. 【转】学习Robot Framework必须掌握的库—-BuiltIn库

    作为一门表格语言,为了保持简单的结构,RF没有像别的高级语言那样提供类似if else while等内置关键字来实现各种逻辑功能,而是提供给了用户BuiltIn库.如果用户想在测试用例中实现比较复杂的 ...

  5. JavaWeb-----实现第一个Servlet程序

    1.Servlet简介      Servlet是在服务器端运行的一个小程序,实际上一个Servlet就是一个Java类,并且可以通过“请求-响应”编程模型来访问的这个驻留在服务器内 存里的servl ...

  6. Python数据分析Numpy库方法简介(二)

    数据分析图片保存:vg 1.保存图片:plt.savefig(path) 2.图片格式:jpg,png,svg(建议使用,不失真) 3.数据存储格式: excle,csv csv介绍 csv就是用逗号 ...

  7. linux 英汉词典程序shell+postgresql版

    在linux控制台下工作,有时候遇到不懂的单词,想要找个linux下的词典程序,搜寻无果,只好自己动手写个了. 首先获取词典文本文件,在github上找到一个 建立数据库 create databas ...

  8. 剑指offer(50)数组中重复的数字

    题目描述 在一个长度为n的数组里的所有数字都在0到n-1的范围内. 数组中某些数字是重复的,但不知道有几个数字是重复的.也不知道每个数字重复几次.请找出数组中任意一个重复的数字. 例如,如果输入长度为 ...

  9. 用mint-ui picker组件 实现省市区三级联动

    公司上一期项目中新增了省市区滑动三级联动效果,用的是mint-ui的picker组件和popup组件,效果如下:点击确定换地区,点击取消不变 省市区数据是后台给的(根据上一级的id,获取下一级数据列表 ...

  10. linux 指令 备份

    lsb_release -a LSB是Linux Standard Base的缩写,lsb_release命令用来显示LSB和特定版本的相关信息.如果使用该命令时不带参数,则默认加上-v参数. -v, ...