是的,Colab笔记本本地存储现在约为40 GiB。查看确切值的一种方法(在Python 3中):
import subprocess p = subprocess.Popen('df -h', shell=True, stdout=subprocess.PIPE) print(str(p.communicate()[0], 'utf-8'))
的 然而: 强> 对于大量数据,本地存储是提供TPU的非最佳方式,TPU不直接连接到运行笔记本的机器。相反,请考虑将大型数据集存储在GCP存储中,并从Colab笔记本中获取该数据。 (此外,Colab本地存储的数量可能会发生变化,Colab笔记本本身将在几个小时后过期,并使用本地存储。)
看一眼 规范的TPU Colab笔记本 。在底部是一些接下来的步骤,其中包括指向的链接 用TPU搜索莎士比亚 。在该笔记本中是以下代码片段,它演示了对Colab TPU的GCP身份验证。它看起来像这样:
from google.colab import auth auth.authenticate_user() if 'COLAB_TPU_ADDR' in os.environ: TF_MASTER = 'grpc://{}'.format(os.environ['COLAB_TPU_ADDR']) # Upload credentials to TPU. with tf.Session(TF_MASTER) as sess: with open('/content/adc.json', 'r') as f: auth_info = json.load(f) tf.contrib.cloud.configure_gcs(sess, credentials=auth_info) # Now credentials are set for all future sessions on this TPU. else: TF_MASTER=''