My OS is Ubuntu 16.04
Python version is 3.5
Tensorflow version is 14.0
When I tried a simple code for TF Eager module
import tensorflow as tf
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
x = [[2.]]
m = tf.matmul(x, x)
I got
AttributeError: module 'tensorflow.contrib.eager' has no attribute 'enable_eager_execution'
So what's wrong?
From Eager user guide:
Eager execution is not included in the latest release (version 1.4) of TensorFlow. To use it, you will need to build TensorFlow from source or install the nightly builds.
Try to install the nightly build of Tensorflow instead of 1.4.0.
As @Sunreef pointed out, you should install the nightly artifacts of tensorflow in order to use TensorFlow eager mode. It is a new, experimental feature that is not yet included in the releases.
To install the nightly pip packages, do:
# For CPU only
pip install tf-nightly
# For GPU support
pip install tf-nightly-gpu
There are also nightly docker/nvidia-docker images available, offering a Jupyter Notebook interface.
# If you have a GPU, use https://github.com/NVIDIA/nvidia-docker
nvidia-docker pull tensorflow/tensorflow:nightly-gpu
nvidia-docker run -it -p 8888:8888 tensorflow/tensorflow:nightly-gpu
# If you do not have a GPU, use the CPU-only image
docker pull tensorflow/tensorflow:nightly
docker run -it -p 8888:8888 tensorflow/tensorflow:nightly
See this page for more details.
Eager execution mode was added to Tensorflow starting with version 1.8. So an update is necessary. In addition, it is a relatively new feature with many glitches and frequent updates, so using the most recent version that can work for you is recommended. Try
conda update tensorflow
or with pip
pip install --upgrade Tensorflow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With