使用GPU连接到本地运行时google colab需要tensorflow-gpu?

问题描述 投票:0回答:2

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

python tensorflow gpu google-colaboratory
2个回答
0
投票

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

GPUs

导航至

Edit
并选择
Notebook Settings

GPU
下拉列表中选择
Hardware Accelerator

之后,您可以通过运行以下代码来确认我们已使用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建议的

链接
local runtime
,

联系

0
投票

如果您在 Google Colab 中使用本地运行时,则您依赖于本地硬件,因此在您的情况下,不需要您提到的 GPU。 在任何情况下,Colab 本地运行时都会在本地计算机上使用Jupyter运行时或docker运行时,因此无需再安装任何内容,因为配置由这些运行时提供。

© www.soinside.com 2019 - 2024. All rights reserved.