Coder Social home page Coder Social logo

colab-ssh-and-gdrive's Introduction

Colab-SSH-and-GDrive

A convenient way to utilize Colab GPUs and save the progress from your local Terminal. SSH into Colab notebook with access to your google drive.

Steps

  1. Create your free account at ngrok and get the authtoken. This will be used in Step4.
    Should look like $ ./ngrok authtoken ZT64bWYnXsdTAdfdassJej42auAQqKqZHn2Sh4g2sfAD
  2. Get the public key of your local machine.
    $ ssh-keygen
    $ cat .ssh/id_rsa.pub
  3. Go to your colab notebook. Copy the content from template provided above (ssh_colab.ipynb).
  4. Execute the colab notebook. Mount your Google Drive. When prompted, enter the authtoken obtained in Step1. Lastly, it will ask the public key of your local machine obtained in Step2.
  5. Now you should get output something like ssh [email protected] -p 12**6. The port will be different for your case. Go to your local machine and run this ssh command. Done!


By default, you will be inside a temporary space and its content will be deleted once your Colab session ends. If you want to save your work, you should explicitly save your changes in the mounted google drive.
Your Google Drive files will be present in /content/gdrive/My Drive/

Screenshot


Extra:

Steps for running a JupyterLab instance on top of it:

  1. Execute the following commands:
    apt-get install tmux && pip install jupyter lab
    tmux
    jupyter lab --ip 0.0.0.0 --port 56784
  2. Split the same terminal: Ctrl+b & Shift+"
  3. Execute ssh -R 80:localhost:56784 [email protected]
    You should get an output like this:
    Connect to http://something-caa4e22c.localhost.run or https://something-caa4e22c.localhost.run Connect to this url in your PC browser. Done!

Screenshot
Screenshot
Screenshot


References:
1. https://imadelhanafi.com/posts/google_colal_server/
2. https://medium.com/@archie9211/guide-to-connect-to-google-colab-with-ssh-from-terminal-and-run-jupyter-lab-7ed60258368

colab-ssh-and-gdrive's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.