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

时间:2022-03-25 20:26:56

The title says it all. I'm using Ubuntu 16.04 Long Term Support.

标题说明了一切。我正在使用Ubuntu 16.04长期支持。

10 个解决方案

#1


188  

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.

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


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.

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

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

点子列表| grep tensorflow for Python 2或pip3 list | Python 3的grep tensorflow也将显示安装的Tensorflow版本。


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.

点子列表| grep tensorflow还将显示已安装的Tensorflow版本。

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

例如,我已经在Python 3的virtualenv中安装了TensorFlow 0.9.0。所以,我得到:

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

$ pip list | grep tensorflow
tensorflow (0.9.0)

#2


30  

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

几乎python中的每个普通包都将变量.__ version__赋给当前版本。因此,如果您想查找某个软件包的版本,可以执行以下操作

import a
a.__version__

For tensorflow it will be

对于张量流,它将是

import tensorflow as tf
tf.__version__

#3


19  

import tensorflow as tf

print tf.VERSION

#4


7  

If you're using anaconda distribution of Python,

如果您正在使用anaconda分发的Python,

$ 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'

#5


5  

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:

下图显示了输出:

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

#6


5  

For python 3.6.2:

对于python 3.6.2:

import tensorflow as tf

print(tf.VERSION)

#7


3  

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

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

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

#8


3  

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

#9


1  

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

Here -c represents program passed in as string (terminates option list)

这里-c表示以字符串形式传入的程序(终止选项列表)

#10


-3  

For Python 3.6.3:

对于Python 3.6.3:

import tensorflow as tf

print tf.VERSION

#1


188  

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.

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


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.

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

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

点子列表| grep tensorflow for Python 2或pip3 list | Python 3的grep tensorflow也将显示安装的Tensorflow版本。


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.

点子列表| grep tensorflow还将显示已安装的Tensorflow版本。

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

例如,我已经在Python 3的virtualenv中安装了TensorFlow 0.9.0。所以,我得到:

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

$ pip list | grep tensorflow
tensorflow (0.9.0)

#2


30  

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

几乎python中的每个普通包都将变量.__ version__赋给当前版本。因此,如果您想查找某个软件包的版本,可以执行以下操作

import a
a.__version__

For tensorflow it will be

对于张量流,它将是

import tensorflow as tf
tf.__version__

#3


19  

import tensorflow as tf

print tf.VERSION

#4


7  

If you're using anaconda distribution of Python,

如果您正在使用anaconda分发的Python,

$ 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'

#5


5  

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:

下图显示了输出:

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

#6


5  

For python 3.6.2:

对于python 3.6.2:

import tensorflow as tf

print(tf.VERSION)

#7


3  

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

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

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

#8


3  

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

#9


1  

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

Here -c represents program passed in as string (terminates option list)

这里-c表示以字符串形式传入的程序(终止选项列表)

#10


-3  

For Python 3.6.3:

对于Python 3.6.3:

import tensorflow as tf

print tf.VERSION