【问题标题】:Connecting to local runtime google colab with GPU needs tensorflow-gpu?使用 GPU 连接到本地运行时 google colab 需要 tensorflow-gpu?
【发布时间】:2023-04-07 08:38:01
【问题描述】:

我的电脑没有安装 GPU,为了加快执行速度,我想通过连接到本地运行时使用 google colab 建议的 GPU(因为我使用的数据集太大而无法上传到 google 驱动器上)。我在我的电脑上安装了正常的 tensorflow,当我尝试在带有 GPU 的 google colab 上运行我的代码时,速度没有变化。为了能够使用 google colab GPU,我需要在我的电脑上安装 tensorflow-gpu 吗? tensorflow-gpu的版本必须和tensorflow一样?

【问题讨论】:

    标签: python tensorflow gpu google-colaboratory


    【解决方案1】:

    您需要在 Google Colab 中为笔记本启用 GPUs

    导航到Edit 并选择Notebook Settings

    Hardware Accelerator 下拉列表中选择GPU

    之后,您可以通过运行以下代码来确认我们使用 tensorflow 连接到 GPU:

    %tensorflow_version 2.x
    import tensorflow as tf
    device_name = tf.test.gpu_device_name()
    if device_name != '/device:GPU:0':
      raise SystemError('GPU device not found')
    print('Found GPU at: {}'.format(device_name))
    

    输出:

    TensorFlow 2.x selected.
    Found GPU at: /device:GPU:0
    

    请参考Google Colab建议的linklocal runtime联系,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 2022-08-15
      • 2019-04-29
      • 1970-01-01
      • 2018-09-26
      • 1970-01-01
      • 2021-08-13
      相关资源
      最近更新 更多