我希望能够在Py3中构建客户端,因为我有一些依赖项。它建立很好,
但是当我运行构建的二进制文件时,它会抛出错误'undefined symbol: PyClass_Type'
。这是一种类型
仅在Py2 C中可用,如here所述。
自动生成_pywrap_tensorflow_internal.so
文件。如何在Py3中构建和运行客户端?
ub64@ub64-VirtualBox:~/serving$ bazel build //tensorflow_serving/example:mnist_client --force_python=PY3
WARNING: ignoring http_proxy in environment.
WARNING: /home/ub64/.cache/bazel/_bazel_ub64/5546b242b4fa6d955b95bc3b90b5397e/external/org_tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule @org_tensorflow//tensorflow/contrib/learn:learn: target '@org_tensorflow//tensorflow/contrib/learn:learn' depends on deprecated target '@org_tensorflow//tensorflow/contrib/session_bundle:exporter': Use SavedModel Builder instead.
WARNING: /home/ub64/.cache/bazel/_bazel_ub64/5546b242b4fa6d955b95bc3b90b5397e/external/org_tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule @org_tensorflow//tensorflow/contrib/learn:learn: target '@org_tensorflow//tensorflow/contrib/learn:learn' depends on deprecated target '@org_tensorflow//tensorflow/contrib/session_bundle:gc': Use SavedModel instead.
INFO: Found 1 target...
Target //tensorflow_serving/example:mnist_client up-to-date:
bazel-bin/tensorflow_serving/example/mnist_client
INFO: Elapsed time: 0.721s, Critical Path: 0.00s
ub64@ub64-VirtualBox:~/serving$ bazel-bin/tensorflow_serving/example/mnist_client
Traceback (most recent call last):
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.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)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/tf_serving/tensorflow_serving/example/mnist_client.py", line 37, in <module>
import tensorflow as tf
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.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)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/ub64/serving/bazel-bin/tensorflow_serving/example/mnist_client.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type
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.
设置
ub64@ub64-VirtualBox:~/serving$ uname -a
Linux ub64-VirtualBox 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
ub64@ub64-VirtualBox:~/serving$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
ub64@ub64-VirtualBox:~/serving/tensorflow$ bazel version
WARNING: ignoring http_proxy in environment.
Build label: 0.5.2
答案 0 :(得分:0)
我使用python3得到了同样的错误并从源代码安装。
尝试通过pip安装apt-get和ModelServer的服务 https://www.tensorflow.org/serving/setup
pip install --upgrade tensorflow-serving-api-python3
sudo apt-get update && sudo apt-get install tensorflow-model-server