如何解决如何从VM实例内部的Docker容器将Tensorflow事件写入Google云存储
我已经在Google Compute Engine上创建了一个VM实例。上传完项目并构建了映像后,我遇到了我的容器并使用我的服务帐户授权访问Google Cloud Platform:
gcloud auth activate-service-account test@xxx.iam.gserviceaccount.com --key-file=mykey.json
以便可以访问我的Google云存储(我在存储桶中使用gsutil cp
进行了测试,并且可以正常运行)。现在我尝试执行如下的tensorflow python脚本:
python object_detection/model_main_tf2.py \
--pipeline_config_path=/raccoon/config.config \
--model_dir=gs://my-bucket/ \
--num_train_steps=10
将我的存储桶指定为model_dir,以便将检查点和事件存储在此处(以便使用我的笔记本电脑中的张量板监视训练的进度)。
问题是我从tensorflow得到以下权限错误:
tensorflow.python.framework.errors_impl.PermissionDeniedError:
Error executing an HTTP request: HTTP response code
403 with body '{
"error": {
"code": 403,"message": "Insufficient Permission","errors": [
{
"message": "Insufficient Permission","domain": "global","reason": "insufficientPermissions"
}
]
}
}
'
when initiating an upload to gs://my-bucket/train/events.out.tfevents.1601998426.266
1f74c3966.450.2928.v2
Failed to flush 1 events to gs://my-bucket/train/events.out.tfevents.1601998426.2661f
74c3966.450.2928.v2
Flushing first event.
Could not initialize events writer. [Op:CreateSummaryFileWriter]
我的存储桶中存在train
目录,正如我在执行以下命令之前所说的那样:
gsutil cp test.txt gs://my-bucket/train/.
我想念什么吗?
解决方法
验证gcloud
仅可确保将来的gcloud
命令得到验证。您的脚本(可能)未使用gcloud
,因此未通过身份验证。
相反,如果您在JSON文件中具有服务帐户凭据,则可以通过GOOGLE_APPLICATION_CREDENTIALS
环境变量进行指定,以使TensorFlow能够通过gs://
URL读取/写入GCS。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。