【问题标题】:Dockerfile fails with llvm-config error for numba installDockerfile 因 numba 安装的 llvm-config 错误而失败
【发布时间】:2019-10-12 10:49:23
【问题描述】:

我使用 pypy 基础的 Dockerfile 失败,并出现 FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config' 安装 llvmlite 时,这是我的 requirements.txt 中列出的 numba 依赖项

我尝试遵循并更新此处的说明 Python numba / llvmlite on Debian 8 - i can't build llvmlite

我的错误更详细:

Building wheels for collected packages: llvmlite
Building wheel for llvmlite (setup.py): started
Building wheel for llvmlite (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
 command: /usr/local/bin/pypy3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ux49fegr/llvmlite/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ux49fegr/llvmlite/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8s6wwump --python-tag pp371
   cwd: /tmp/pip-install-ux49fegr/llvmlite/
Complete output (26 lines):
running bdist_wheel
/usr/local/bin/pypy3 /tmp/pip-install-ux49fegr/llvmlite/ffi/build.py
LLVM version... Traceback (most recent call last):
  File "/tmp/pip-install-ux49fegr/llvmlite/ffi/build.py", line 105, in main_posix
    out = subprocess.check_output([llvm_config, '--version'])
  File "/usr/local/lib-python/3/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/local/lib-python/3/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib-python/3/subprocess.py", line 722, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib-python/3/subprocess.py", line 1354, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'

我不想要 conda 安装的重量。没有它有没有办法为 pypy 实现 numba 安装?

FROM pypy:3.6-slim-stretch

RUN apt-get update && apt-get install -y gnupg wget software-properties-common
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 15CF4D18AF4F7421
RUN apt-add-repository "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-6.0 main"
RUN apt-get update
RUN apt-get -y install cython python-llvm build-essential libedit-dev
RUN apt-get -y install libllvm6.0 llvm-6.0-dev llvm-dev

RUN pip install enum34
ENV LLVM_CONFIG=/usr/lib/llvm-6.0-dev/bin/llvm-config pip install llvmlite
ENV LLVM_CONFIG=/usr/lib/llvm-6.0-dev/bin/llvm-config pip install numba
# ENV LD_LIBRARY_PATH /usr/lib/llvm-6.0-dev/lib/

#... other stuff

RUN apt-get clean && apt-get -y update
RUN apt-get -y install python3-dev \
    && apt-get -y install build-essential

# Add requirements
COPY requirements.txt /tmp/

# Install sphinx first as it does not work inside requirements
RUN pip install -U pip && pip install -U sphinx && pip install numpy && pip install cython &&  \
  pip install -r /tmp/requirements.txt

我希望在 pypy 上使用 numba 干净构建 docker 映像

【问题讨论】:

  • 试试FROM python:3.7-alpine3.9 RUN apk add --update alpine-sdk 然后通过pip安装
  • 我正在尝试使用 pypy3.6 而不是 python 3.7,已经成功使用 python3.7 docker 映像。也更喜欢使用 Debian stretch,因为 Alpine 没有我需要的许多库。

标签: docker llvm numba pypy


【解决方案1】:

解决方法 如果错误出现在 4 月 17 日之后(他们发布了新版本,请参阅 history)。 作为一种解决方法,请尝试安装以前的版本

pip3 install llvmlite==0.31.0

【讨论】:

  • 它不再可用说我的点子:(
  • 在安装 llvmlite 之前,我必须更新 pip 和 setuptools。否则 llvmlite 安装失败。
【解决方案2】:

此刻麻木了won't install on python 3.9

我将基础 docker 映像从 python:3.9-slim 更改为 python:3.8-slim,然后 pip install numba 成功

【讨论】:

【解决方案3】:

这为我解决了问题 -

RUN echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" >> /etc/apt/sources.list
RUN echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" >> /etc/apt/sources.list

RUN apt-get install -y --no-install-recommends libedit-dev build-essential
RUN apt-get install -y --no-install-recommends  llvm-8 llvm-8-dev

RUN LLVM_CONFIG=/usr/bin/llvm-config-8 pip3 install enum34 llvmlite numba

使用版本 8,因为最新的 llvm 版本出错 -

RuntimeError: Building llvmlite requires LLVM 7.0.x, 7.1.x or 8.0.x, got '3.7.1'

参考 - https://apt.llvm.org/

【讨论】:

  • 如何在win os上运行这些命令?我的意思是 apt-get ?
  • 这需要一些研究,您可能想在 Windows 构建中试试运气 - llvm.org/builds
  • 我只是安装并运行它吗?但是码头工人也需要拉它吗?构建图像时?
  • 你在构建一个 windows docker 镜像吗?还是你在 Windows 上构建一个 linux docker 镜像?
  • 起初我正在构建 win docker 映像,但弹出了 llvm lite 错误 - 我搜索了解决方案,但唯一的解决方案是上面使用 apt-get 的代码,所以现在我认为我使用的是 ubuntu 映像 -我正在使用您提供的链接
【解决方案4】:

“真正的”解决方案是鼓励llvmlite 和/或numba 为pypy 释放一个轮子。但是对于眼前的问题……

至少根据apt-file,您不知何故缺少 llvm 安装:

$ apt-file find llvm-config |grep llvm-6
llvm-6.0: /usr/bin/llvm-config-6.0
llvm-6.0: /usr/lib/llvm-6.0/bin/llvm-config
llvm-6.0: /usr/share/man/man1/llvm-config-6.0.1.gz

【讨论】:

    【解决方案5】:

    对于在 macOS 上的 Python 3.9 上安装 numba,以下工作:

    # install llvm using MacPorts
    sudo port install llvm-10
    sudo port install llvm_select
    sudo port select --set llvm mp-llvm-10
    # set environment variable used when building `llvmlite`
    export LLVM_CONFIG=/opt/local/bin/llvm-config
    
    # clone, build, and install `llvmlite`
    # http://llvmlite.pydata.org/en/latest/admin-guide/install.html#compiling-llvmlite
    git clone git@github.com:numba/llvmlite.git
    cd llvmlite
    python setup.py build
    python runtests.py
    python setup.py install
    cd ..
    
    # clone, build, and install `numba`
    # https://numba.readthedocs.io/en/stable/user/installing.html#installing-from-source
    git clone git@github.com:numba/numba.git
    cd numba
    export PATH=/usr/bin/:$PATH  # use clang, same as used for building Python 3.9
    pip install -v .
    cd ..
    

    以上是与:

    • llvmlite 在提交 334411cf638c8e06ba19bfda16b07dd64e9dac3c 和
    • numba 提交 ca8132ba5e43fc3f79767046ed55217aeeabb35e。

    【讨论】:

      【解决方案6】:

      根据https://askubuntu.com/questions/1286131/how-do-i-install-llvm-10-on-ubuntu-18-04 我在 Dockerfile 中添加了这些行

      RUN apt-get -y install llvm-10*
      
      RUN rm -f  /usr/bin/llvm-config
      
      RUN ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config
      

      它成功了(llvmlite 已安装)

      【讨论】:

        【解决方案7】:

        这是从github issues thread 获得的解决方案,对我有用!本质上,pip 只需要在安装库之前升级 Dockerfile。我需要做的就是在我的 Dockerfile 中添加这一行:

        --upgrade pip \
        

        这是我的 Dockerfile 示例:

        # Docker commands here ...
        RUN APT_INSTALL="apt-get install -y " && \
        PIP_INSTALL="python3 -m pip install " && \
        apt-get update && \
        # more docker commands here ...
        DEBIAN_FRONTEND=noninteractive $APT_INSTALL \
        python3.6 \
        python3.6-dev \
        python3-distutils-extra \
        python3-pip && \
        ln -s /usr/bin/python3.6 /usr/local/bin/python3 && \
        $PIP_INSTALL \
            --upgrade pip \ # adding this line was my solution
            setuptools \
            && \
        $PIP_INSTALL \
            numpy==1.18.5 \
        # more docker commands here...
        

        这适用于 python 3.6

        【讨论】:

          猜你喜欢
          • 2021-01-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-04-03
          • 1970-01-01
          • 2020-04-11
          • 2023-03-18
          • 2020-03-25
          相关资源
          最近更新 更多