How can I uninstall Tensorflow 2.0.0-alpha0? - python

I am using sublime text editor to run tensorflow commands using pythin 3.7. In particular I am trying to run: tf.enable_eager_execution() but I get the error:
AttributeError: module 'tensorflow' has no attribute 'enable_eager_execution'
I have checked my version of tensorflow using: print(tf.__version__) and the version is: 2.0.0-alpha0.
What's odd is that I have uninstalled tensorflow completely using pip3 uninstall tensorflow and I still have that version running.
From reading around I believe I cant run tf.enable_eager_execution() because of my tensorflow version and thats why I am trying to uninstall it. Ive also tried to explicitly call it using tensorflow.contrib.eager but still no luck.

TensorFlow 2.0 has eager execution by default. To disable eager execution use
tf.compat.v1.disable_eager_execution()

Related

Python Tensorflow stopped working; cannot import tensorflow due to keras import error

I was playing around with a custom object detector through the Tensorflow object detection API in Python. All of a sudden my code stopped working and is producing the following error when trying to import tensorflow:
from tensorflow.python.keras.engine.base_layer import Layer ImportError: cannot import name 'Layer' from 'tensorflow.python.keras.engine.base_layer'
I have tried redownloading tensorflow and keras with different versions. I am using python 3.7 and tensorflow 1.15. The keras version I was always using is 2.11.0
There could be many reasons for errors such as this. Try to reinstall the packages in a new python virtual environment.
In any case, I recommend using the official tensorflow nvidia docker image, it just works.
https://catalog.ngc.nvidia.com/orgs/nvidia/containers/tensorflow
There is a version mismatch issue. TensorFlow 1.15 does not support Keras 2.11. You need the same version of TensorFlow and Keras. Please reinstall TensorFlow with the latest stable version in your system using the below code:
!pip install tensorflow==3.10
import tensorflow as tf
tf.__version__
As Keras uses tensorflow as backend, Keras will get automatically installed with the same version of TensorFlow while installing TensorFlow.
To check the installed Keras version:
import keras
keras.__version__

ModuleNotFoundError: No module named 'tensorflow.contrib' with jupyter notebook

So this is my error [ModuleNotFoundError: No module named 'tensorflow.contrib']
I'm using tensorflow 2.0.0 and python 3.6.9 when i downgrade the tensorflow version of the code doesn't work when i upgrade it the same thing happens . (i am using jupyter notebook)
I tried to downgrade tensorflow's version and vice versa .
This is the part of the code where i have the error
Please help i really can't find a solution.
tensorflow.contrib is being removed in version 2.0, you therefore need version <= 1.14 to operate tflearn.
In the command line (not the notebook), conda install tensorflow=1.14 (or tensorflow-gpu=1.14 if you want GPU support ; or pip install rather than conda install depending on what you are used to do).
tensorflow.contrib is being removed in version 2.0, you therefore need version <= 1.14 to operate tflearn (by the way, this is a TFlearn issue, not a tensorflow one).
In your case, I would consider moving to tensorflow (instead of tflearn) and using the tf.keras API, which provides the higher-level API tflearn aimed at offering in times when tf.keras was not out yet.

AttributeError: keras.backend ,no attribute 'eager'

I'm using python 3.8.2 , keras 2.3.1 and tensorflow 2.2.0rc4 .
just with the following code :
import keras
from keras.models import sequential
I have this error :
AttributeError: partially initialized module 'keras.backend' has no attribute 'eager' (most likely due to a circular import)
if I use :
import tensorflow
or
from tensorflow.keras import ....
new error :
AttributeError: partially initialized module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function' (most likely due to a circular import)
full traceback:
enter image description here
enter image description here
My suggestion is to reinstall the package. Sometimes this happens due to the installation problem.
Use the following code to do so
Uninstall tensorflow
pip uninstall tensorflow
Requires the latest pip
pip install --upgrade pip
To install keras as separate package
pip install Keras
Current stable release for CPU and GPU
pip install tensorflow
Try this and hope this helps you.
It's an install problem, most likely; K.eager was introduced in Keras 2.3.0 (and is included in Keras 2.3.1), so your Python interpreter is somehow reading code of 2.2.5 or earlier.
A possible culprit is an Anaconda mishap. First run conda uninstall keras. Then, in the anaconda3 directory, search "keras" and delete all results. Lastly, run conda install -c conda-forge keras, which should download version 2.3.1. You might need to run similar steps with TensorFlow (in fact, it's better you do, and first reinstall TensorFlow then Keras).
P.S., your code is probably from keras import Sequential, as sequential should error differently.

Python module in tensorflow anaconda installation

I am working in anaconda environment
I used conda install tensorflow to install tensorflow
In the code I :
import tensorflow as tf
from tensorflow.python.data import Dataset
The first command passes but the second command does not (Import error)
I looked In the github of tensorflow and saw that the tensorflow.python.data module exists but probably changed
Is there a way to get Dataset class from the anaconda installation?
If not is there a workaround ?
Ilan
My mistake was that i used :
conda install tensorflow
rather than follow the instructions in the tensorflow site
Ilan

Why can't tensorflow be imported?

I just installed Tensorflow, and am trying to run a test program in Python to validate the installation. When I run the program usually nothing happens. A couple times the Spyder IDE has crashed. Here is the test program:
print('test before')
import tensorflow as tf
print('test after')
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Interestingly, all lines before importing tensorflow run, that is "test before" is printed. However, the program seems to run into trouble with importing tensorflow because "test after" is not printed. Why can't the program successfully import tensorflow?
Also, note that the tensorflow installation seems to have been successful because at the end it printed "Successfully installed tensorflow-1.7.0". And no errors appear when running the program. Usually if there is a problem when importing the package you get an error saying something like "[package] cannot be found". In this case the program just runs for a few seconds and then stops (or the IDE crashes) without returning an error. When running python3 -c 'import tensorflow' it gave the error Illegal instruction (core dumped).
Tensorflow version: 1.7.0
Python version: 3.5.2
using Spyder IDE
Operating system: ubuntu 16.04 LTS
It turns out that newer versions of TensorFlow use AVX instructions that are not supported on older CPUs. This problem was discussed in a GitHub issue and in an earlier Stack Overflow question. The solution was to downgrade TensorFlow to version 1.5, which I did using the following commands:
pip3 uninstall tensorflow
pip3 install tensorflow==1.5
After downgrading to 1.5 the test code worked.

Categories