I am getting headache with tensorflow installations...
I have CUDA 8, CUdnn 6 and UBUNTU 16.04, python 2.7
I want now to install yensorflow. I have followed what they have explained for installation on the website but I have version ismatches of libraries.
As I am using caffe, I do not want to change those versions. So I have to go for older versions of tensorflow it seems.
But I can not find a good way to install it. Every time it is just failuare. I am very tired now.
I go like this:
1- download tensorflow r1.4 from here:
https://github.com/tensorflow/tensorflow/tree/r1.4
2- My 'LD_LIBRARY_PATH' is:
:/usr/local/cuda-8.0/lib64/:/usr/local/cuda/lib64:/home/aa/torch/install/lib:/usr/lib/
3- The I run successfully this:
$ sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7
4- and this:
$ virtualenv --system-site-packages targetDirectory # for Python 2.7
5- I activate the environment
$ source ~/tensorflow/bin/activate
6- and this
(tensorflow)$ easy_install -U pip
Till here, everything is fine.
7- and when I run this line
pip install --upgrade tensorflow-gpu
It finished successfully with this message:
Successfully installed absl-py-0.1.10 numpy-1.14.1 protobuf-3.5.1 setuptools-38.5.1 six-1.11.0 tensorflow-gpu-1.5.0 tensorflow-tensorboard-1.5.1 werkzeug-0.14.1 wheel-0.30.0
But then I cannot import it in python and this message is given:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/aa/tensorflow/local/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.9.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.
I think I should go for older versions.
I did install older versions
but then when I test installation in python I see this messages:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/node_def_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 22, in <module>
serialized_pb=_b('\n/tensorflow/core/framework/resource_handle.proto\x12\ntensorflow\"r\n\x13ResourceHandleProto\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x11\n\tcontainer\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\thash_code\x18\x04 \x01(\x04\x12\x17\n\x0fmaybe_type_name\x18\x05 \x01(\tB/\n\x18org.tensorflow.frameworkB\x0eResourceHandleP\x01\xf8\x01\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
You should be able to install earlier versions of tensorflow using
pip install tensorflow==1.3 where 1.3 is the version number. You can pick the version of your choice.
you can find .whl file of tensorflow in here https://pypi.python.org/pypi/tensorflow/1.4.0 and install it using pip.
hope you looking tensorflow 1.4.0 version in case if you want older version change url https://pypi.python.org/pypi/tensorflow/1.x.0(x= version you want)
'The problem is solved.
I had "/usr/lib/python2.7/dist-packages" in my PYTHONPATH.
So there was a version mismatch between protobufs and it was solved by typing 'unset PYTHONPATH' before starting to import tensorflow.
Related
I've been working on installing and setting up the GPU version of tensorflow for about 8 hours now. I finally got everything full installed, but when I try to test it I get this error:
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Admin\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\Admin\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\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\context.py", line 32, in <module>
from tensorflow.core.framework import function_pb2
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\function_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\tensor_shape_pb2.py", line 36, in <module>
_descriptor.FieldDescriptor(
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\google\protobuf\descriptor.py", line 560, in __new__
return _message.default_pool.FindFieldByName(full_name)
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
I'll put my installation setup below for reference:
Tensorflow 2.3.0
Python 3.8.10
CUDA 10.1
cuDNN 7.6
OS: Windows 10
I solved a similar issue faced while importing tensorflow module by downgrading protobuf from release 4.21.1 to version 3.19.4
$ pip install protobuf
Requirement already satisfied ... (4.21.1)
$ pip uninstall protobuf
Found existing installation: protobuf 4.21.1
Uninstalling protobuf-4.21.1:
Would remove:
/home/kali/.local/lib/python3.10/site-packages/google/protobuf/*
/home/kali/.local/lib/python3.10/site-packages/protobuf-4.21.1-py3.10-nspkg.pth
/home/kali/.local/lib/python3.10/site-packages/protobuf-4.21.1.dist-info/*
Proceed (Y/n)? Y
Successfully uninstalled protobuf-4.21.1
$ pip install protobuf==3.19.4
How do I fix the following error traceback regarding tf.record?
(tensorflow1) c:\tensorflow1\models\research\object_detection>python generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record --image_dir=(image directory)
Traceback (most recent call last):
File "generate_tfrecord.py", line 17, in <module>
import tensorflow as tf
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 15, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\node_def_pb2.py", line 15, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 15, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 15, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "C:\Users\Dell-Oguz\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 91, in <module>
__module__ = 'tensorflow.core.framework.resource_handle_pb2'
TypeError: expected bytes, Descriptor found
Try this, worked for me
pip install protobuf-py3
pip install --upgrade protobuf
I get the same error when I installed tensorflow with conda install -c anaconda tensorflow-gpu over existing tenforflow.
Remove existing environment and create a new one. Then run conda install -c anaconda tensorflow-gpu .
Probably it's due to unmatched tensorflow and tensorboard versions.
I solved it after creating a separate conda environment for my code.
In my case,
pip install --ignore-installed --upgrade tensorflow-gpu==1.15.0
did the job :).
I'm trying to install SyntaxNet on Ubuntu, I followed the Ubuntu 16.10+ binary installation instruction here. When I ran the last command:
python -c 'import dragnn.python.load_dragnn_cc_impl, syntaxnet.load_parser_ops'
I get this long line of error message below:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/dragnn/python/load_dragnn_cc_impl.py", line 19, in <module>
import tensorflow as tf
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/lib/python2.7/dist-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 checked the common installation problems page but it appears there is no fix for this there yet. Does anyone have a similar problem installing SyntaxNet? I would really appreciate your help.
You need to install latest libstdc++6.
check version
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
add repo
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
install
sudo apt-get update
sudo apt-get dist-upgrade # I used this command, I guess that the following command should also work.
sudo apt-get install libstdc++6
I followed this: How to fix: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found.
I recently installed python on my Ubuntu 14.04. I downloaded tensorflow by pip.
When I tried to import tensorflow it said ImportError:No module named tensorflow.
Then I edited PYTHONPATH by adding /usr/local/lib/python2.7/dist-packages. Now when I try to import, it says
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 45, in <module>
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
I found here that 2 versions of python causes the conflict, but that didn't help. Any assistance will be appreciated. Thank you
Best way to install packages if you have more than one python installed is:
path_to_your_python_executable -m pip install package_name
This way, you can make sure that you have installed package for proper python.
And don't forget about sudo ;)
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).