从源代码构建TensorFlow后,看到__longjmp_chk:找不到符号错误

时间:2018-09-03 06:57:34

标签: python-3.x docker tensorflow alpine

我正在TensorFlow 1.10.1上使用Python 3.6在Linux Docker映像上从源代码构建AlpineDockerfile已成功构建。尽管如此,仍运行以下代码:

import tensorflow

失败:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/local/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: Error relocating /usr/local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: __longjmp_chk: symbol not found 

我认为问题出在ld库中,并添加了glibc,但仍然出现错误。我使用依赖性管理工具poetry安装了Python软件包。

Dockerfile:

FROM python:3.6-alpine

WORKDIR /app
COPY pyproject.toml /app/pyproject.toml
COPY pyproject.lock /app/pyproject.lock

# Install TensorFlow CPU version
ENV TENSORFLOW_VERSION 1.10.1

RUN apk update \
    && apk add bash \
               ca-certificates \
               libstdc++ \
               libgfortran \
    && wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
    && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk \
    && apk add glibc-2.28-r0.apk \
    && apk add --virtual build-deps \
                         curl \
                         gcc \
                         gfortran \
                         g++ \
                         libstdc++ \
                         libxml2-dev \
                         libxslt-dev \
                         linux-headers \
                         make \
                         musl-dev \
                         python3-dev \
                         py-numpy-dev \
    && apk --no-cache add --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \
                                       hdf5 \
                                       hdf5-dev \
    && mkdir -p /tmp/build \
    && cd /tmp/build/ \
    && wget http://www.netlib.org/blas/blas-3.6.0.tgz \
    && wget http://www.netlib.org/lapack/lapack-3.6.1.tgz \
    && tar xzf blas-3.6.0.tgz \
    && tar xzf lapack-3.6.1.tgz \
    && cd /tmp/build/BLAS-3.6.0/ \
    && gfortran -O3 -std=legacy -m64 -fno-second-underscore -fPIC -c *.f \
    && ar r libfblas.a *.o \
    && ranlib libfblas.a \
    && mv libfblas.a /tmp/build/. \
    && cd /tmp/build/lapack-3.6.1/ \
    && sed -e "s/frecursive/fPIC/g" -e "s/ \.\.\// /g" -e "s/^CBLASLIB/\#CBLASLIB/g" make.inc.example > make.inc \
    && make lapacklib \
    && make clean \
    && mv liblapack.a /tmp/build/. \
    && cd / \
    && export BLAS=/tmp/build/libfblas.a \
    && export LAPACK=/tmp/build/liblapack.a \
    && python3.6 -m pip install --default-timeout=100 future \
    && curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3.6 \
    # Download Tensorflow package
    && cd /app \
    && which ld \
    && wget -q https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-${TENSORFLOW_VERSION}-cp36-cp36m-linux_x86_64.whl \
    && python3.6 -m poetry config settings.virtualenvs.create false \
    && python3.6 -m poetry install \
    && apk del build-deps \
    && rm -rf /tmp/build \
              /var/cache/apk/*

# Make sure Tensorflow built properly
RUN python3.6 -c 'import tensorflow'

COPY . /app
COPY bin/docker_entrypoint.sh /app/entrypoint.sh
COPY --from=0 /app/train app/train

EXPOSE 80

ENTRYPOINT ["/app/entrypoint.sh"]

0 个答案:

没有答案