Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Connecter un TPU à un réseau VPC partagé
Configurer un projet hôte VPC
Vous devez accorder au compte de service TPU de votre projet de service les autorisations nécessaires pour gérer les ressources du projet hôte.
Pour ce faire, utilisez le rôle "Agent dans le VPC partagé pour les nœuds TPU" (roles/tpu.xpnAgent). Exécutez les commandes gcloud suivantes pour accorder cette liaison de rôle.
Lorsque vous n'avez plus besoin de la VM TPU, veillez à la supprimer.
gcloudcomputetpustpu-vmdeletetpu-name--zonezone
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Connect a TPU to a Shared VPC network\n=====================================\n\n| **Important:** This guide explains how to set up Cloud TPUs that use a centrally managed [Shared VPC network](/vpc/docs/overview). This document assumes you are familiar with VPCs and have created a Shared VPC. For more information on how to create and manage Shared VPC networks, see [Create and modify Shared VPC networks](/vpc/docs/create-modify-vpc-networks).\n\nConfigure a VPC host project\n----------------------------\n\nYou need to grant the TPU Service Account\nin your [service project](/vpc/docs/shared-vpc#concepts_and_terminology)\npermissions to manage resources in the [host project](/vpc/docs/shared-vpc#concepts_and_terminology).\nYou do this using the \"TPU Shared VPC Agent\" (`roles/tpu.xpnAgent`) role. Run\nthe following `gcloud` commands to grant this role binding. \n\n```bash\ngcloud projects add-iam-policy-binding host-project-id \\\n--member=serviceAccount:service-your-service-project-number@gcp-sa-tpu.iam.gserviceaccount.com \\\n--role=roles/tpu.xpnAgent\n```\n| **Note:** You can find your service project number in the project info section of the [Google Cloud console](https://console.cloud.google.com/) dashboard.\n\nCreate a TPU VM connected to a Shared VPC Network\n-------------------------------------------------\n\nFirst determine which accelerator types and versions are available in the zone \n\n```bash\ngcloud compute tpus accelerator-types list --zone zone\n``` \n\n```bash\ngcloud compute tpus versions list --zone zone\n```\n\nYou connect a TPU VM to a Shared VPC network when you create your TPU.\nSpecify your Shared VPC using the `--network` tag: \n\n```bash\ngcloud compute tpus tpu-vm create tpu-name \\\n --zone zone \\\n --accelerator-type accelerator-type \\\n --network projects/host-project-id/global/networks/host-network \\\n --version tpu-image-version \\\n --project your-service-project-id\n```\n| **Note:** The `--network` tag must be set to the fully qualified network name. For example, `projects/`\u003cvar translate=\"no\"\u003emy-host-project-id\u003c/var\u003e`/global/networks/`\u003cvar translate=\"no\"\u003emy-network\u003c/var\u003e.\n\nYou can verify your TPU VM is connected to your Shared VPC using\nthe `gcloud describe` command: \n\n```bash\n$ gcloud compute tpus tpu-vm describe tpu-name --zone zone\n```\n\nThe response includes the network to which your TPU VM is attached: \n\n```\nacceleratorType: v3-8\napiVersion: V2\ncidrBlock: 10.128.0.0/20\ncreateTime: '2022-06-17T21:32:13.859274143Z'\nhealth: HEALTHY\nid: '0000000000000000000'\nname: projects/my-project/locations/us-central1-b/nodes/my-tpu\nnetworkConfig:\n enableExternalIps: true\n network: projects/my-project/global/networks/default\n subnetwork: projects/my-project/regions/us-central1/subnetworks/default\nnetworkEndpoints:\n- accessConfig:\n externalIp: 000.000.000.000\n ipAddress: 10.128.0.104\n port: 8470\nruntimeVersion: tpu-vm-tf-2.8.0\nschedulingConfig: {}\nserviceAccount:\n email: 00000000000-compute@developer.gserviceaccount.com\n scope:\n - https://www.googleapis.com/auth/devstorage.read_write\n - https://www.googleapis.com/auth/logging.write\n - https://www.googleapis.com/auth/service.management\n - https://www.googleapis.com/auth/servicecontrol\n - https://www.googleapis.com/auth/cloud-platform\n - https://www.googleapis.com/auth/pubsub\nshieldedInstanceConfig: {}\nstate: READY\n```\n\nDelete the TPU VM\n-----------------\n\nWhen you are done with the TPU VM, make sure to delete it. \n\n```bash\ngcloud compute tpus tpu-vm delete tpu-name --zone zone\n```"]]