Im trying to create a Google Cloud TPU node using TPU client API and I cannot figure out the parent resource name of a TPU node in Google Cloud.
Below you can find the full code I'm using to create the node and I'm struggling to understand wht should be the value of the parent attribute of the CreateNodeRequest class:
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
I have tried these parent resource names, among other combinations:
And I always get, respectively, one of the following errors:
google.api_core.exceptions.InvalidArgument: 400 Malformed name: 'projects/my-project-id/zones/europe-west4-a/tpus/nodes/'
or
google.api_core.exceptions.InvalidArgument: 400 Invalid resource field value in the request.
I really have no clue how to get the TPU node parent resource name, or even a TPU node resource name. Any help would be much appreciated!
EDIT: I also tried with the following parent resource name projects/my-project-id/locations/europe-west4-a, and I still get the gRPC error below:
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}
You can find the expected format of parent in the documentation for the underlying API method: projects.locations.nodes.create.
parent should be formatted as projects/*/locations/*. That is, change zones to locations and remove the /tpus from the end.
Edit: adding some example code below
I tried exactly the following (except for project and TPU names) on a Cloud Shell:
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()
I ran this example with the google-cloud-tpu package at 1.3.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With