【问题标题】:Missing XLA configuration when running pytorch/xla运行 pytorch/xla 时缺少 XLA 配置
【发布时间】:2020-12-08 16:29:11
【问题描述】:

我正在尝试使用 Pytorch/XLA 运行 GCP TPU,我正在使用带有 debian-9-torch-xla-v20200818 映像的 VM,我启动 TPU 并使用 ctpu 状态检查它是否正在运行,这表明两个 CPU并且 TPU 正在运行,然后我激活了 torch-xla-nightly 环境,但是当我尝试调用这个简单的代码时:

import torch
import torch_xla
import torch_xla.core.xla_model as xm

dev = xm.xla_device()
t1 = torch.ones(3, 3, device = dev)
print(t1)

出现此错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/core/xla_model.py", line 231, in xla_device
devkind=devkind if devkind is not None else None)
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/core/xla_model.py", line 136, in get_xla_supported_devices
 xla_devices = _DEVICES.value
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/utils/utils.py", line 32, in value
self._value = self._gen_fn()
File "/anaconda3/envs/torch-xla-nightly/lib/python3.6/site-packages/torch_xla/core/xla_model.py", line 18, in <lambda>
_DEVICES = xu.LazyProperty(lambda: torch_xla._XLAC._xla_get_devices())
RuntimeError: tensorflow/compiler/xla/xla_client/computation_client.cc:274 : Missing XLA configuration

我尝试了所有方法,但似乎没有任何效果。

【问题讨论】:

  • 看看this link,因为它似乎与问题有关。也许你没有设置 XRT_TPU_CONFIG: (vm)$ export XRT_TPU_CONFIG="tpu_worker;0;$TPU_IP_ADDRESS:8470" 按照说明here 你应该没问题
  • 确实是这个问题,非常感谢。

标签: google-cloud-platform pytorch tpu


【解决方案1】:

看看this link,因为它似乎与该问题有关。也许你没有设置 XRT_TPU_CONFIG: (vm)$ export XRT_TPU_CONFIG="tpu_worker;0;$TPU_IP_ADDRESS:8470" 按照here 的说明进行操作,应该没问题。

【讨论】:

    【解决方案2】:

    如果您看到XRT_TPU_CONFIG 设置正确,另一种可能性是您忘记使用适当的scopes 启动您的实例:

    gcloud compute instances create ... --scopes=https://www.googleapis.com/auth/cloud-platform
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 2020-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多