How can I make NumPy use OpenBlas in Ubuntu?

痴心易碎 提交于 2019-12-05 18:53:40

On Ubuntu 16.10 you can just

$ apt install libopenblas-base

and activate your prefered implementation of BLAS using

$ update-alternatives --config libblas.so.3

I did it and ran

import numpy as np
a1 = np.random.rand(10000, 10000)
a2 = np.random.rand(10000, 10000)
np.dot(a1, a2)

with libblas (2m38s, single core load only) and libopenblas (0m18s, multi core load)

EDIT: This was with Python and numpy installed through Ubuntu's official repositories and not with pip.

Based on the ldd output, NumPy must already be linked with OpenBLAS. It just doesn't know it, because it's linked via /usr/lib/libblas*, which it sees as generic BLAS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!