MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

tpu/createTopologyVM.js:19–97  ·  view source on GitHub ↗
(tpuClient)

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main(tpuClient) {
20 // [START tpu_vm_create_topology]
21 // Import the TPUClient
22 // TODO(developer): Uncomment below line before running the sample.
23 // const {TpuClient} = require('@google-cloud/tpu').v2;
24
25 const {Node, NetworkConfig, AcceleratorConfig} =
26 require('@google-cloud/tpu').protos.google.cloud.tpu.v2;
27
28 // Instantiate a tpuClient
29 // TODO(developer): Uncomment below line before running the sample.
30 // tpuClient = new TpuClient();
31
32 /**
33 * TODO(developer): Update these variables before running the sample.
34 */
35 // Project ID or project number of the Google Cloud project you want to create a node.
36 const projectId = await tpuClient.getProjectId();
37
38 // The name of the network you want the TPU node to connect to. The network should be assigned to your project.
39 const networkName = 'compute-tpu-network';
40
41 // The region of the network, that you want the TPU node to connect to.
42 const region = 'europe-west4';
43
44 // The name for your TPU.
45 const nodeName = 'node-name-1';
46
47 // The zone in which to create the TPU.
48 // For more information about supported TPU types for specific zones,
49 // see https://cloud.google.com/tpu/docs/regions-zones
50 const zone = 'europe-west4-a';
51
52 // Software version that specifies the version of the TPU runtime to install. For more information,
53 // see https://cloud.google.com/tpu/docs/runtimes
54 const tpuSoftwareVersion = 'v2-tpuv5-litepod';
55
56 // The version of the Cloud TPU you want to create.
57 // Available options: TYPE_UNSPECIFIED = 0, V2 = 2, V3 = 4, V4 = 7
58 const tpuVersion = AcceleratorConfig.Type.V2;
59
60 // The physical topology of your TPU slice.
61 // For more information about topology for each TPU version,
62 // see https://cloud.google.com/tpu/docs/system-architecture-tpu-vm#versions.
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}`,

Callers

nothing calls this directly

Calls 2

callCreateTpuVMTopologyFunction · 0.85
getProjectIdMethod · 0.80

Tested by

no test coverage detected