Ubuntu 14.04.
Python 2.7.13 :: Anaconda custom (64-bit)
I installed Tensorflow follow the tutorial: https://www.tensorflow.org/install/
when I enter
~/anaconda2/lib/python2.7/site-packages/tensorflow/examples/tutorials/mnist
and attempt to run the already existed python file:
fully_connected_feed.py
I met the below AttributeError:
:~/anaconda2/lib/python2.7/site-packages/tensorflow/examples/tutorials/mnist$ python fully_connected_feed.py
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Extracting Mnist_data/train-images-idx3-ubyte.gz
Extracting Mnist_data/train-labels-idx1-ubyte.gz
Extracting Mnist_data/t10k-images-idx3-ubyte.gz
Extracting Mnist_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
File "fully_connected_feed.py", line 229, in <module>
tf.app.run()
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "fully_connected_feed.py", line 225, in main
run_training()
File "fully_connected_feed.py", line 154, in run_training
summary_op = tf.merge_all_summaries()
AttributeError: 'module' object has no attribute 'merge_all_summaries'
But the same code run successfully in other computer. So I think that must be the configuration problem in my computer.
I have followed the same steps to install tensorflow many times and use it to run Deep Learning for a period of time. But it was the first time I met such problem.
There are many suggestions in Google say such kind of AttributeError maybe the problem with python version. But it's not.
In https://stackoverflow.com/a/40066895/4533188 you can read up on an answer to a similar problem: The answer is to migrate as appropriate. Check out https://www.tensorflow.org/install/migration. There you see that
- tf.merge_summary
- should be renamed to tf.summary.merge
- tf.train.SummaryWriter
- should be renamed to tf.summary.FileWriter
(Actually SummaryWriter has also been changed.) So you should be able to solve your problem if you write before your code
import tensorflow as tf
tf.merge_all_summaries = tf.summary.merge_all
tf.train.SummaryWriter = tf.summary.FileWriter
(I had the same issue in Keras + TensorFlow: “module 'tensorflow' has no attribute 'merge_all_summaries''”.)
I have solven this problem with the help of teammates.
It's the tensorflow versions problem.
Tensorflow version in the former computer is 0.12.1. Tensorflow version in the computer met AttributeError is 1.0.0. This new tensorflow version has change some Python api, So the AttributeError met.
In this computer which met AttributeError:
:~$ python
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
>>> __tf.version__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '__tf' is not defined
>>> tf.__version__
'1.0.0'
>>>
In the former computer:
:~$ python
Python 2.7.13 |Anaconda 2.4.1 (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
>>> tf.__version__
'0.12.1'
>>>
You need to update depreicated Tensorflow API in the python files you are running i.e. fully_connected_feed.py
Look for tf.merge_all_summaries() and replace it with tf.summary.merge_all()
Present version of Tensorflow uses
tf.summary.merge_all()
instead of the old version which used
tf.merge_all_summaries()