Saving pip installs in google colab

前端 未结 1 1470
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 04:03

Is there a way to save packages in Google Collab to my Google Drive? This is so I won\'t have to re-download and re-install packages every time I want to use them.

1条回答
  •  梦毁少年i
    2021-01-01 04:43

    To save your the installed configuration to your Google Drive:

    from google.colab import drive
    drive.mount('/content/gdrive')
    pip freeze --local > /content/gdrive/My\ Drive/colab_installed.txt
    

    To restore from drive:

    from google.colab import drive
    drive.mount('/content/gdrive')
    pip install --upgrade --force-reinstall `cat /content/gdrive/My\ Drive/colab_installed.txt`
    

    0 讨论(0)
提交回复
热议问题