Python 如何查找我的系统中安装了哪个版本的 TensorFlow?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38549253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:07:26  来源:igfitidea点击:

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

pythonubuntutensorflowcommand-lineversion

提问by Hans Krupakar

I need to find which version of TensorFlow I have installed. I'm using Ubuntu 16.04 Long Term Support.

我需要找到我安装了哪个版本的 TensorFlow。我正在使用 Ubuntu 16.04 长期支持。

回答by edwinksl

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

这取决于您如何安装 TensorFlow。我将使用TensorFlow 安装说明使用的相同标题来构建此答案。



Pip installation

pip安装

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 pythonis symlinked to /usr/bin/python3in some Linux distributions, so use pythoninstead of python3in these cases.

请注意,在某些 Linux 发行版中使用python符号链接到/usr/bin/python3,因此在这些情况下使用python代替python3

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

pip list | grep tensorflow对于 Python 2 或pip3 list | grep tensorflowPython 3,还将显示已安装的 Tensorflow 版本。



Virtualenv installation

虚拟环境安装

Run:

跑:

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

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

pip list | grep tensorflow还将显示已安装的 Tensorflow 版本。

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

例如,我在virtualenvPython 3 的a 中安装了 TensorFlow 0.9.0 。所以,我得到:

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

$ pip list | grep tensorflow
tensorflow (0.9.0)

回答by Salvador Dali

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

几乎每个python 中的普通包都将变量.__version__或分配VERSION给当前版本。所以如果你想找到某个包的版本,你可以执行以下操作

import a
a.__version__ # or a.VERSION

For tensorflow it will be

对于张量流,它将是

import tensorflow as tf
tf.VERSION

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

对于旧版本的 tensorflow(低于 0.10),使用 tf.__version__

BTW, if you are planning to install tf, install it with conda, not pip

顺便说一句,如果您打算安装 tf,请使用 conda 而不是 pip 安装

回答by Trideep Rath

If you have installed via pip, just run the following

如果您通过 pip 安装,只需运行以下命令

$ pip show tensorflow
Name: tensorflow
Version: 1.5.0
Summary: TensorFlow helps the tensors flow

回答by Bilal

import tensorflow as tf

print(tf.VERSION)

回答by gd1

For python 3.6.2:

对于python 3.6.2:

import tensorflow as tf

print(tf.version.VERSION)

回答by kmario23

If you're using anaconda distribution of Python,

如果您使用的是 Python 的 anaconda 发行版,

$ conda list | grep tensorflow
tensorflow    1.0.0       py35_0    conda-forge

To check it using Jupyter Notebook (IPython Notebook)

使用 Jupyter Notebook (IPython Notebook) 检查它

In [1]: import tensorflow as tf
In [2]: tf.__version__
Out[2]: '1.0.0'

回答by Yuan Ma

I installed the Tensorflow 0.12rc from source, and the following command gives me the version info:

我从源代码安装了 Tensorflow 0.12rc,以下命令提供了版本信息:

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

The following figure shows the output:

下图显示了输出:

enter image description here

在此处输入图片说明

回答by jitsm555

On Latest TensorFlow release 1.14.0

在最新的 TensorFlow 版本1.14.0

tf.VERSION

版本

is deprecated, instead of this use

已弃用,而不是这种用途

tf.version.VERSION

tf.version.VERSION

ERROR:

错误:

WARNING: Logging before flag parsing goes to stderr.
The name tf.VERSION is deprecated. Please use tf.version.VERSION instead.

回答by 0xAliHn

To get more information about tensorflow and its options you can use below command:

要获取有关 tensorflow 及其选项的更多信息,您可以使用以下命令:

>> import tensorflow as tf
>> help(tf)

回答by Kevin Patel

Easily get KERAS and TENSORFLOW version number --> Run this command in terminal:

轻松获取 KERAS 和 TENSORFLOW 版本号 --> 在终端中运行此命令:

[username@usrnm:~] python3

[用户名@usrnm:~] python3

>>import keras; print(keras.__version__)

>>import keras; print(keras.__version__)

Using TensorFlow backend.

Using TensorFlow backend.

2.2.4

2.2.4

>>import tensorflow as tf; print(tf.__version__)

>>import tensorflow as tf; print(tf.__version__)

1.12.0

1.12.0