在Google AI平台上运行tensorflow-cloud作业时,作业的入口点如下所示:
import tensorflow as tf
filename = r'gs://my_bucket_name/hello.txt'
with tf.io.gfile.GFile(filename, mode='w') as w:
w.write("Hello, world!")
with tf.io.gfile.GFile(filename, mode='r') as r:
print(r.read())
作业成功完成,在日志中打印“hello world”
铲斗和作业都位于同一区域
但我在云存储中找不到该文件。它不在那里。我运行了一些其他测试,在那里我做了tf.io.gfile.listdir
,然后写了一个新文件,然后再次tf.io.gfile.listdir
,我打印了之前和之后的文件,似乎添加了一个文件,但当我打开云存储时,我在那里找不到它。还能够从存储器中读取文件
我没有得到任何权限错误,正如官方文件所说,AI平台已经有了读/写云存储的权限
这是我的main.py
文件:
import tensorflow_cloud as tfc
tfc.run(
entry_point="run_me.py",
requirements_txt="requirements.txt",
chief_config=tfc.COMMON_MACHINE_CONFIGS['CPU'],
docker_config=tfc.DockerConfig(
image_build_bucket="test_ai_storage"),
)
这是我可以重现问题的最简单版本
云存储不是一个文件系统。记住这一点,您可以在bucket中执行uploads、downloads或Deletion操作
您试图做的是打开一个文件并写入其中。您应该做的是在本地创建文件,然后将其上载到所需的bucket
相关问题 更多 >
编程相关推荐