The Python Oracle

How to find which version of TensorFlow is installed in my system?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping

--

Chapters
00:00 Question
00:23 Accepted answer (Score 530)
01:37 Answer 2 (Score 124)
02:09 Answer 3 (Score 84)
02:24 Answer 4 (Score 34)
02:34 Thank you

--

Full question
https://stackoverflow.com/questions/3854...

Accepted answer links:
[TensorFlow's installation instructions]: https://www.tensorflow.org/versions/r0.1...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #ubuntu #tensorflow #commandline #version

#avk47



ACCEPTED ANSWER

Score 543


This depends on how you installed TensorFlow. I am going to use the same headings used by TensorFlow's installation instructions to structure this answer.


Pip installation

Run:

python -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 2
python3 -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 3

Note that python is symlinked to /usr/bin/python3 in some Linux distributions, so use python instead of python3 in these cases.

pip list | grep tensorflow for Python 2 or pip3 list | grep tensorflow for Python 3 will also show the version of Tensorflow installed.


Virtualenv installation

Run:

python -c 'import tensorflow as tf; print(tf.__version__)'  # for both Python 2 and Python 3

pip list | grep tensorflow will also show the version of Tensorflow installed.

For example, I have installed TensorFlow 0.9.0 in a virtualenv for Python 3. So, I get:

$ python -c 'import tensorflow as tf; print(tf.__version__)'
0.9.0

$ pip list | grep tensorflow
tensorflow (0.9.0)



ANSWER 2

Score 130


Almost every normal package in python assigns the variable .__version__ to the current version. So if you want to find the version of some package you can do the following

import a
a.__version__

For tensorflow it will be

import tensorflow as tf
tf.version.VERSION

For old versions of tensorflow (below 0.10), use tf.__version__




ANSWER 3

Score 34


import tensorflow as tf

print(tf.VERSION)



ANSWER 4

Score 24


For python 3.6.2:

import tensorflow as tf

print(tf.version.VERSION)