Free!! GPUs on your local machine

Eswar Chitirala
3 min readMar 19, 2020

--

Image Source: hpcwire

As the world of Artificial intelligence is increasing day by day. The need for more data and the blah blah …. The routine stuff which everyone knows.

So as a personal interest I started exploring how to obtain free GPUs to meet demands for my amateur data scientist brain.

So started exploring different ways to get free gpu’s.

  1. Kaggle.
  2. Google Colab.
  3. Free AWS Tier. etc.

Finally, Google came to rescue as always they provide ~13 GB of RAM, with GPU and TPU also. Well, but they only support Jupyter-Notebooks. Well, I don’t have a personal grudge on using jupyter-notebook I prefer using a normal coding environment instead of notebooks in some scenarios. In case if you have written an AI Algorithm (In my case just copying from multiple sources and stitching together).

Well you can pay 1$ to copy code from StackOverflow, but you need to pay 1000’s of $$ who knows which code to copy. -An IT guy who isnt paid well.

Your options are limited. My code is only Python 3.5 compatible or I wrote all my code using different small files that imported to my final file or for any different reason. You cannot use google colab notebook.

Follow the below steps to solve all these problems.

You cannot directly change the environment for the notebook.
After hours of exploration found a solution:

  1. Initialize a Ngork gateway in the colab notebook.
  2. connect the Ngork gateway to colab from a local terminal using ssh
  3. Install the required python version using the terminal.
  4. Install Virtualenv.
  5. create a virtual environment by specifying the python version installed.
  6. Activate the environment.
  7. Work in that environment from the terminal directly.

Note: Google doesn’t allow directly installing virtual env with a specific python version. so you need to install the required python version before activating it.

Well, let me make your life a lot easier.

Image Source: imgflip.com

Init Ngork Server in Colab Notebook

Create an account in Ngork (You can connect 1st server for free additional requires Premium version). Get the auth token to be able to connect via ssh

Paste and run the following code in any new google colab notebook cell. Replace the password and auth token generated from the Ngork Gateway

Paste and run the above code in colab notebook.

After you run the code you will get the tcp address generated which you can connect using an ssh terminal.

Need a specific python version?

Now since you have terminal access you can connect and use GPU/TPU provided by google colab from any code editor (VSCode etc.) just by installing any python version and activating the virtual environments.

Just keep your colab notebook running on the browser.

FootNotes:

This approach assumes that you have a pre-requisite knowledge of following:

  1. Basic Usage of google colab.
  2. Connect any code editor (VSCode, Sublime, Pycharm) to a remote server via ssh.
  3. Usage of environment in python.

Well, even if you don’t know any of them above you can use google.

Give a clap if you find this useful.

--

--