I am having problems trying to run TensorFlow on my Windows 10 machine. Code runs fine on my MacOS machine.
Traceback (most recent call last):
File "c:\Users\Fynn\Documents\GitHub\AlpacaTradingBot\ai.py", line 15, in <module>
from keras.models import Sequential, load_model
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\__init__.py", line 24, in <module>
from keras import models
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\models\__init__.py", line 18, in <module>
from keras.engine.functional import Functional
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\functional.py", line 24, in <module>
from keras.dtensor import layout_map as layout_map_lib
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\dtensor\__init__.py", line 22, in <module>
from tensorflow.compat.v2.experimental import dtensor as dtensor_api # pylint: disable=g-import-not-at-top
ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental' (C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v2\experimental\__init__.py)
This can be caused by an incompatibility between your tensorflow and your keras versions. In particular I see this with tensorflow==2.6.0 and keras==2.9.0, though I would not be surprised if other versions can cause this as well.
Either update your tensorflow version by:
pip install tensorflow==2.8
or downgrade your keras version by:
pip install keras==2.6
Just run :
pip install --disable-pip-version-check --no-cache-dir tensorflow
Before you must delete tensorflow and keras folder at site-package.
Open admin command prompt use this codes
pip uninstall tensorflow
pip install tensorflow --ignore-installed
I tried many solutions to no avail, in the end this worked for me!
pip3 uninstall tensorflow absl-py astunparse flatbuffers gast google-pasta grpcio h5py keras keras-preprocessing libclang numpy opt-einsum protobuf setuptools six tensorboard tensorflow-io-gcs-filesystem termcolor tf-estimator-nightly typing-extensions wrapt
pip3 install --disable-pip-version-check --no-cache-dir tensorflow
Related
Solutions tried:
pip install tensorflow
pip show tensorflow --ignore_installed
pip install tensorflow==2.0.0-rc0
conda install -c conda-forge tensorflow
conda install tensorflow
pip3 show tensorflow
pip show tensorflow
Note: you may need to restart the kernel to use updated packages.
WARNING: Package(s) not found: tensorflow
Tried restarting kernel.
Tried restarting laptop
Code trying to run:
from keras.models import load_model
Error:
runcell(0, 'C:/Users/chinm/untitled1.py')
Traceback (most recent call last):
File "C:\Users\chinm\anaconda3\lib\site-packages\keras_init_.py", line 3, in
from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
ModuleNotFoundError: No module named 'tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\chinm\untitled1.py", line 14, in
from keras.models import load_model
File "C:\Users\chinm\anaconda3\lib\site-packages\keras_init_.py", line 6, in
'Keras requires TensorFlow 2.2 or higher. '
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
I can't see your code, but it appears your key error is Keras requires TensorFlow 2.2, while you installed pip install tensorflow==2.0.0-rc0. 2.0 < 2.2. Have you tried installing tensorflow 2.2 or up, or upgrading your existing version?
https://www.tensorflow.org/install/pip recommends:
pip install --upgrade tensorflow
with
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
to verify the installation.
I have tensorflow-gpu 1.2.1 and keras on ubuntu 16.04.
I am not able to perform:
from kears.utils import multi_gpu_model
Has anyone had success with multi_gpu_model as described in their documentation's FAQ section?
I have a 4 GPU machine with 4 GeForce GTX 1080 Ti cards and want to use all of them.
Here's the error I get:
import keras.utils.multi_gpu_model
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-0174878249b1> in <module>()
----> 1 import keras.utils.multi_gpu_model
2
ModuleNotFoundError: No module named 'keras.utils.multi_gpu_model'
I can import keras and keras.utils successfully.
pip uninstall keras
pip install keras==2.2.4
this helped me ...
working on keras hrnetv2
for Tensorflow 2.7.0 this works:
from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
This function was added on October 11, and there have been no Keras releases that include it. Currently the last Keras release is 2.0.8 released on Aug 25, 2017.
Your only options are to wait until a release is made, or to use a Keras
version directly from git master.
To close this issue: I installed the latest version of Keras from github and got the multi_gpu_model module working as expected.
pip install git+git://github.com/fchollet/keras.git --upgrade
You could reinstall tensorflow-estimator and keras like this:
pip uninstall tensorflow-estimator
pip install tensorflow-estimator
pip uninstall keras
pip install keras
I was able to resolve the issue by this.
I am trying to import keras it gives me an error from tensorflow.python.ops import tensor_array_ops.
>>> import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/__init__.py", line 2, in <module>
from . import backend
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/backend/__init__.py", line 67, in <module>
from .tensorflow_backend import *
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 4, in <module>
from tensorflow.python.ops import tensor_array_ops
ImportError: cannot import name tensor_array_ops
I really appreciate if someone can help me to solve this error.
Thanks.
Try: sudo pip install tensorflow --upgrade
You may be using an older version of TensorFlow.
Did you install tensorflow at all?
Could you try installing the lastest version? There is how:
pip install git+git://github.com/tensorflow/tensorflow
pip install git+git://github.com/fchollet/keras.git --upgrade
If this doesn't work I do recommand using theano as a backend, it worked well for me.
There is how to setup it easily:
pip install git+git://github.com/Theano/Theano
pip install git+git://github.com/fchollet/keras.git --upgrade
pip install tensor
Before you do anything else, start python and import keras. Once keras is imported a new file will be created. You can then execute this command:
vi .keras/keras.json
Once the file is open, change tensorflow for theano and you are ready to go.
I've tried installing tflearn through pip as follows
pip install tflearn
and now when I open python, the following happens:
>>> import tflearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/tflearn/__init__.py", line 22, in <module>
from . import activations
File "//anaconda/lib/python2.7/site-packages/tflearn/activations.py", line 7, in <module>
from . import initializations
File "//anaconda/lib/python2.7/site-packages/tflearn/initializations.py", line 5, in <module>
from tensorflow.contrib.layers.python.layers.initializers import \
ImportError: cannot import name variance_scaling_initializer
Any ideas? I'm using an anaconda installation of python.
The variance_scaling_initializer() function was added on April 19th, which means that it wasn't included in version 0.8.0rc0, and you need to upgrade to a newer version of TensorFlow. If you upgrade to the 0.9.0rc0 version that was released this week, tflearn should work.
Last tflearn update had a compatibility issue with old TensorFlow versions (like mrry said, caused by 'variance_scaling_initializer()' that was only compatible with TensorFlow 0.9).
That error had already been fix, so you can just update TFLearn and it should works fine with any TensorFlow version over 0.7.
This is because your TensorFlow version is too low. Tflearn requires tensorflow‘s version >= 1.0, so you should reinstall tensorflow again, and reinstall step like this:
For python2.7:
sudo pip install tensorflow==1.0 #cpu version
sudo pip install tensorflow-gpu==1.0 # gpu version
For python3:
sudo pip3 install tensorflow==1.0 #cpu version
sudo pip3 install tensorflow-gpu==1.0 # gpu version
Built tensorflow 0.7 from source on Ubuntu 15.10, Cuda 7.5, cudnn 4.0, python 2.7. Bazel build and pip package generation OK. pip install ok. Python script "import tensorflow" fails:
Traceback (most recent call last):
File "/home/keith/Desktop/tf1.py", line 8, in <module>
import tensorflow as tf
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 35, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/graph_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 "/usr/local/lib/python2.7/dist-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 "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_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 "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"z\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x12\x14\n\x0cunknown_rank\x18\x03 \x01(\x08\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tB/\n\x18org.tensorflow.frameworkB\x11TensorShapeProtosP\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
Any thoughts?
Thanks
This does look like a protobuf library versioning error. There's a long thread on similar issues here:
https://github.com/tensorflow/tensorflow/issues/11
Towards the end there are some suggested solutions that might help.
I succeed in running TensorFlow 0.7 on a manjaro linux laptop using cuda acceleration by running python with optirun:
$optirun python
However, I had problem with protobuf and I had to uninstall/reinstall previous version of protobuf and tensorflow with pip. http://bit.ly/1RHApU5
This is because of protobuf version conflict:
for me i had python-protobuf v2.6.1 installed from apt-get package manager
and while installing tensorflow it installed protobuf v3.3.0 from pip manager
so i uninstalled both:
sudo pip uninstall protobuf
sudo apt-get remove python-protobuf
Reinstalled using pip and it solved the issue!!!
sudo pip install protobuf
Hope this helps..