link numpy with openblas on Ubuntu 16.04
2017-03-08 02:50
615 查看
最近在美帝搞了台台式机,总算有机会可以玩玩Ubuntu了,正好ST790的project需要用到TensorFlow,当然就要先配置一下Python,特别是numpy。
首先安装openblas
切换blas库
安装numpy(pip或者apt-get均可)
测试
我用了两段代码测试。
用时13s左右
输出为:
跑程序的时候通过htop可见8核全开。
首先安装openblas
sudo apt-get install libopenblas-base
切换blas库
sudo update-alternatives --config libblas.so.3
安装numpy(pip或者apt-get均可)
测试
我用了两段代码测试。
import numpy as np a1 = np.random.rand(10000, 10000) a2 = np.random.rand(10000, 10000) np.dot(a1, a2)
用时13s左右
import numpy as np import numpy.random as npr import time # --- Test 1 N = 1 n = 1000 A = npr.randn(n,n) B = npr.randn(n,n) t = time.time() for i in range(N): C = np.dot(A, B) td = time.time() - t print("dotted two (%d,%d) matrices in %0.1f ms" % (n, n, 1e3*td/N)) # --- Test 2 N = 100 n = 4000 A = npr.randn(n) B = npr.randn(n) t = time.time() for i in range(N): C = np.dot(A, B) td = time.time() - t print("dotted two (%d) vectors in %0.2f us" % (n, 1e6*td/N)) # --- Test 3 m,n = (2000,1000) A = npr.randn(m,n) t = time.time() [U,s,V] = np.linalg.svd(A, full_matrices=False) td = time.time() - t print("SVD of (%d,%d) matrix in %0.3f s" % (m, n, td)) # --- Test 4 n = 1500 A = npr.randn(n,n) t = time.time() w, v = np.linalg.eig(A) td = time.time() - t print("Eigendecomp of (%d,%d) matrix in %0.3f s" % (n, n, td))
输出为:
dotted two (1000,1000) matrices in 547.5 ms dotted two (4000) vectors in 5.73 us SVD of (2000,1000) matrix in 6.938 s Eigendecomp of (1500,1500) matrix in 16.114 s
跑程序的时候通过htop可见8核全开。
相关文章推荐
- Running OpenBTS with the Nuand bladeRF on Ubuntu (The Definitive and Step by Step Guide)
- Ubuntu 16.04的caffe环境配置:cuda 8.0+cudnn 8.0+opencv3.1.0 + python2.7 + matlab2016b + blas(OpenBlas)
- Play with OpenAI Gym in Ubuntu 16.04: Hello World
- [Perl] Regressive bug with perl 5.22.1 on Ubuntu 16.04 x64
- ubuntu16.04上完美的安装caffe-ssd的指南(使用OpenBlas做基本的矩阵操作算子)
- How To Install WordPress with LAMP on Ubuntu 16.04
- How to Install HTTP Git Server With Nginx on Ubuntu 16.04
- ubuntu16.04下OpenBLAS安装步骤
- How To Install WordPress with LAMP on Ubuntu 16.04
- Installing openjdk-7-jdk on Ubuntu 16.04 LTS
- problem with Ubuntu 11.10 on sun-java6-jdk
- 【摘录】Installing Openproj on Ubuntu
- Send-only Mail Server with Exim on Ubuntu 11.04
- Crack Password with John the Ripper on Ubuntu 9.10
- Using OpenWRT on TP-Link WR841N-V7.2 router
- Getting Sart with OpenMPI On Federa 14 X86_64
- Build boost 1.45 with VC++ 2008 on Windows XP and gcc on Ubuntu
- ubuntu open folderpath on terminal