首页 文章

请勿在conda环境中正确安装numba / llvmlite

提问于
浏览
5

我创建了一个新的conda环境

user@machine:~/project$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /home/user/anaconda2/envs/test-env:

The following NEW packages will be INSTALLED:

    llvmdev:    3.8.1-7       numba
    openssl:    1.0.2k-0           
    pip:        9.0.1-py35_1       
    python:     3.5.2-0            
    readline:   6.2-2              
    setuptools: 27.2.0-py35_0      
    sqlite:     3.13.0-0           
    system:     5.8-2         numba
    tk:         8.5.18-0           
    wheel:      0.29.0-py35_0      
    xz:         5.2.2-1            
    zlib:       1.2.8-3            

Proceed ([y]/n)? y

#
# To activate this environment, use:
# > source activate test-env
#
# To deactivate this environment, use:
# > source deactivate test-env
#

然后激活它并尝试使用专门的pip(而不是conda)来安装llvmlite和numba,这似乎是成功的 . (注意:我也尝试了 --no-cache-dir 并且它没有改变任何东西 . )

user@machine:~/project$ source activate test-env
(test-env) user@machine:~/project$ pip install llvmlite==0.15 numba==0.30.1
Collecting llvmlite==0.15
Collecting numba==0.30.1
Collecting numpy (from numba==0.30.1)
  Using cached numpy-1.12.0-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: llvmlite, numpy, numba
Successfully installed llvmlite-0.15.0 numba-0.30.1 numpy-1.12.0

但是库没有正确安装,

(test-env) user@machine:~/project$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 42, in <module>
    lib = ctypes.CDLL(os.path.join(_lib_dir, _lib_name))
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so: undefined symbol: _ZNKSt14error_category23default_error_conditionEi

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/__init__.py", line 9, in <module>
    from . import config, errors, runtests, types
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/config.py", line 11, in <module>
    import llvmlite.binding as ll
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/__init__.py", line 6, in <module>
    from .dylib import *
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/dylib.py", line 4, in <module>
    from . import ffi
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 47, in <module>
    lib = ctypes.CDLL(_lib_name)
  File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory

为什么来自numba通道的 llvmdev 的conda安装失败"just work" .

在我的用例中,我来到一个具有pip样式的requirements.txt文件的项目,我需要从该文件创建conda环境 . 一些项目开发人员将使用venv pip,一些将使用conda,并且其中包含的某些软件包在任何anaconda渠道中都找不到,因此必须安装pip . 除了requirements.txt之外,我们不想维护单独的envrionment.yaml,因此从conda环境中的requirements.txt安装是我的约束的一部分 .

一切似乎没问题,除了numba / llvmlite的pip安装,它需要llvm 3.8的系统依赖性 . 我想将其作为conda环境的一部分来满足 .

我怎样才能从conda环境中确保只存在用于安装numba和llvmlite的正确llvmdev?

2 回答

  • 1

    在理想情况下,安装llvmlite后应该存在所需的共享库 .

    (test-env) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
    (test-env) ~/condaexpts$ source activate test-env
    (test-env) ~/condaexpts$ pip install numpy==1.12.0 llvmlite==0.15 numba==0.30.1
    (test-env) ~/condaexpts$ find $CONDA_PREFIX | grep libllvmlite
    /home/ubuntu/condaexpts/m3/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so
    

    如果test-env中没有此文件,则在安装llvmlite时出现问题 .

    另外,反过来考虑这种方法 . 您不需要将要求文件与conda环境文件分开 . 您可以在conda环境文件本身中拥有两个依赖项:

    (test-env) ~/condaexpts$ conda env export               
    name: test-env
    channels:
    - !!python/unicode
      'numba'
    - !!python/unicode
      'defaults'
    dependencies:
    - !!python/unicode
      'openssl=1.0.2k=0'
    - !!python/unicode
      'pip=9.0.1=py35_1'
    - !!python/unicode
      'python=3.5.2=0'
    - !!python/unicode
      'readline=6.2=2'
    - !!python/unicode
      'setuptools=27.2.0=py35_0'
    - !!python/unicode
      'sqlite=3.13.0=0'
    - !!python/unicode
      'tk=8.5.18=0'
    - !!python/unicode
      'wheel=0.29.0=py35_0'
    - !!python/unicode
      'xz=5.2.2=1'
    - !!python/unicode
      'zlib=1.2.8=3'
    - !!python/unicode
      'llvmdev=3.8.1=7'
    - !!python/unicode
      'system=5.8=2'
    - pip:
      - llvmlite==0.15.0
      - numba==0.30.1
      - numpy==1.12.0
    prefix: !!python/unicode '/home/ubuntu/condaexpts/m3/envs/test-env'
    

    在第二个注释中,您可以安装“numba”conda通道本身所需的预构建二进制文件 . 附:

    (root) ~/condaexpts$ ./Miniconda3-latest-Linux-x86_64.sh -b -p m3
    (root) ~/condaexpts$ source ./m3/bin/activate 
    (root) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8 numba=0.30.1 llvmlite=0.15.0
    (root) ~/condaexpts$ source activate test-env
    (test-env) ~/condaexpts$ python
    Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numba
    >>> numba.__version__
    '0.30.1'
    
  • 1

    Installing llvmdev :通过在您的 Channels 中添加conda-forge,可以实现从conda-forge Channels 安装llvmdev:

    conda config --add channels conda-forge
    

    启用 conda-forge Channels 后,可以安装 llvmdev

    conda install llvmdev
    

    可以列出您平台上可用的llvmdev的所有版本:

    conda search llvmdev --channel conda-forge
    

    帮助:我从他们的GitHub源克隆了相关文件并进行了python setup.py安装
    更多没有conda使用pip sudo pip install -U llvmlite
    sudo pip install -U numba

相关问题