Google cloud platform Can';t从GCP中的VM访问TPU
正在尝试运行此代码Google cloud platform Can';t从GCP中的VM访问TPU,google-cloud-platform,google-compute-engine,google-cloud-tpu,tpu,Google Cloud Platform,Google Compute Engine,Google Cloud Tpu,Tpu,正在尝试运行此代码 import os import tensorflow as tf from tensorflow.contrib import tpu from tensorflow.contrib.cluster_resolver import TPUClusterResolver def axy_computation(a, x, y): return a * x + y inputs = [ 3.0, tf.ones([3, 3], tf.float32
import os import tensorflow as tf from tensorflow.contrib
import tpu from tensorflow.contrib.cluster_resolver import TPUClusterResolver
def axy_computation(a, x, y): return a * x + y
inputs = [
3.0,
tf.ones([3, 3], tf.float32),
tf.ones([3, 3], tf.float32), ]
tpu_computation = tpu.rewrite(axy_computation, inputs)
tpu_grpc_url = TPUClusterResolver(
tpu=["sahil-wadhwa"], zone="us-central1-b").get_master()
with tf.Session(tpu_grpc_url) as sess:
sess.run(tpu.initialize_system())
sess.run(tf.global_variables_initializer())
output = sess.run(tpu_computation)
print(output)
sess.run(tpu.shutdown_system())
但是我得到了以下错误:
GoogleAppClient.errors.HttpError:https://tpu.googleapis.com/v1alpha1/projects/nlp-research-198620/locations/us-central1-b/nodes/sahil-wadhwa?alt=json
在上返回了“权限”tpu.nodes.get“拒绝”
“项目/nlp-research-198620/locations/us-central1-b/nodes/sahil wadhwa'”>
有人能告诉我需要什么权限来提供我的VM或TPU才能顺利运行吗?该工具自动化了许多这些步骤,是创建TPU和VM的推荐方法
如果您希望手动创建VM,则需要将云平台身份验证范围添加到VM中,如下所述
gcloud compute instances create tpu-demo-vm \
--machine-type=n1-standard-2 \
--image-project=ml-images \
--image-family=tf-1-11 \
--scopes=cloud-platform
Michaelb的答案是可行的,不过也可以在控制台中更改现有VM的权限。您必须停止VM,然后对其进行编辑,以允许对计算引擎api进行读/写访问。为此,单击虚拟机的名称,然后单击顶部栏中的编辑;api访问设置位于页面底部