Published on

How to access your kaggle datasets GCS bucket in colab

Categorised under
  1. Upload your dataset to kaggle.
  2. Create a new kaggle notebook, add the dataset, and run the following code:
from kaggle_datasets import KaggleDatasets
GCS_PATH = KaggleDatasets().get_gcs_path()
!gsutil ls $GCS_PATH # >> gs://bucket_name/object_name
python
  1. Run the following within the colab instance:
from google.colab import auth
auth.authenticate_user()
!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
!mkdir data # folder to mount the dataset
!gcsfuse --implicit-dirs "bucket_name" data
python