Silver BlogDeep Learning Development with Google Colab, TensorFlow, Keras & PyTorch

Now you can develop deep learning applications with Google Colaboratory - on the free Tesla K80 GPU - using Keras, Tensorflow and PyTorch.



Cloning Github Repo to Google Colab

 
It is easy to clone a Github repo with Git.

Step 1: Find the Github Repo and Get “Git” Link

Find any Github repo to use. For instance: https://github.com/wxs/keras-mnist-tutorial

Clone or download > Copy the link!

2. Git Clone

Simply run:


3. Open the Folder in Google Drive

Folder has a same the with Github repo of course :)

4. Open The Notebook

Right Click > Open With > Colaboratory

5. Run

Now you are able to run Github repo in Google Colab.

 

Some Useful Tips

 

1. How to Install Libraries?

Keras

!pip install -q keras
import keras


PyTorch


MxNet

!apt install libnvrtc8.0
!pip install mxnet-cu80
import mxnet as mx


OpenCV

!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2


XGBoost

!pip install -q xgboost==0.4a30
import xgboost


GraphViz

!apt-get -qq install -y graphviz && pip install -q pydot
import pydot


7zip Reader

!apt-get -qq install -y libarchive-dev && pip install -q -U libarchive
import libarchive


Other Libraries

!pip install or !apt-get install to install other libraries.


2. Is GPU Working?

To see if you are currently using the GPU in Colab, you can run the following code in order to cross-check:

import tensorflow as tf
tf.test.gpu_device_name()


3. Which GPU Am I Using?

from tensorflow.python.client import device_lib
device_lib.list_local_devices()


Currently, Colab only provides Tesla K80.

4. What about RAM?

!cat /proc/meminfo


5. What about CPU?

!cat /proc/cpuinfo


6. Changing Working Directory

Normally when you run this code:

!ls


You probably see datalab and drive folders.

Therefore you must add drive/app before defining each filename.

To get rid of this problem, you can simply change the working directory. (In this tutorial I changed to app folder) with this simple code:

import os
os.chdir("drive/app")


After running code above, if you run again

!ls


You would see app folder content and don’t need to add drive/app all the time anymore.

7. “No backend with GPU available“ Error Solution

If you encounter this error:

Failed to assign a backend
No backend with GPU available. Would you like to use a runtime with no accelerator?


Try again a bit later. A lot of people are kicking the tires on GPUs right now, and this message arises when all GPUs are in use.

Reference

8. How to Clear Outputs of All Cells

Follow Tools>>Command Palette>>Clear All Outputs

9. “apt-key output should not be parsed (stdout is not a terminal)” Warning

If you encounter this warning:

Warning: apt-key output should not be parsed (stdout is not a terminal)


That means authentication has already done. You only need to mount Google Drive:

!mkdir -p drive
!google-drive-ocamlfuse drive


10. How to Use Tensorboard with Google Colab?

I recommend this repo:

https://github.com/mixuala/colab_utils

 

Conclusion

 
I think Colab will bring a new breath to Deep Learning and AI studies all over the world.

If you found this article helpful, it would mean a lot if you gave it some applause???? and shared to help others find it! And feel free to leave a comment below.

You can find me on LinkedIn.

 
Bio: Fuat Beşer is a Deep Learning Researcher, and the founder of Deep Learning Turkey, the largest AI community in Turkey.

Original. Reposted with permission.

Related: