最近在研究点云和图像融合的深度学习算法,目前正在配置相关的算法上的代码,numba这个包需要依赖llvm以及llvmlite,而这两个包安装起来很麻烦,现有网络上没有详细的相关指南,能查到的指南都是17年的安装指南了,版本太多老旧,导致numba的包不兼容,现将正确的安装方法进行记录,希望也能帮助其他人少走一些坑。
想要安装numba必须要安装llvm,具体的安装方法如下:
$ wget -c http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
$ tar xJvf clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
$ pwd
记录此处出现的路径,记录为path
$ vim ~/.bashrc
将path进行替换
export PATH=$PATH:“path”+clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-16.04/bin
$ source ~/.bashrc
$ clang++ -v #测试是否安装成功
测试结果如下:
接下来就是安装llvmlite,如果直接使用
pip3 install llvmlite
是会报错误如下:
Makefile.linux:20: recipe for target 'libllvmlite.so' failed
make: *** [libllvmlite.so] Error 1
7.0.1
SVML not detected
Traceback (most recent call last):
File "/tmp/pip-install-7ugr6pir/llvmlite/ffi/build.py", line 192, in <module>
main()
File "/tmp/pip-install-7ugr6pir/llvmlite/ffi/build.py", line 182, in main
main_posix('linux', '.so')
File "/tmp/pip-install-7ugr6pir/llvmlite/ffi/build.py", line 174, in main_posix
subprocess.check_call(['make', '-f', makefile])
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2
error: command '/usr/bin/python3' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ugr6pir/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ugr6pir/llvmlite/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-40_a_d0g/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ZT/.local/include/python3.5m/llvmlite Check the logs for full command output.
也是很神奇,参考了前面17年的文章时候,要通过Git下载llvmlite,之后修改其中的代码,主要是修改LLVM_CONFIG的具体位置,之后进行编译安装,我感觉这种方法不可以,就去llvmlite官网 https://pypi.org/project/llvmlite/查看了一下,发现了官网中有如下的信息:
LLVM和LLvmlite的版本是有对应关系的,所以我直接选取了llvmlite==0.31.0 ,即使用一下命令:
$ pip3 install llvmlite==0.31.0
$ pip3 install numba
直接搞定安装,不需要修改任何源码等,最为简单的安装~
猜测原本需要修改代码的安装可能是版本之间的对应关系没有搞对,所以有这么多的麻烦,所以安装软件一定要多去官网上看看相关信息~