【问题标题】:I want to install tensorflow version 1.14 in Google colab but failed我想在 Google colab 中安装 tensorflow 1.14 版但失败了
【发布时间】:2020-08-04 05:13:53
【问题描述】:

我需要在 Google colab 中测试一个 tf2 不支持的代码(因为 tf2 不支持 tf.ceil),所以我想在 1.14 版本中安装 tensorflow。我使用 pip3 和 pip 安装 tensorflow,都成功安装了 tf,但是当我这样做时:

import tensorflow as tf
tf.__version__

返回:

'2.2.0-rc3'

而且我有明确的 sys.path:

import sys
sys.path

返回:

[]

如何在 1.14 版本中安装 tensorflow?

【问题讨论】:

    标签: google-colaboratory


    【解决方案1】:

    如果sys.path 为空,则您的 Python 环境处于非常糟糕的状态。您应该重置您的 VM(Runtime -> Factory reset Runtime),然后运行以下命令:

    !pip install tensorflow==1.14
    

    完成此操作后,您将安装 tensorflow 1.14:

    import tensorflow
    print(tensorflow.__version__)
    
    1.14.0
    

    请注意,重置 VM 会导致您丢失当前会话中的所有程序状态。

    【讨论】:

      【解决方案2】:

      确保您使用 TF v1 的最简单方法是简单地运行

      %tensorflow_version 1.x
      

      在您导入 TensorFlow 之前行。

      Colab 已经从源代码构建 TF,因此 Google 建议不要使用 pip 安装 TF,因为您可能会遇到性能问题。

      【讨论】:

        猜你喜欢
        • 2020-04-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-29
        • 2020-11-09
        • 2021-12-28
        • 2021-01-08
        • 1970-01-01
        相关资源
        最近更新 更多