将 TPU 与 PyTorch 结合使用

Using TPUs with PyTorch

我正在尝试使用来自 Colab 的 Google Cloud 的 TPU。我能够按照教程使用 Tensorflow 完成它。

有人知道是否可以通过 PyTorch 使用 TPU 吗? 如果是这样我该怎么做?你有什么例子吗?

目前,无法将 Cloud TPU 与 PyTorch 一起使用,因为它是专门为 Tensorflow 设计的。

但是,根据 this product news posted three days ago in the Google Cloud blog,"engineers on Google’s TPU team are actively collaborating with core PyTorch developers to connect PyTorch to Cloud TPUs"。

查看我们的存储库 pytorch/xla,您可以从中开始在 TPU 上训练 PyTorch 模型。

此外,您甚至可以在带有 PyTorch 的 Colab 上使用这些 Colab notebooks

从今天开始,PyTorch Lightning 允许 运行 在 TPU 上简单地编写 PyTorch 代码(您需要安装 XLA 库)。 来自 colab 上的演示笔记本:

from pytorch_lightning import Trainer

model = CoolSystem()

# most basic trainer, uses good defaults
trainer = Trainer(num_tpu_cores=8)
trainer.fit(model)