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

新手上路,请多包涵

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

原文由 Hans K 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 437
2 个回答

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


点安装

跑:

 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 用于 Python 2 或 pip3 list | grep tensorflow 用于 Python 3 还将显示安装的 Tensorflow 版本。


虚拟环境安装

跑:

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

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

例如,我在 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)

原文由 edwinksl 发布,翻译遵循 CC BY-SA 3.0 许可协议

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

import a
a.__version__

对于张量流,它将是

import tensorflow as tf
tf.version.VERSION

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

原文由 Salvador Dali 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题