region은 Cloud TPU를 만든 리전입니다.
리전 및 TPU 가용성에 관한 자세한 내용은 TPU 리전 및 영역을 참고하세요.
bucket-name은 만들려는 버킷의 이름입니다.
Cloud Storage 버킷에 파일을 작성하려면 gcloud storage cp 명령어를 사용합니다.
gcloudstoragecp-rlocal-data-dirgs://bucket-name
여기서 local-data-dir은 데이터의 로컬 경로입니다.
예를 들면 다음과 같습니다.$HOME/your-data
Cloud TPU에 Cloud Storage 액세스 권한 부여
Cloud TPU에 Cloud Storage 객체에 대한 읽기 및 쓰기 액세스 권한을 부여해야 합니다. 이렇게 하려면 Cloud TPU에서 사용하는 Cloud TPU 서비스 계정에 필요한 액세스 권한을 부여해야 합니다.
다음 섹션에서는 Cloud TPU 서비스 계정을 찾고 필요한 액세스 권한을 부여하는 방법을 보여줍니다.
Cloud TPU 서비스 계정 승인
Cloud TPU 서비스 계정을 승인하는 데 권장되는 방법은 세분화된 액세스 제어 목록(ACL)을 사용하는 것입니다. IAM 권한을 사용하여 더 광범위한 권한을 부여할 수도 있습니다.
Cloud TPU용으로 세밀하게 조정된 ACL 사용(권장)
Cloud Storage에 학습 데이터를 저장하는 경우 Cloud TPU 서비스 계정에 버킷에 대한 읽기/쓰기 권한이 있어야 합니다.
Cloud Storage FUSE를 사용하면 Cloud Storage 버킷을 로컬 파일 시스템으로 마운트하고 액세스할 수 있습니다. 이렇게 하면 애플리케이션이 표준 파일 시스템 시맨틱스를 사용하여 버킷의 객체를 읽고 쓸 수 있습니다.
Cloud Storage FUSE 작동 방식에 대한 자세한 내용과 Cloud Storage FUSE 작업이 Cloud Storage 작업에 매핑되는 방식에 대한 설명은 Cloud Storage FUSE 문서를 참조하세요. GitHub에서 gcsfuse CLI를 설치하고 버킷을 마운트하는 방법 등 Cloud Storage FUSE 사용 방법에 대한 추가 정보를 확인할 수 있습니다.
삭제
Cloud TPU에서 아직 연결을 해제하지 않았으면 연결을 해제합니다.
(vm)$exit
Cloud Shell에서 Cloud TPU를 삭제합니다.
gcloudcomputetpustpu-vmdeletetpu-name--zone=zone
gcloud compute tpus tpu-vm list를 실행하여 VM이 삭제되었는지 확인합니다. 삭제하는 데 몇 분 정도 걸릴 수 있습니다.
gcloudcomputetpustpu-vmlist--zone=zone
다음과 같은 응답이 나타나면 인스턴스가 성공적으로 삭제되었다는 의미입니다.
Listed0items
다음 명령어를 실행하여 Cloud Storage 버킷과 콘텐츠를 삭제하고, bucket-name을 생성한 버킷의 이름으로 바꿉니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Connecting to Cloud Storage Buckets\n===================================\n\nThis page introduces [Cloud Storage](/storage/docs) as an option for storing your\nmachine learning data and training output, and describes how to give your\nCloud TPU access to the data objects on Cloud Storage.\n\nBefore you begin\n----------------\n\nYou need a Cloud TPU [service account](/iam/docs/service-accounts)\nin order to access a Cloud Storage\nbucket.\n| **Note:** Once you set up a service account for your project, it stays set while the project is active; you don't have to set up the service account every time you run a training workload in the same project.\n\n1. Create a Cloud TPU service account for your project.\n\n ```bash\n gcloud beta services identity create --service tpu.googleapis.com --project project-id\n ```\n\n The command returns a Cloud TPU service account with following format: \n\n ```\n service-project-number@cloud-tpu.iam.gserviceaccount.com\n ```\n | **Important:** This command creates a [service agent](/iam/docs/service-agents), a special type of Google-managed service account which is not listed in your Service accounts page in the Google Cloud console.\n2. Follow the instructions found in either the\n [Cloud TPU quickstart guides](/tpu/docs/quickstart) or\n [Manage TPUs](/tpu/docs/managing-tpus-tpu-vm)\n to configure your Google Cloud project and create your Cloud TPU\n VM and TPU resources.\n\nWrite data to Cloud Storage\n---------------------------\n\n**Note:** Set up the Cloud Storage bucket in the same location (region) that you set up the Cloud TPU. See [Create buckets](/storage/docs/creating-buckets) for all options available for managing storage buckets. \n\n### Console\n\n1. Go to the Cloud Storage page on the Google Cloud console.\n\n [Go to the Cloud Storage page](https://console.cloud.google.com/storage/browser)\n2. Create a new bucket, specifying the following options:\n\n - A unique name of your choosing.\n - Default storage class: `Standard`\n - Location: The region where you created the Cloud TPU. For more information about regions and TPU availability, see [TPU regions and zones](/tpu/docs/regions-zones).\n\n### CLI\n\n1. Use the `gcloud storage buckets create` command to create a Cloud Storage bucket:\n\n ```bash\n gcloud storage buckets create gs://bucket-name --location region\n ```\n\n where:\n - \u003cvar translate=\"no\"\u003eregion\u003c/var\u003e is the region where you created the Cloud TPU.\n For more information about regions and TPU availability, see\n [TPU regions and zones](/tpu/docs/regions-zones).\n\n - \u003cvar translate=\"no\"\u003ebucket-name\u003c/var\u003e is the name of the bucket you want to create.\n\n2. Use the `gcloud storage cp` command to write files to the Cloud Storage bucket:\n\n ```bash\n gcloud storage cp -r local-data-dir gs://bucket-name\n ```\n\n where \u003cvar translate=\"no\"\u003elocal-data-dir\u003c/var\u003e is a local path to your data.\n For example:`$HOME/your-data`\n\nGive your Cloud TPU access to Cloud Storage\n-------------------------------------------\n\nYou need to give your Cloud TPU read and write access to your\nCloud Storage objects. To do that, you must grant the required access to\nthe Cloud TPU service account used by the Cloud TPU.\nThe following sections show how to find the Cloud TPU service account and\ngrant the necessary access.\n\n### Authorize the Cloud TPU service account\n\nThe recommended way to authorize the Cloud TPU service account is by using\n[fine-grained access control lists (ACLs)](#fine-grained-acl). You can also grant\nbroader permissions using [IAM permissions](#iam-permissions).\n\n#### Using fine-grained ACLs for Cloud TPU (Recommended)\n\nIf you store training data on Cloud Storage, the Cloud TPU\nservice account needs read and write permission on the bucket. \n\n### Console\n\n1. Go to the Cloud Storage browser page to view the buckets you own.\n\n [Go to the Cloud Storage browser](https://console.cloud.google.com/storage/browser)\n\n \u003cbr /\u003e\n\n2. Select the bucket whose ACL you want to modify.\n\n3. Select the **Permissions** tab.\n\n4. Select **Grant access** to add a new permission and type the complete service account\n name in the **New principals** edit box.\n\n5. If you are *reading* from this bucket, you must authorize the TPU Service\n Account to read from the resource. Do this by granting the Service\n Account the `Storage Legacy \u003e Storage Legacy Bucket Reader` role.\n\n6. If you are *writing* to this bucket, you must authorize the TPU Service\n Account to write to the resource. Do this by granting the Service\n Account the `Storage Legacy \u003e Storage Legacy Bucket Writer` role.\n\n### CLI\n\n1. If you are *reading* from this bucket, grant read permission for\n the Cloud TPU service account:\n\n \u003cbr /\u003e\n\n ```bash\n gcloud storage buckets add-iam-policy-binding gs://bucket-name --member=serviceAccount:service-account --role=roles/storage.objectViewer\n \n ```\n\n \u003cbr /\u003e\n\n2. If you are *writing* to this bucket, grant write permission for\n the Cloud TPU service account:\n\n \u003cbr /\u003e\n\n ```bash\n gcloud storage buckets add-iam-policy-binding gs://bucket-name --member=serviceAccount:service-account --role=roles/storage.objectCreator\n ```\n\n \u003cbr /\u003e\n\n#### Using IAM permissions for Cloud TPU (Alternative)\n\nIf you want to grant broader permissions instead of granting access to each\nbucket explicitly, you can grant the Identity Access Management (IAM) Storage\nAdmin role to the Cloud TPU service account.\n\n1. [Go to IAM](https://console.cloud.google.com/iam-admin/iam)\n\n2. Click the **Grant access** button to add principals to the project.\n\n3. Enter the names of the Cloud TPU service account in the\n **Principals** text box.\n\n4. Click the **Roles** dropdown list.\n\n5. Enable the following roles:\n\n - **Project \\\u003e Viewer**\n\n - **Storage \\\u003e Storage Admin**\n\n### Cloud Storage FUSE\n\nCloud Storage FUSE allows you to\nmount and access Cloud Storage buckets as local file systems. This allows\napplications to read and write objects in your bucket using standard\nfile system semantics.\n\nSee the [Cloud Storage FUSE documentation](/storage/docs/gcs-fuse)\nfor details about how Cloud Storage FUSE works and a description of how\nCloud Storage FUSE operations map to Cloud Storage operations. You can find\nadditional information about how to use Cloud Storage FUSE, such as how to\ninstall the gcsfuse CLI and mounting buckets on\n[GitHub.](https://github.com/GoogleCloudPlatform/gcsfuse/tree/master/docs)\n\nClean up\n--------\n\n1. Disconnect from the Cloud TPU, if you have not already done so:\n\n ```bash\n (vm)$ exit\n ```\n2. In your Cloud Shell, delete the Cloud TPU:\n\n ```bash\n gcloud compute tpus tpu-vm delete tpu-name --zone=zone\n ```\n3. Verify the VM has been deleted by running `gcloud compute tpus tpu-vm list`. The\n deletion might take several minutes.\n\n ```bash\n gcloud compute tpus tpu-vm list --zone=zone\n ```\n\n A response like the following indicates your instances have been\n successfully deleted. \n\n Listed 0 items\n\n4. Run the following command to delete the Cloud Storage bucket and its\n contents, replacing \u003cvar translate=\"no\"\u003ebucket-name\u003c/var\u003e with the name of the bucket you\n created:\n\n ```bash\n gcloud storage rm --recursive gs://bucket-name\n ```\n\nWhat's next\n-----------\n\n- For more information about creating Cloud Storage buckets and writing data to those buckets, see the [Cloud Storage create buckets\n documentation](/storage/docs/creating-buckets).\n- For more information about service accounts, see the [authentication overview](/docs/authentication)."]]