【发布时间】:2019-11-19 12:14:31
【问题描述】:
我正在尝试使用 gcloud 提交一份在 ML-Engine 中进行培训的作业,但我遇到了我无法弄清楚的服务帐户权限错误。模型代码存在于一个 Compute Engine 实例上,我在该实例中运行 gcloud ml-engine jobs submit 作为 bash 脚本的一部分。我为 VM 实例上的 gcloud 身份验证创建了一个服务帐户 (ai-platform-developer@..iam.gserviceaccount.com),并为作业和模型数据创建了一个存储桶。服务帐号已被授予存储桶的存储对象查看者和存储对象创建者角色,并且虚拟机和存储桶都属于同一个项目。
当我尝试根据this tutorial 提交作业时,会执行以下操作:
time_stamp=`date +"%Y%m%d_%H%M"`
job_name='ObjectDetection_'${time_stamp}
gsutil cp object_detection/samples/configs/faster_rcnn_resnet50.config
gs://[bucket-name]/training_configs/faster-rcnn-resnet50.${job_name}.config
gcloud ml-engine jobs submit training ${job_name} \
--project [project-name] \
--runtime-version 1.12 \
--job-dir=gs://[bucket-name]/jobs/${job_name} \
--packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz \
--module-name object_detection.model_main \
--region us-central1 \
--config object_detection/training-config.yml \
-- \
--model_dir=gs://[bucket-name]/output/${job_name}} \
--pipeline_config_path=gs://[bucket-name]/training_configs/faster-rcnn-resnet50.${job_name}.config
其中 [bucket-name] 和 [project-name] 是上面创建的存储桶以及它和虚拟机所在的项目的占位符。
配置文件已成功上传到存储桶,我可以在云控制台中确认它存在。但是,作业无法提交并出现以下错误:
ERROR: (gcloud.ml-engine.jobs.submit.training) User [ai-platform-developer@....iam.gserviceaccount.com] does not have permission to access project [project-name] (or it may not exist): Field: job_dir Error: You don't have the permission to access the provided directory 'gs://[bucket-name]/jobs/ObjectDetection_20190709_2001'
- '@type': type.googleapis.com/google.rpc.BadRequest
fieldViolations:
- description: You don't have the permission to access the provided directory 'gs://[bucket-name]/jobs/ObjectDetection_20190709_2001'
field: job_dir
如果我查看云控制台,--packages 指定的文件存在于该位置,并且我已确保服务帐户 ai-platform-developer@....iam.gserviceaccount.com 已被赋予存储桶的存储对象查看者和存储对象创建者角色,这已设置存储桶级别权限。确保服务帐号已激活且默认后,我也可以运行
gsutil ls gs://[bucket-name]/jobs/ObjectDetection_20190709_2001
成功返回文件夹的内容而没有权限错误。在该项目中,存在一个托管服务帐户service-[project-number]@cloud-ml.google.com.iam.gserviceaccount.com,并且我还在存储桶上授予了该帐户的Storage Object Viewer 和Storage Object Creator 角色。
为确认此 VM 能够提交作业,我可以将 gcloud 用户切换到我的个人帐户,然后脚本运行并提交作业而没有任何错误。但是,由于这存在于共享 VM 中,我想依靠服务帐户授权而不是我自己的用户帐户。
【问题讨论】:
标签: google-cloud-storage gcloud google-cloud-ml