未定义的符号:PyUnicodeUCS4_FromStringAndSize,带有在heroku上的tensorflow

ber*_*rak 2 python heroku tensorflow

试图在heroku上安装tensorflow,最后它失败了:

pywrap_tensorflow.so: undefined symbol: PyUnicodeUCS4_FromStringAndSize
Run Code Online (Sandbox Code Playgroud)

requirements.txt:

numpy
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
Run Code Online (Sandbox Code Playgroud)

安装:

git push heroku master

Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 327 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/python
remote: -----> Python app detected
remote: -----> Installing dependencies with pip
remote:        Collecting numpy (from -r requirements.txt (line 1))
remote:          Downloading numpy-1.10.1.tar.gz (4.0MB)
remote:        Collecting tensorflow==0.5.0 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl (from -r requirements.txt (line 2))
remote:          Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl (10.9MB)
remote:        Installing collected packages: numpy, tensorflow
remote:          Running setup.py install for numpy
remote:        Successfully installed numpy-1.10.1 tensorflow-0.5.0
remote:
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing... done, 54.8MB
remote: -----> Launching... done, v7
remote:        https://jalapenocandy.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To git@heroku.com:jalapenocandy.git
   9a2cc96..231788d  master -> master
Run Code Online (Sandbox Code Playgroud)

看起来不错 !不幸的是,当我尝试:

heroku run bash

$python
python
Python 2.7.10 (default, May 27 2015, 20:38:41)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import tensorflow as tf
import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/__init__.py",
 line 4, in <module>
    from tensorflow.python import *
  File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/__init
__.py", line 22, in <module>
    from tensorflow.python.client.client_lib import *
  File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/client
/client_lib.py", line 35, in <module>
    from tensorflow.python.client.session import InteractiveSession
  File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/client
/session.py", line 11, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/pywrap
_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/pywrap
_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/_
pywrap_tensorflow.so: undefined symbol: PyUnicodeUCS4_FromStringAndSize
Run Code Online (Sandbox Code Playgroud)

我能做些什么吗?

mrr*_*rry 6

此问题是由您的Python二进制文件具有与TensorFlow二进制文件(UCS4)假定的不兼容的Unicode定义(UCS2)引起的.

目前,最好的解决方案是从源代码构建TensorFlow .最新版本不在本机扩展中使用Unicode字符串,因此不应出现此问题.当更新的二进制文件可用时,它们将包含此修复程序.

如果您无法在目标计算机上构建源代码(例如使用Heroku时),则可以选择在不同的计算机(具有相同的体系结构)上构建自己的PIP包,并将其添加到您的计算机上requirements.txt.