且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数据从Google Cloud Storage导入到Google Colab

更新时间:2023-01-06 18:11:59

from google.colab import auth
auth.authenticate_user()

运行此命令后,将生成一个链接,您可以单击它并完成登录.

Once you run this, a link will be generated, you can click on it and get the signing in done.

!echo "deb http://packages.cloud.google.com/apt gcsfuse-bionic main" > /etc/apt/sources.list.d/gcsfuse.list
!curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
!apt -qq update
!apt -qq install gcsfuse

使用它在colab上安装gcsfuse. Cloud Storage FUSE是一种开源FUSE适配器,可用于将Cloud Storage存储桶作为文件系统挂载在Colab,Linux或macOS系统上.

Use this to install gcsfuse on colab. Cloud Storage FUSE is an open source FUSE adapter that allows you to mount Cloud Storage buckets as file systems on Colab, Linux or macOS systems.

!mkdir folderOnColab
!gcsfuse folderOnBucket/content/ folderOnColab

使用它来挂载目录. (folderOnBucket是不带gs://部分的GCS存储桶URL)

Use this to mount the directories. (folderOnBucket is the GCS bucket URL without the gs:// part)

您可以使用此文档进行进一步阅读. https://cloud.google.com/storage/docs/gcs-fuse

You can use this docs for further reading. https://cloud.google.com/storage/docs/gcs-fuse