Hemp
Hemp

Reputation: 61

Error in tensorflow eager module

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?

Upvotes: 6

Views: 17260

Answers (3)

Ali Hummos
Ali Hummos

Reputation: 19

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

Upvotes: 1

Shanqing Cai
Shanqing Cai

Reputation: 3876

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.

Upvotes: 1

Sunreef
Sunreef

Reputation: 4542

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.

Upvotes: 7

Related Questions