lhelontra / tensorflow-on-arm

TensorFlow for Arm
MIT License
1.05k stars 274 forks source link

Compilation for RPi fails when using Docker on Ubuntu 16.04 #31

Closed treto closed 4 years ago

treto commented 5 years ago

I've tried building the tensorflow wheel file for arm using Docker image and following the README.md. The setup works just fine and build is started, however, ultimately the build procedure fails (full error below).

The bazel version used by the docker is 0.15. I'm using Ubuntu 16.04 running as a guest in VirtualBox.

ERROR: /root/tensorflow-on-arm/build_tensorflow/sources/tensorflow/tensorflow/BUILD:592:1: Executing genrule //tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command (cd /root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow && \ exec env - \ ERROR: /root/tensorflow-on-arm/build_tensorflow/sources/tensorflow/tensorflow/BUILD:592:1: Executing genrule //tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command (cd /root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow && \ exec env - \ PATH=/root/tensorflow-on-arm/build_tensorflow/sources//bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/create_tensorflow.python_api --root_init_template=tensorflow/api_template.__init__.py --apidir=bazel-out/host/genfiles/tensorflow --apiname=tensorflow --apiversion=1 --package=tensorflow.python --output_package=tensorflow bazel-out/host/genfiles/tensorflow/__init__.py bazel-out/host/genfiles/tensorflow/app/__init__.py bazel-out/host/genfiles/tensorflow/bitwise/__init__.py bazel-out/host/genfiles/tensorflow/compat/__init__.py bazel-out/host/genfiles/tensorflow/data/__init__.py bazel-out/host/genfiles/tensorflow/debugging/__init__.py bazel-out/host/genfiles/tensorflow/distributions/__init__.py bazel-out/host/genfiles/tensorflow/dtypes/__init__.py bazel-out/host/genfiles/tensorflow/errors/__init__.py bazel-out/host/genfiles/tensorflow/feature_column/__init__.py bazel-out/host/genfiles/tensorflow/gfile/__init__.py bazel-out/host/genfiles/tensorflow/graph_util/__init__.py bazel-out/host/genfiles/tensorflow/image/__init__.py bazel-out/host/genfiles/tensorflow/io/__init__.py bazel-out/host/genfiles/tensorflow/initializers/__init__.py bazel-out/host/genfiles/tensorflow/keras/__init__.py bazel-out/host/genfiles/tensorflow/keras/activations/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/densenet/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/inception_resnet_v2/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/inception_v3/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/mobilenet/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/mobilenet_v2/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/nasnet/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/resnet50/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/vgg16/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/vgg19/__init__.py bazel-out/host/genfiles/tensorflow/keras/applications/xception/__init__.py bazel-out/host/genfiles/tensorflow/keras/backend/__init__.py bazel-out/host/genfiles/tensorflow/keras/callbacks/__init__.py bazel-out/host/genfiles/tensorflow/keras/constraints/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/boston_housing/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/cifar10/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/cifar100/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/fashion_mnist/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/imdb/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/mnist/__init__.py bazel-out/host/genfiles/tensorflow/keras/datasets/reuters/__init__.py bazel-out/host/genfiles/tensorflow/keras/estimator/__init__.py bazel-out/host/genfiles/tensorflow/keras/initializers/__init__.py bazel-out/host/genfiles/tensorflow/keras/layers/__init__.py bazel-out/host/genfiles/tensorflow/keras/losses/__init__.py bazel-out/host/genfiles/tensorflow/keras/metrics/__init__.py bazel-out/host/genfiles/tensorflow/keras/models/__init__.py bazel-out/host/genfiles/tensorflow/keras/optimizers/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/image/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/sequence/__init__.py bazel-out/host/genfiles/tensorflow/keras/preprocessing/text/__init__.py bazel-out/host/genfiles/tensorflow/keras/regularizers/__init__.py bazel-out/host/genfiles/tensorflow/keras/utils/__init__.py bazel-out/host/genfiles/tensorflow/keras/wrappers/__init__.py bazel-out/host/genfiles/tensorflow/keras/wrappers/scikit_learn/__init__.py bazel-out/host/genfiles/tensorflow/layers/__init__.py bazel-out/host/genfiles/tensorflow/linalg/__init__.py bazel-out/host/genfiles/tensorflow/logging/__init__.py bazel-out/host/genfiles/tensorflow/losses/__init__.py bazel-out/host/genfiles/tensorflow/manip/__init__.py bazel-out/host/genfiles/tensorflow/math/__init__.py bazel-out/host/genfiles/tensorflow/metrics/__init__.py bazel-out/host/genfiles/tensorflow/nn/__init__.py bazel-out/host/genfiles/tensorflow/nn/rnn_cell/__init__.py bazel-out/host/genfiles/tensorflow/profiler/__init__.py bazel-out/host/genfiles/tensorflow/python_io/__init__.py bazel-out/host/genfiles/tensorflow/quantization/__init__.py bazel-out/host/genfiles/tensorflow/resource_loader/__init__.py bazel-out/host/genfiles/tensorflow/strings/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/builder/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/constants/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/loader/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/main_op/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/signature_constants/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/signature_def_utils/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/tag_constants/__init__.py bazel-out/host/genfiles/tensorflow/saved_model/utils/__init__.py bazel-out/host/genfiles/tensorflow/sets/__init__.py bazel-out/host/genfiles/tensorflow/sparse/__init__.py bazel-out/host/genfiles/tensorflow/spectral/__init__.py bazel-out/host/genfiles/tensorflow/summary/__init__.py bazel-out/host/genfiles/tensorflow/sysconfig/__init__.py bazel-out/host/genfiles/tensorflow/test/__init__.py bazel-out/host/genfiles/tensorflow/train/__init__.py bazel-out/host/genfiles/tensorflow/train/queue_runner/__init__.py bazel-out/host/genfiles/tensorflow/user_ops/__init__.py') Traceback (most recent call last): File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in <module> from tensorflow.python.tools.api.generator import doc_srcs File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 74, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) ImportError: /root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyUnicode_InternFromString

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.

Target //tensorflow/tools/pip_package:build_pip_package failed to build INFO: Elapsed time: 9795.185s, Critical Path: 3274.69s INFO: 7633 processes: 7633 local. FAILED: Build did NOT complete successfully

stanlee321 commented 5 years ago

I am also getting the same error, in my laptop with ubuntu 16.04 and even in a AWS T2.2Xlarge instance with ubuntu 16.04 and pre-config docker ce AMI. Any clues about how to solve it ???

lhelontra commented 5 years ago

Hi, i'll try build docker again because in my pc works well.

stanlee321 commented 5 years ago

I downgrade the tf installation to 1.9.0 and at the end of the compilation, the same error popups, also inside of the Docker container image.


:1: Executing genrule //tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow && \
  exec env - \
    PATH=/root/tensorflow-on-arm/build_tensorflow/sources//bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/create_tensorflow.python_api --root_init_template=tensorflow/api_template.__init__.py --apidir=bazel-out/armeabi-opt/genfiles/tensorflow --apiname=tensorflow --apiversion=1 --package=tensorflow.python --output_package=tensorflow bazel-out/armeabi-opt/genfiles/tensorflow/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/app/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/bitwise/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/compat/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/data/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/debugging/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/distributions/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/dtypes/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/errors/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/feature_column/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/gfile/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/graph_util/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/image/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/io/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/initializers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/activations/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/densenet/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/inception_resnet_v2/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/inception_v3/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/mobilenet/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/mobilenet_v2/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/nasnet/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/resnet50/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/vgg16/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/vgg19/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/applications/xception/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/backend/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/callbacks/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/constraints/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/boston_housing/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/cifar10/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/cifar100/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/fashion_mnist/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/imdb/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/mnist/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/datasets/reuters/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/estimator/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/initializers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/layers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/losses/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/metrics/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/models/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/optimizers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/preprocessing/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/preprocessing/image/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/preprocessing/sequence/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/preprocessing/text/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/regularizers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/utils/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/wrappers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/keras/wrappers/scikit_learn/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/layers/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/linalg/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/logging/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/losses/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/manip/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/math/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/metrics/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/nn/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/nn/rnn_cell/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/profiler/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/python_io/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/quantization/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/resource_loader/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/strings/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/builder/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/constants/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/loader/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/main_op/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/signature_constants/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/signature_def_utils/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/tag_constants/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/saved_model/utils/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/sets/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/sparse/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/spectral/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/summary/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/sysconfig/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/test/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/train/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/train/queue_runner/__init__.py bazel-out/armeabi-opt/genfiles/tensorflow/user_ops/__init__.py')
[9,730 / 9,749] 13 actions running
    Linking tensorflow/python/_pywrap_tensorflow_internal.so; 5s local
    Compiling tensorflow/contrib/lite/toco/tflite/export.cc; 3s local
    Compiling tensorflow/contrib/lite/toco/tooling_util.cc; 2s local
Traceback (most recent call last):
  File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in <module>
    from tensorflow.python.tools.api.generator import doc_srcs
  File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /root/.cache/bazel/_bazel_root/ce71fd092aa8d5457c1f0e68f2d49c52/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyUnicode_InternFromString
markwallace16 commented 5 years ago

ERROR: /root/tensorflow-on-arm/build_tensorflow/sources/tensorflow/tensorflow/BUILD:533:1: Executing genrule //tensorflow:tf_python_api_gen_v1 failed (Exit 1):… tensorflow/create_tensorflow.python_api_1.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyUnicode_InternFromString

I was building for python3 and was getting this error. I had trouble figuring it out because the symbol is clearly defined in the python3 libraries. , It turns out that a python2 script is being run using python3…. This undefined symbol is new to python 3, does not exist in python2 The offending script file is generated by Bazel using a template text file for python. bazel/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt has this at the top:

!/usr/bin/env python

Issue resolution was here: https://github.com/bazelbuild/bazel/issues/4146 Allow python3 as value for the --python_path flag when calling bazel build

For example, edit the configuration file like this: BAZEL_EXTRA_FLAGS="--cpu=armeabi --crosstool_top=//tools/local_arm_compiler:toolchain //tensorflow/tools/pip_package:build_pip_package --python_path=python3"

Note that setting environment variables to point at python3 doesn’t help as long as python 2 is installed…