我正在构建tensorflow-serving r1.10;因为我的centos7默认python版本是2.7.13,我想用python3.6构建,所以我改变了tools / bazel.rc中的PYTHON_BIN_PATH。[python3.6 env与pyenv一起安装]
build --action_env PYTHON_BIN_PATH="/home/pyenv/.pyenv/versions/tensorflow-serving/bin/python"
build --define PYTHON_BIN_PATH=/home/pyenv/.pyenv/versions/tensorflow-serving/bin/python
当我构建张量流服务器之前,它已经工作了。但现在,它不起作用,所以这是tensorflow服务r1.11的问题
ERROR: /home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/external/org_tensorflow/tensorflow/BUILD:581:1: Executing genrule @org_tensorflow//tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command
(cd /home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving && \
exec env - \
PATH=/home/pyenv/.pyenv/plugins/pyenv-virtualenv/shims:/home/pyenv/.pyenv/shims:/home/pyenv/.pyenv/bin:/usr/local/ffmpeg/bin/:/opt/jdk1.8.0_112/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/pyenv/.local/bin:/home/pyenv/bin \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api --root_init_template=external/org_tensorflow/tensorflow/api_template.__init__.py --apidir=bazel-out/host/genfiles/external/org_tensorflow/tensorflow --apiname=tensorflow --apiversion=2 --package=tensorflow.python --output_package=tensorflow bazel-out/host/genfiles/external/org_tensorflow/tensorflow/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/app/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/bitwise/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/compat/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/data/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/debugging/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/distributions/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/distributions/bijectors/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/dtypes/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/errors/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/feature_column/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/gfile/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/graph_util/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/image/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/io/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/initializers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/activations/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/densenet/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/inception_resnet_v2/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/inception_v3/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/mobilenet/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/nasnet/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/resnet50/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/vgg16/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/vgg19/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/applications/xception/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/backend/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/callbacks/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/constraints/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/boston_housing/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/cifar10/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/cifar100/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/fashion_mnist/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/imdb/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/mnist/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/datasets/reuters/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/estimator/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/initializers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/layers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/losses/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/metrics/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/models/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/optimizers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/image/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/sequence/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/preprocessing/text/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/regularizers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/utils/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/wrappers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/keras/wrappers/scikit_learn/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/layers/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/linalg/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/logging/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/losses/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/manip/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/math/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/metrics/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/nn/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/nn/rnn_cell/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/profiler/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/python_io/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/quantization/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/resource_loader/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/strings/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/builder/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/constants/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/loader/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/main_op/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/signature_constants/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/signature_def_utils/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/tag_constants/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/saved_model/utils/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/sets/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/sparse/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/spectral/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/summary/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/sysconfig/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/test/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/train/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/train/queue_runner/__init__.py bazel-out/host/genfiles/external/org_tensorflow/tensorflow/user_ops/__init__.py')
Traceback (most recent call last):
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/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 "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/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 "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/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 "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/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 "/home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/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: /home/pyenv/.cache/bazel/_bazel_pyenv/73f8d77da757234474f166b154bb24f7/execroot/tf_serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _Py_FalseStruct
exec命令中甚至没有PYTHON_BIN_PATH。
我知道tensorflow-serving r1.10应该用bazel 0.15 +构建,那么这里发生了什么?如何更改bazel.rc以指定我的python路径?
没有minimal, complete, and veriafiable example很难分辨。也许bazel出于某种原因没有在你的工作区上捡到?
您可以尝试的一件事是使用.bazelrc文件:
https://docs.bazel.build/versions/master/best-practices.html#bazelrc