Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid ELF header tensorflow

I first tried installing tensorflow via the following:

user@WS1:~/July 2016$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

user@WS1:~/July 2016$ pip install --upgrade $TF_BINARY_URL

Then I tried using a (slightly modified version for linux and tensorflow 0.9.0) solution from iRapha here:

user@WS1:~/July 2016$ wget https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

user@WS1:~/July 2016$ pip install tensorflow-0.9.0-cp27-none-linux_x86_64.whl

Then I tried to test whether tensorflow was successfully installed. The following output shows that there is an 'invalid ELF header' error.

user@WS1:~/July 2016$ python
Python 2.7.12 |Anaconda 2.5.0 (64-bit)| (default, Jul  2 2016, 17:42:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/export/mlrg/caugusta/anaconda2/lib/python2.7/site-packages   /tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/export/mlrg/caugusta/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 48, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/export/mlrg/caugusta/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
  File "/export/mlrg/caugusta/anaconda2/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: /export/mlrg/caugusta/anaconda2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header

I've checked here. Based on that answer, I tried:

user@WS1:~July 2016$ pip install tensorflow

Everything says that tensorflow installed successfully, but when I import it in python I get that invalid ELF header error. Anyone know how I can resolve this?

like image 565
StatsSorceress Avatar asked Feb 06 '23 12:02

StatsSorceress


1 Answers

This could happen if you have install tensorflow package which does not match your platform.

An extreme example would be installing the mac platform package (as seen below) on linux.

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp35-cp35m-linux_x86_64.whl

Just make sure you use the correct platform.

like image 101
Zee Avatar answered Feb 13 '23 05:02

Zee