I installed tensorflow on Linux, but when I try to import it in the python shell it cannot find the module. I cannot find the error massage on the tensorflow website. Does anyone have any ideas on how I can fix it?
Whenever I give the command:
import tensorflow as tf
I get as a return:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
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.
Going through your error seems like you're using anaconda for your tensorflow. I have got this error and it seems that tensorflow-gpu for anacoda is still under development and does not work properly.
I suggest you to installed the tensorflow-gpu version out of the anaconda environment. The cpu version works fine though.
After clean installing it again without anacoda for python 2.7. DO:
cd /opt/DL/tensorflow/bin/
source tensorflow-activate
Follow this as it is similar
It looks like it can't find your Cuda library. Things you want to check are:
Do you actually have a GPU? If not: reinstall the non-GPU tensorflow
Do you have Cuda version 8.0? Before you could use an older version, but since the Tensorflow 1.0 release you have to have at least version 8. Maybe reinstall Cuda to fix this problem.
Good luck!
Related
I tried different versions of TF, installed VisualStudio but it never worked.
I'm using Python 3.8.0rc1 on windows 10 64-bit.
Would highly appreciate your help!
C:\WINDOWS\system32>rasa init
Traceback (most recent call last):
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\наталия\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\наталия\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Наталия\AppData\Local\Programs\Python\Python38\Scripts\rasa.exe\__main__.py", line 7, in <module>
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\rasa\__main__.py", line 104, in main
set_log_level(log_level)
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\rasa\utils\common.py", line 66, in set_log_level
update_tensorflow_log_level()
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\rasa\utils\common.py", line 108, in update_tensorflow_log_level
import tensorflow as tf
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
First of all, I will suggest to use the Linux, i.e. Ubuntu Operating System through VM.
Also which ever version you use for the Rasa or the VM or Python or Anaconda Environment, always opt for stable version.
Refer Rasa Change logs https://legacy-docs-v1.rasa.com/changelog/
also follow the Installation guide where the python versions are mentioned:
https://legacy-docs-v1.rasa.com/user-guide/installation/
As you see 3.8 python version is not mentioned, so read the document and install as per the instruction, this could be a possibility for that error
Problem solved!
So after having read multiple issues similar to mine that other people had I figured that the main problem is my old Pentium CPU which doesn't support AVX instructions.
I tried older versions of tensorflow and rasa which didn't require AVX (tensorflow 1.15 and earlier, rasa 1.7.4 and earlier) but always received dependencies errors.
So I ended up upgrading my Pentium CPU for Core i-7 3770 and now it all works just fine in the latest versions available.
When I faced the similar error, I uninstalled Tensorflw completely, cleaned cache and then installed it again with Conda.
Previously I had tensorflow installed using pip.
I am new to posting here, so forgive me if I mess something up. I have been trying for quite some time to install tensorflow with gpu support on Mac OS 10.12.6. I know Tensorflow for mac support was dropped starting in version 1.2. I am installing version 1.1.0. I was able to install this version, however, when I try to import tensorflow, I get the following stack trace:
import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: dlopen(/Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: #rpath/libcublas.8.0.dylib
Referenced from: /Users/workhorse/tensorflow-gpu/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found
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 checked out the common reasons but none mentioned the one I have. Thank you for your time and help!
According to the GitHub URL there looks like there might be a fix here
According to one of the users, this seems to be a popular answer:
I just did some research I didn't really provide any insight to your answer I hope it helps if not let me know.
To run our tests on Jenkins, we need to install tensorflow in the virtual environment inside the Jenkins agent. I am getting the following error.
import tensorflow as tf
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyUnicodeUCS4_FromString
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.
From the last line of error PyUnicodeUCS4_FromString I think this might be because of the wrong UCS type in python. However, I do not have sudo control over the Jenkins agents to install another python version. Any suggestions?
TF version : 1.6.0
Python verson: 2.7.3
I tried running tensorflow inside a Docker image on Jenkins and it worked.
I am trying to run sample code in tensor flow with only one line - import tensorflow as tf. But it gives this error.
Traceback (most recent call last): File "sample.py", line 1, in <module>
import tensorflow as tf File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import * File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg) ImportError: Traceback (most recent call last): File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper() File "/home/djlimdiwala/.local/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: libcudart.so.8.0: cannot open shared object file: No such file or directory
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.
CAN ANYONE HELP IN THIS?
Focus on this part:
"ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory"
The reason why this message is displayed because Tensorflow couldn't find the place where the Nvidia cuda library is installed. Try to install it properly along with the tensorflow.
If you are using the pre-built TensorFlow binaries(included in their website https://www.tensorflow.org/install/install_linux) then please check the supported cuda and cudnn versions before installing. Those pre-built TensorFlow versions support specific versions only.
It is giving you this error because some how when you install cuda, it does not save its location in the environment.
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
Export the path to cuda lib:
sudo ldconfig /usr/local/cuda/lib64
cuda_version: 8.0
cuDNN_version: 5.1
I followed the instructions on this page and managed to install TensorFlow via pip within Visual Studio 2015. My Python environment runs in Enthought Canopy. The installation was successful. I refreshed the DB, and auto-completion via IntelliSense was available when I wrote the following line:
from tensorflow.examples.tutorials.mnist import input_data
However, when I run it in the REPL, I see the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\__init__.py", line 23, in <module>
from tensorflow.python import *
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow import contrib
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\__init__.py", line 23, in <module>
from tensorflow.contrib import layers
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\layers\__init__.py", line 68, in <module>
from tensorflow.contrib.layers.python.layers import *
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\layers\python\layers\__init__.py", line 22, in <module>
from tensorflow.contrib.layers.python.layers.initializers import *
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\layers\python\layers\initializers.py", line 24, in <module>
from tensorflow.python.ops import random_ops
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\ops\random_ops.py", line 23, in <module>
from tensorflow.python.framework import ops
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\framework\ops.py", line 39, in <module>
from tensorflow.python.framework import versions
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\framework\versions.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
Can anyone shed some light on why I get the message ImportError: No module named _pywrap_tensorflow even though the installation of TensorFlow took place without a hiccup? Any suggestions on how I can resolve this issue?
The current version of TensorFlow does not support running on Windows. In particular, the PIP packages available here are for Linux and Mac OS X only: they include a native compiled library called _pywrap_tensorflow that has not been compiled for Windows.
As suggested in another answer, you can run TensorFlow on Windows using a Docker container. There is an open issue on GitHub concerning better Windows support, but this will depend on Bazel adding support for Windows build (currently targeted for later this year).