Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError running tensorflow with python on Heroku?

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?

like image 877
Abs Avatar asked Dec 15 '25 15:12

Abs


1 Answers

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.

like image 115
Employed Russian Avatar answered Dec 18 '25 02:12

Employed Russian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!