ubuntu安装numba详细指令亲测有效

numba可以给python程序运行加速

windows平台下直接pip安装numba就行

pip install numba

TX2(ubuntu16.04)上这样安装numba就会报错,因为需要先手动安装llvm和llvmlite

主要参考https://blog.csdn.net/fuck_hang/article/details/106950765

首先numba安装需要依赖包llvmlite,llvmlite又需要安装llvm
本次安装numba版本为0.31.0,llvmlite版本为0.16.0,llvm版本为3.9

1. 安装llvm-3.9

sudo apt-get install llvm-3.9

2. 下载llvmlite0.16.0源码并编译安装

通过pip install llvmlite==0.16.0在终端中显示出下载链接,然后用wget下载源码到电脑任意位置,解压进入源码文件夹,运行安装程序

sudo LLVM_CONFIG=/usr/bin/llvm-config-3.9 python setup.py install

通过源码安装的好处是可以指定LLVM_CONFIG的路径,否则用pip安装还是会报错找不到llvm

更新:

更简单的方法是不用从源码安装,直接用pip安装llvmlite,如下

sudo LLVM_CONFIG=/usr/bin/llvm-config-3.9 pip install llvmlite==0.16.0

3. 安装numba

sudo LLVM_CONFIG=/usr/bin/llvm-config-3.9 pip install numba==0.31

同样,用pip安装numba0.31前还要指定LLVM_CONFIG的路径,否则还是会报错。

注意对于电脑上有python2和python3的情况(如TX2),pip安装的包对应python2,pip3对应python3

用pip安装的包在python3运行程序的时候是找不到的。看自己运行程序需要用python(python2)还是python3,从而选择合适的pip

pip list

可以查看pip已经安装好的包,可以检查有没有numba

猜你喜欢

转载自blog.csdn.net/benchuspx/article/details/109152810