使用 python 3.6 安装自定义构建 tensorflow 1.12 轮时出错

Posted

技术标签:

【中文标题】使用 python 3.6 安装自定义构建 tensorflow 1.12 轮时出错【英文标题】:Getting error installing custom build tensorflow 1.12 wheel with python 3.6 【发布时间】:2019-04-27 17:02:06 【问题描述】:

我正在尝试在 ppc64le 上安装自定义 tensorflow 1.12 轮 带有 NVIDIA Pascal V100 的 IBM Power9 系统,但出现以下错误:

gcc -pthread -B /ccs/home/shubhankar/miniconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DH5_USE_16_API -I./h5py -I/tmp/pip-install-d__8pdpg/h5py/lzf -I/opt/local/include -I/usr/local/include -I/ccs/home/shubhankar/miniconda3/lib/python3.6/site-packages/numpy/core/include -I/ccs/home/shubhankar/miniconda3/include/python3.6m -c /tmp/pip-install-d__8pdpg/h5py/h5py/defs.c -o build/temp.linux-ppc64le-3.6/tmp/pip-install-d__8pdpg/h5py/h5py/defs.o
    In file included from /ccs/home/shubhankar/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1821:0,
                     from /ccs/home/shubhankar/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                     from /ccs/home/shubhankar/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from /tmp/pip-install-d__8pdpg/h5py/h5py/api_compat.h:26,
                     from /tmp/pip-install-d__8pdpg/h5py/h5py/defs.c:657:
    /ccs/home/shubhankar/miniconda3/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it by " \
      ^
    In file included from /tmp/pip-install-d__8pdpg/h5py/h5py/defs.c:657:0:
    /tmp/pip-install-d__8pdpg/h5py/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
     #include "hdf5.h"
                      ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
  Rolling back uninstall of h5py
Command "/ccs/home/shubhankar/miniconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-d__8pdpg/h5py/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-5_3ofwib/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-d__8pdpg/h5py/

由于某种原因,它在安装 h5py 时中断。这一切都始于一条警告信息。我不确定它是否与它有关。

Cythonizing /tmp/pip-install-d__8pdpg/h5py/h5py/h5z.pyx
    /tmp/pip-install-d__8pdpg/h5py/.eggs/Cython-0.29.1-py3.6-linux-ppc64le.egg/Cython/Compiler/Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-d__8pdpg/h5py/h5py/h5z.pxd

最后

Rolling back uninstall of h5py
Command "/ccs/home/shubhankar/miniconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-d__8pdpg/h5py/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-5_3ofwib/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-d__8pdpg/h5py/

我正在使用 miniconda3 进行包管理。系统安装的gcc版本是4.8.5

【问题讨论】:

【参考方案1】:

您在非标准架构上安装tensorflow(没有预编译***at PyPI),因此pip 必须从源代码编译所有内容(包括依赖项,包括h5py)。

要从源代码编译 h5py,您需要安装 HDF5 1.8.4 或更新版本带有开发头文件。详情请见http://docs.h5py.org/en/stable/build.html#source-installation。

如果软件包可用,请使用操作系统的软件包管理器安装 libhdf5-dev。或install HDF5 from sources。

【讨论】:

anaconda 不是已经处理好了 hdf5。我尝试在 power8 和 Nvidia Tesla 非标准架构上从源代码构建,但从未遇到过同样的问题。 你没有在问题中提到anaconda 对不起,我的错。我会相应地更新问题。

以上是关于使用 python 3.6 安装自定义构建 tensorflow 1.12 轮时出错的主要内容,如果未能解决你的问题,请参考以下文章

就地自定义对象使用 __getitem__ python 3.5 与 python 3.6 解包不同的行为

在python 3.6中处理自定义编码时遇到类型错误

Parrot 3.6 安装mitmproxy

使用python 3.6在windows 10中安装imutils

[ubuntu]安装并使用python 3.6及与2.7的切换

Django容器(上): 自定义基础镜像