首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google TPU节点资源名称

Google TPU节点资源名称
EN

Stack Overflow用户
提问于 2022-02-21 23:10:28
回答 1查看 193关注 0票数 3

我试图使用TPU客户端API创建Google节点,但我无法确定Google中TPU节点的父资源名称。

下面可以找到我用来创建节点的完整代码,我很难理解什么应该是parent类的CreateNodeRequest属性的值:

代码语言:javascript
复制
def create_tpu_node(parent_resource_name, node_name, accelerator_type, runtime_version):
# Create a client
client = tpu_v2alpha1.TpuClient()

# Initialize request argument(s)
node = tpu_v2alpha1.Node()
node.name = node_name
node.accelerator_type = accelerator_type
node.runtime_version = runtime_version

request = tpu_v2alpha1.CreateNodeRequest(
    parent=parent_resource_name,
    node=node,
)

# Make the request
operation = client.create_node(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
return response

在其他组合中,我尝试了这些父资源名称:

  1. projects/my-project-id/zones/europe-west4-a/tpus
  2. 我的项目-id/zone/欧洲-West4-a/tpus

而我总是分别得到以下错误之一:

代码语言:javascript
复制
google.api_core.exceptions.InvalidArgument: 400 Malformed name: 'projects/my-project-id/zones/europe-west4-a/tpus/nodes/'

代码语言:javascript
复制
google.api_core.exceptions.InvalidArgument: 400 Invalid resource field value in the request.

我真的不知道如何获得TPU节点父资源名称,甚至是TPU节点资源名称。任何帮助都将不胜感激!

编辑:我还尝试使用以下父资源名称projects/my-project-id/locations/europe-west4-a,但仍然得到了下面的gRPC错误:

代码语言:javascript
复制
status = StatusCode.INVALID_ARGUMENT details = "Malformed name: 'projects/my-project-id/locations/europe-west4-a/nodes/'" debug_error_string = "{"created":"@1645875905.514000000","description":"Error received from peer ipv4:142.251.36.42:443","file":"src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"Malformed name: 'projects/my-project-id/locations/europe-west4-a/nodes/'","grpc_status":3}
EN

回答 1

Stack Overflow用户

发布于 2022-02-23 22:20:41

您可以在基础API方法的文档中找到parent的预期格式:projects.locations.nodes.create

parent应该被格式化为projects/*/locations/*。也就是说,将zones更改为locations并从末尾删除/tpus

编辑:在下面添加一些示例代码

我在云壳上完全尝试了以下操作(除了项目名和TPU名称)

代码语言:javascript
复制
from google.cloud import tpu_v2alpha1

req = tpu_v2alpha1.CreateNodeRequest(
  parent='projects/my-project-id/locations/europe-west4-a', 
  node_id='test-tpu',
  node=tpu_v2alpha1.Node(
    accelerator_type='v2-8',
    runtime_version='v2-alpha',
    network_config=tpu_v2alpha1.NetworkConfig(
      enable_external_ips=True)))

op = client.create_node(req)
# Shows TPU created successfully
op.result()

我使用google-cloud-tpu包在1.3.2上运行了这个示例

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71214083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档