| 63 | const topology = '2x2'; |
| 64 | |
| 65 | async function callCreateTpuVMTopology() { |
| 66 | // Create a node |
| 67 | const node = new Node({ |
| 68 | name: nodeName, |
| 69 | zone, |
| 70 | // acceleratorType: tpuType, |
| 71 | runtimeVersion: tpuSoftwareVersion, |
| 72 | // Define network |
| 73 | networkConfig: new NetworkConfig({ |
| 74 | enableExternalIps: true, |
| 75 | network: `projects/${projectId}/global/networks/${networkName}`, |
| 76 | subnetwork: `projects/${projectId}/regions/${region}/subnetworks/${networkName}`, |
| 77 | }), |
| 78 | acceleratorConfig: new AcceleratorConfig({ |
| 79 | type: tpuVersion, |
| 80 | topology, |
| 81 | }), |
| 82 | }); |
| 83 | |
| 84 | const parent = `projects/${projectId}/locations/${zone}`; |
| 85 | const request = {parent, node, nodeId: nodeName}; |
| 86 | |
| 87 | const [operation] = await tpuClient.createNode(request); |
| 88 | |
| 89 | // Wait for the create operation to complete. |
| 90 | const [response] = await operation.promise(); |
| 91 | |
| 92 | console.log(JSON.stringify(response)); |
| 93 | return response; |
| 94 | } |
| 95 | return await callCreateTpuVMTopology(); |
| 96 | // [END tpu_vm_create_topology] |
| 97 | } |