Node
A Cloud TPU instance. To get more information about Node, see:
How-to Guides
Example Usage
Tpu Node Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const available = gcp.tpu.getTensorflowVersions({});
const tpu = new gcp.tpu.Node("tpu", {
name: "test-tpu",
zone: "us-central1-b",
acceleratorType: "v3-8",
tensorflowVersion: available.then(available => available.versions?.[0]),
cidrBlock: "10.2.0.0/29",
});
import pulumi
import pulumi_gcp as gcp
available = gcp.tpu.get_tensorflow_versions()
tpu = gcp.tpu.Node("tpu",
name="test-tpu",
zone="us-central1-b",
accelerator_type="v3-8",
tensorflow_version=available.versions[0],
cidr_block="10.2.0.0/29")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var available = Gcp.Tpu.GetTensorflowVersions.Invoke();
var tpu = new Gcp.Tpu.Node("tpu", new()
{
Name = "test-tpu",
Zone = "us-central1-b",
AcceleratorType = "v3-8",
TensorflowVersion = available.Apply(getTensorflowVersionsResult => getTensorflowVersionsResult.Versions[0]),
CidrBlock = "10.2.0.0/29",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/tpu"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
available, err := tpu.GetTensorflowVersions(ctx, nil, nil)
if err != nil {
return err
}
_, err = tpu.NewNode(ctx, "tpu", &tpu.NodeArgs{
Name: pulumi.String("test-tpu"),
Zone: pulumi.String("us-central1-b"),
AcceleratorType: pulumi.String("v3-8"),
TensorflowVersion: pulumi.String(available.Versions[0]),
CidrBlock: pulumi.String("10.2.0.0/29"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.tpu.TpuFunctions;
import com.pulumi.gcp.tpu.inputs.GetTensorflowVersionsArgs;
import com.pulumi.gcp.tpu.Node;
import com.pulumi.gcp.tpu.NodeArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var available = TpuFunctions.getTensorflowVersions();
var tpu = new Node("tpu", NodeArgs.builder()
.name("test-tpu")
.zone("us-central1-b")
.acceleratorType("v3-8")
.tensorflowVersion(available.applyValue(getTensorflowVersionsResult -> getTensorflowVersionsResult.versions()[0]))
.cidrBlock("10.2.0.0/29")
.build());
}
}
resources:
tpu:
type: gcp:tpu:Node
properties:
name: test-tpu
zone: us-central1-b
acceleratorType: v3-8
tensorflowVersion: ${available.versions[0]}
cidrBlock: 10.2.0.0/29
variables:
available:
fn::invoke:
Function: gcp:tpu:getTensorflowVersions
Arguments: {}
Tpu Node Full
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const available = gcp.tpu.getTensorflowVersions({});
const network = new gcp.compute.Network("network", {name: "tpu-node-network"});
const serviceRange = new gcp.compute.GlobalAddress("service_range", {
name: "my-global-address",
purpose: "VPC_PEERING",
addressType: "INTERNAL",
prefixLength: 16,
network: network.id,
});
const privateServiceConnection = new gcp.servicenetworking.Connection("private_service_connection", {
network: network.id,
service: "servicenetworking.googleapis.com",
reservedPeeringRanges: [serviceRange.name],
});
const tpu = new gcp.tpu.Node("tpu", {
name: "test-tpu",
zone: "us-central1-b",
acceleratorType: "v3-8",
tensorflowVersion: available.then(available => available.versions?.[0]),
description: "Google Provider test TPU",
useServiceNetworking: true,
network: privateServiceConnection.network,
labels: {
foo: "bar",
},
schedulingConfig: {
preemptible: true,
},
});
import pulumi
import pulumi_gcp as gcp
available = gcp.tpu.get_tensorflow_versions()
network = gcp.compute.Network("network", name="tpu-node-network")
service_range = gcp.compute.GlobalAddress("service_range",
name="my-global-address",
purpose="VPC_PEERING",
address_type="INTERNAL",
prefix_length=16,
network=network.id)
private_service_connection = gcp.servicenetworking.Connection("private_service_connection",
network=network.id,
service="servicenetworking.googleapis.com",
reserved_peering_ranges=[service_range.name])
tpu = gcp.tpu.Node("tpu",
name="test-tpu",
zone="us-central1-b",
accelerator_type="v3-8",
tensorflow_version=available.versions[0],
description="Google Provider test TPU",
use_service_networking=True,
network=private_service_connection.network,
labels={
"foo": "bar",
},
scheduling_config={
"preemptible": True,
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var available = Gcp.Tpu.GetTensorflowVersions.Invoke();
var network = new Gcp.Compute.Network("network", new()
{
Name = "tpu-node-network",
});
var serviceRange = new Gcp.Compute.GlobalAddress("service_range", new()
{
Name = "my-global-address",
Purpose = "VPC_PEERING",
AddressType = "INTERNAL",
PrefixLength = 16,
Network = network.Id,
});
var privateServiceConnection = new Gcp.ServiceNetworking.Connection("private_service_connection", new()
{
Network = network.Id,
Service = "servicenetworking.googleapis.com",
ReservedPeeringRanges = new[]
{
serviceRange.Name,
},
});
var tpu = new Gcp.Tpu.Node("tpu", new()
{
Name = "test-tpu",
Zone = "us-central1-b",
AcceleratorType = "v3-8",
TensorflowVersion = available.Apply(getTensorflowVersionsResult => getTensorflowVersionsResult.Versions[0]),
Description = "Google Provider test TPU",
UseServiceNetworking = true,
Network = privateServiceConnection.Network,
Labels =
{
{ "foo", "bar" },
},
SchedulingConfig = new Gcp.Tpu.Inputs.NodeSchedulingConfigArgs
{
Preemptible = true,
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/tpu"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
available, err := tpu.GetTensorflowVersions(ctx, nil, nil)
if err != nil {
return err
}
network, err := compute.NewNetwork(ctx, "network", &compute.NetworkArgs{
Name: pulumi.String("tpu-node-network"),
})
if err != nil {
return err
}
serviceRange, err := compute.NewGlobalAddress(ctx, "service_range", &compute.GlobalAddressArgs{
Name: pulumi.String("my-global-address"),
Purpose: pulumi.String("VPC_PEERING"),
AddressType: pulumi.String("INTERNAL"),
PrefixLength: pulumi.Int(16),
Network: network.ID(),
})
if err != nil {
return err
}
privateServiceConnection, err := servicenetworking.NewConnection(ctx, "private_service_connection", &servicenetworking.ConnectionArgs{
Network: network.ID(),
Service: pulumi.String("servicenetworking.googleapis.com"),
ReservedPeeringRanges: pulumi.StringArray{
serviceRange.Name,
},
})
if err != nil {
return err
}
_, err = tpu.NewNode(ctx, "tpu", &tpu.NodeArgs{
Name: pulumi.String("test-tpu"),
Zone: pulumi.String("us-central1-b"),
AcceleratorType: pulumi.String("v3-8"),
TensorflowVersion: pulumi.String(available.Versions[0]),
Description: pulumi.String("Google Provider test TPU"),
UseServiceNetworking: pulumi.Bool(true),
Network: privateServiceConnection.Network,
Labels: pulumi.StringMap{
"foo": pulumi.String("bar"),
},
SchedulingConfig: &tpu.NodeSchedulingConfigArgs{
Preemptible: pulumi.Bool(true),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.tpu.TpuFunctions;
import com.pulumi.gcp.tpu.inputs.GetTensorflowVersionsArgs;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.GlobalAddress;
import com.pulumi.gcp.compute.GlobalAddressArgs;
import com.pulumi.gcp.servicenetworking.Connection;
import com.pulumi.gcp.servicenetworking.ConnectionArgs;
import com.pulumi.gcp.tpu.Node;
import com.pulumi.gcp.tpu.NodeArgs;
import com.pulumi.gcp.tpu.inputs.NodeSchedulingConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var available = TpuFunctions.getTensorflowVersions();
var network = new Network("network", NetworkArgs.builder()
.name("tpu-node-network")
.build());
var serviceRange = new GlobalAddress("serviceRange", GlobalAddressArgs.builder()
.name("my-global-address")
.purpose("VPC_PEERING")
.addressType("INTERNAL")
.prefixLength(16)
.network(network.id())
.build());
var privateServiceConnection = new Connection("privateServiceConnection", ConnectionArgs.builder()
.network(network.id())
.service("servicenetworking.googleapis.com")
.reservedPeeringRanges(serviceRange.name())
.build());
var tpu = new Node("tpu", NodeArgs.builder()
.name("test-tpu")
.zone("us-central1-b")
.acceleratorType("v3-8")
.tensorflowVersion(available.applyValue(getTensorflowVersionsResult -> getTensorflowVersionsResult.versions()[0]))
.description("Google Provider test TPU")
.useServiceNetworking(true)
.network(privateServiceConnection.network())
.labels(Map.of("foo", "bar"))
.schedulingConfig(NodeSchedulingConfigArgs.builder()
.preemptible(true)
.build())
.build());
}
}
resources:
tpu:
type: gcp:tpu:Node
properties:
name: test-tpu
zone: us-central1-b
acceleratorType: v3-8
tensorflowVersion: ${available.versions[0]}
description: Google Provider test TPU
useServiceNetworking: true
network: ${privateServiceConnection.network}
labels:
foo: bar
schedulingConfig:
preemptible: true
network:
type: gcp:compute:Network
properties:
name: tpu-node-network
serviceRange:
type: gcp:compute:GlobalAddress
name: service_range
properties:
name: my-global-address
purpose: VPC_PEERING
addressType: INTERNAL
prefixLength: 16
network: ${network.id}
privateServiceConnection:
type: gcp:servicenetworking:Connection
name: private_service_connection
properties:
network: ${network.id}
service: servicenetworking.googleapis.com
reservedPeeringRanges:
- ${serviceRange.name}
variables:
available:
fn::invoke:
Function: gcp:tpu:getTensorflowVersions
Arguments: {}
Import
Node can be imported using any of these accepted formats:
projects/{{project}}/locations/{{zone}}/nodes/{{name}}
{{project}}/{{zone}}/{{name}}
{{zone}}/{{name}}
{{name}}
When using thepulumi import
command, Node can be imported using one of the formats above. For example:
$ pulumi import gcp:tpu/node:Node default projects/{{project}}/locations/{{zone}}/nodes/{{name}}
$ pulumi import gcp:tpu/node:Node default {{project}}/{{zone}}/{{name}}
$ pulumi import gcp:tpu/node:Node default {{zone}}/{{name}}
$ pulumi import gcp:tpu/node:Node default {{name}}
Properties
The type of hardware accelerators associated with this node.
The CIDR block that the TPU node will use when selecting an IP address. This CIDR block must be a /29 block; the Compute Engine networks API forbids a smaller block, and using a larger block would be wasteful (a node can only consume one IP address). Errors will occur if the CIDR block has already been used for a currently existing TPU node, the CIDR block conflicts with any subnetworks in the user's provided network, or the provided network is peered with another network that is using that CIDR block.
The user-supplied description of the TPU. Maximum of 512 characters.
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
The network endpoints where TPU workers can be accessed and sent work. It is recommended that Tensorflow clients of the node first reach out to the first (index 0) entry. Structure is documented below.
The combination of labels configured directly on the resource and default labels configured on the provider.
Sets the scheduling options for this TPU instance. Structure is documented below.
The service account used to run the tensor flow services within the node. To share resources, including Google Cloud Storage data, with the Tensorflow job running in the Node, this account must have permissions to that data.
The version of Tensorflow running in the Node.
Whether the VPC peering for the node is set up through Service Networking API. The VPC Peering should be set up before provisioning the node. If this field is set, cidr_block field should not be specified. If the network that you want to peer the TPU Node to is a Shared VPC network, the node must be created with this this field enabled.