未定义的符号:PyUnicodeUCS4_FromStringAndSize 在 heroku 上使用 tensorflow
undefined symbol: PyUnicodeUCS4_FromStringAndSize with tensorflow on heroku
尝试在 heroku 上安装 tensorflow,最后 it fails 有:
pywrap_tensorflow.so: undefined symbol: PyUnicodeUCS4_FromStringAndSize
requirements.txt:
numpy
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
安装:
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
看起来不错!不幸的是,当我尝试时:
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
我能做些什么吗?
此问题是由于您的 Python 二进制文件具有与 TensorFlow 二进制文件 (UCS4) 假定的不兼容的 Unicode 定义 (UCS2)。
目前最好的方案是构建TensorFlowfrom source。最新版本在native extension中没有使用Unicode字符串,所以应该不会出现这个问题。当更新的二进制文件可用时,它们将包含此修复程序。
如果您无法在目标机器上从源代码构建(例如使用 Heroku 时),一个选择是 build your own PIP package 在另一台机器(具有相同架构)上,并将其添加到您的requirements.txt
而不是。
尝试在 heroku 上安装 tensorflow,最后 it fails 有:
pywrap_tensorflow.so: undefined symbol: PyUnicodeUCS4_FromStringAndSize
requirements.txt:
numpy
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
安装:
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
看起来不错!不幸的是,当我尝试时:
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
我能做些什么吗?
此问题是由于您的 Python 二进制文件具有与 TensorFlow 二进制文件 (UCS4) 假定的不兼容的 Unicode 定义 (UCS2)。
目前最好的方案是构建TensorFlowfrom source。最新版本在native extension中没有使用Unicode字符串,所以应该不会出现这个问题。当更新的二进制文件可用时,它们将包含此修复程序。
如果您无法在目标机器上从源代码构建(例如使用 Heroku 时),一个选择是 build your own PIP package 在另一台机器(具有相同架构)上,并将其添加到您的requirements.txt
而不是。