Deep learning without expensive hardware using Google Colab and connecting it with GitHub

Original article was published by Tushar Dhyani on Deep Learning on Medium


Installing and Running ColabCode

Installing the software is fairly easy using pip. pip install colabcode. If you are still looking for installing the latest version of the code, you can do so directly from the GitHub repo using the following piece of code: pip install git+https://github.com/abhishekkrthakur/colabcode.git.

Once you have installed the Colabcode, you can easily call it in a single line and run as shown in figure 1.0.

1.0: Installing and starting the vs code server

In the ColabCode class, the port argument signifies the port of the machine used for serving the backend. Please note that certain port numbers are reserved for machine usage such as port 80 or 8080, so please make sure that you do not use some conflicting port number else they will result in the unpredictive behavior of the vs code server.

Once you run the cell, it will return a server access code in the form of https://<random-token>.ngrok.io which could be used to get a full-fledged text server which could be used as an IDE as shown in figure 2.3.

1.1 : The server starts and returns the server link

Attaching Google Drive

Now if you have been following Google colab for some time, you might be knowing that we have the flexibility of attaching our google drive at the backend in order to reuse the generated files. Attaching Colabcode to drive is also exactly similar. All we have to do is pass the mount_drive parameter as True and then you’ll just require to authorize Colabcode.

2.0 : Mounting drive with the vs code server
2.1 : Authorizing the Google drive
2.2 : Authorized vs code server online up and running.

Once the authorization is completed and the backend has been connected, it will generate the ngrok URL again as shown above in figure 2.2. You can use the generated link to use the fully-fledged vs code server.

2.3 vs code running on the generated address

Connecting vs code to GitHub

Now that we have set up all the basics of training our code, what we can do is simply use the vs code’s inbuilt functionality to connect. The connection is fairly straight-forward, but if you are fluent in using Github from the terminal, then I would suggest you use the built-in functionality rather than using the terminal. Although the terminal is a much viable option, it will get frustrating soon enough as you might face a bit delay in the response from the terminal. If you still want to use the terminal, you can call the terminal using the ctrl+` button from your keyboard. The ` is the little key below the escape key on the keyboard. It is a little slow to connect but please have patience till you get the mini terminal there. This seems like an annoying issue, but looking at the end product we are getting, it could easily be looked over. I have prepared a little step-by-step gif (Illustrated in figure 3.0) to guide you through most of the process. But if you are still facing any issue, do consider commenting and sharing your problem in the comment section.

3.0: Vs code with GitHub for development

Start using the vs code today over your usual Jupyter notebooks and then thank me later for faster workflows 😉. You can check this colab notebook for the code.