Error when importing tensorflow on raspberry pi 2 - python

After installing tensorflow from the source on my raspberry pi, importing tensorflow gives me the following error:
import tensorflow
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: /usr/local/lib/python3.4/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so: wrong ELF class: ELFCLASS64
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: /usr/local/lib/python3.4/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so: wrong ELF class: ELFCLASS64
By the way, I am installing from the official tensorflow website on a raspberry pi 2 on python 3.4.
I uninstalled all of the tensorflow dependencies including numpy, and installed. This installed all of the dependencies but took around an hour. It also said that:
Could not find .egg-info directory in install record for numpy>=1.11.0 (from tensorflow==1.2.0)
and:
Could not find .egg-info directory in install record for protobuf
Then when importing tensorflow, it gives me the first error.

You error _pywrap_tensorflow_internal.so: wrong ELF class: ELFCLASS64 means that you're trying to load 64-bit code into 32-bit process.
What OS do you have?
This guy was succeeded in installing tensorflow on Raspberry Pi 2.
You can also try this package.
Note that running Raspberry 2 is not straightforward task. What official tensorflow site did you use?
As for egg-info warnings, try to upgrade setuptools with pip install --upgrade setuptools pip.

Related

Can't run tensorflow on Win10

I am trying to run Gpt2 on my machine, i am following this guide : https://lambdalabs.com/blog/run-openais-new-gpt-2-text-generator-code-with-your-gpu/
I created a new environment on Conda to make sure it would be isolated and all, and downloaded the correct versions of the libs.
My environment is :
Windows 10
Python 3.6
tensorflow-gpu 1.12 (installed with pip)
CUDA v9, v10, v11
cuDNN for v9 and for v11 (i first installe dht elatest, but then i was told tensorflow was only happy with version 9 so i installed it)
Whenever i try to import tensorflow, either with from tensorflow import * or import tensorflow as tf
I get :
Traceback (most recent call last):
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
This error isn't helping at all, and i'm stuck there. Any ideas ?
Thank you.
EDIT :
For those running in the same problem, follow the github link, install everything with conda. I also ran into this problem : Tensorflow has no Attribute "sort" in GPT 2 Git Release? that was solved as well by udating tensorflow. Thanks everyone
Please try to install tensorflow with conda with below command.
conda install -c conda-forge tensorflow //tensorflow package
or for specific version
conda install -c conda-forge tensorflow=1.13.1

Error in importing tensorflow ( python 3.6x )

import error tensorflow in python 3.6.0
Failed to load the native TensorFlow runtime.
ImportError: DLL load failed: The specified module could not be found.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Vignesh\AppData\Local\Programs\Python\Python36\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
It might be because it is installed as a Python 2 package and you're running Python 3 or the opposite.
To specifically install the package for Python 3, try entering this command:
pip3 install tensorflow
or
python3 -m pip install tensorflow
To specifically install the package for Python 2, try entering this command:
pip2 install tensorflow
or
python -m pip install tensorflow

How to setup virtual environment to run tensorflow benchmarks

My purpose is setting up virtual environment to run tensorflow benchmark but I am getting an error at last statement after running following code. May I ask what I should do to resolve this issue? FYI: I am using Python 3.6.7 with only pip and virtualenv packages and CUDA 9.2/cuDNN7 installed (all dlls in system path).
virtualenv venv
venv\scripts\activate
#now you should be in virtual environment
#install using pip
pip install tf-nightly-gpu
python
import tensorflow
Error message:
>>> import tensorflow
Traceback (most recent call last):
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>
Found an answer just after writing the question.
Downgrading CUDA 9.2 to 9.0 before copying cudnn64_7.dll (cuDNN 7.3.1 for CUDA 9.0) to CUDA bin directory made it work.
In the end, following script produced two different results from two different machines.
virtualenv venv
venv\scripts\activate
pip install tf-nightly-gpu
python tf_cnn_benchmarks.py --num_gpus=1 --batch_size=32 --model=resnet50 --variable_update=parameter_server
7th gen quad-core i7 with GTX 970
total images/sec: 78.16
AMD 1920X with GTX 1080
total images/sec: 147.77

Installing Tensorflow 1.10 on El Capitan 10.11.6

I am trying to install tensorflow 1.10 on my old mac, but I run into the same problem every time. As soon as I start the python shell and I do get the error below.
I did try to install it in a virtualenv first, after that, I tried to install it just using pip and got the same error. Also when I tried to install it with conda, the same issue again. I googled and looked that up here, but couldn't solve it yet, maybe due to my noobish acting. I did uninstall anaconda and pip already and tried again, but I always run into the same error.
I do have CUDA installed, although I tried to install tensorflow with and without GPU.
The error results in: Failed to load the native TensorFlow runtime.
I hope someone is able to help, as I would really like to learn this.
(tensorflow) abc:~ me$ python
import tensorflow as tf
Traceback (most recent call last):
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/Users/me/tensorflow/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Users/me/tensorflow/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _SecKeyCopyExternalRepresentation
Referenced from: /Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so (which was built for Mac OS X 10.12)
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
During handling of the above exception, another exception occurred:
>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/Users/me/tensorflow/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Users/me/tensorflow/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _SecKeyCopyExternalRepresentation
Referenced from: /Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so (which was built for Mac OS X 10.12)
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /Users/me/tensorflow/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
For some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I think there is something wrong with TensorFlow 1.10 and OS X El Capitan (10.11.6)!
Just install 1.9.0 instead of 1.10 with the pip command:
pip3 install tensorflow==1.9.0
or its GPU version:
pip3 install tensorflow-gpu==1.9.0
It seems to be a version conflict. I can succesfully run Tensorflow 1.9.

Error imporing tensorflow in python 3.4 "Failed to load the native TensorFlow runtime"

Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/init.py", line 61, in
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/usr/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: /opt/Xilinx/Vivado/2015.1/lib/lnx64.o/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by /usr/local/lib/python3.4/dist-packages/tensorflow/python/_pywrap_tensorflow.so)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "image_resize.py", line 10, in
import tensorflow as tf
File "/usr/local/lib/python3.4/dist-packages/tensorflow/init.py", line 24, in
from tensorflow.python import *
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/init.py", line 72, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/init.py", line 61, in
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/usr/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: /opt/Xilinx/Vivado/2015.1/lib/lnx64.o/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by /usr/local/lib/python3.4/dist-packages/tensorflow/python/_pywrap_tensorflow.so)
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
i am using ubuntu 14.4
and python version 3.4
It looks like you installed Xilinx which includes an older version of libstdc++. If you remove it from your LD_LIBRARY_PATH, that should solve the issue.
I'm using Ubuntu 14.4 with python 3.5. I run the following and the python3 shell imported tensorflow perfectly fine.
sudo -H pip3 install tensorflow

Categories

Resources