This tutorial shows how to use Colab with Google Drive (G-Drive) for storage and GitHub for version control. Follow the example in setup.ipynb
[link].
- Mount Google Drive and create a symbolic link.
- Copy the SSH key to access your GitHub repository.
- Install the required packages.
Since Colab doesn't have its own persistent storage, you need to use external storage like Google Drive.
-
Create a working directory on Google Drive. In this example, we'll use
colab
. -
Create a Git directory (e.g.,
colab_setup
) locally on your computer. -
Upload the entire Git directory to Google Drive at
colab/colab_setup
. -
In the Colab notebook, run the following code to mount Google Drive:
from google.colab import drive drive.mount('/content/drive')
-
Create a symbolic link for quick access to the directory:
!ln -s drive/MyDrive/colab/colab_setup/ colab_setup
Colab initializes a new virtual machine each time you launch a notebook. To maintain persistent access to your GitHub repository, store the .ssh folder on Google Drive (colab
).
- Copy the access keys to the virtual machine:
!cp -r drive/MyDrive/colab/.ssh /root/.ssh
- Copy git config to the virual machine:
!cp drive/MyDrive/colab/.gitconfig /root/.gitconfig
- Change the working directory:
%cd colab_setup
- Install the dependencies listed in requirements.txt:
!pip install -r requirements.txt