3

I am trying to import tensorflow in my Heroku instance, and I keep getting the following error:

File "/app/tools/inception/classify_image.py", line 45, in <module>
2016-06-23T19:08:18.090957+00:00 app[clock.1]:     import tensorflow as tf
2016-06-23T19:08:18.090979+00:00 app[clock.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
2016-06-23T19:08:18.091005+00:00 app[clock.1]:     from tensorflow.python import *
2016-06-23T19:08:18.091011+00:00 app[clock.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 45, in <module>
2016-06-23T19:08:18.091050+00:00 app[clock.1]:     from tensorflow.python import pywrap_tensorflow
2016-06-23T19:08:18.091068+00:00 app[clock.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
2016-06-23T19:08:18.091112+00:00 app[clock.1]:     _pywrap_tensorflow = swig_import_helper()
2016-06-23T19:08:18.091116+00:00 app[clock.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
2016-06-23T19:08:18.091136+00:00 app[clock.1]:     _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
2016-06-23T19:08:18.091166+00:00 app[clock.1]: ImportError: /app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header

Would anybody know why that is? I have the following line in my requirements.txt:

https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

I'm not sure what it means by invalid ELF header. Am I missing a dependency or something?

Abs
  • 1,726
  • 2
  • 17
  • 28
  • Here is a question which might help: http://stackoverflow.com/questions/5713731/what-does-this-error-mean-invalid-elf-header – Yao Zhang Jun 23 '16 at 20:32

1 Answers1

6

ImportError: /app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header

The most likely cause is that you are attempting to load x86_64 TF shared library into i386 Python executable.

You can verify this by running

file -L /app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so

(which should produce ELF 64-bit LSB shared object, x86-64, version 1 (SYSV) ...) and

file -L /app/.heroku/python/bin/python2.7

(which should say ELF 64-bit LSB executable, x86-64, version 1 (SYSV), ..., but probably says ELF 32-bit LSB executable ... instead).

Update:

_pywrap_tenso‌​rflow.so: Mach-O 64-bit x86_64 dynamically linked shared library

This is a MacOS version that you are trying to load into Linux Python. You need a Linux version of tensorflow.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Here's the output from running those things. Running `file -L /app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so` gives `/app/.heroku/python/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: Mach-O 64-bit x86_64 dynamically linked shared library` and `file -L /app/.heroku/python/bin/python2.7` gives `/app/.heroku/python/bin/python2.7: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=99516c2c2eaad1ec73864b40a691bf1cacf29f35, not stripped` – Abs Jun 23 '16 at 21:23
  • So it seems like the output is what it should be? – Abs Jun 23 '16 at 21:29
  • @Abs: no, it's not what it should be. Answer updated. – Employed Russian Jun 24 '16 at 07:21