Cheat-sheet for Google Colab (2024)

In this tutorial, you will learn how to make the most out of Google Colab.

Cheat-sheet for Google Colab (1)

Google Colab is an amazing tool that lets us build and execute an outstanding data science model and provides us with an opportunity to document our journey. As Google Colab provides us code cells to type the code, it also provides us with text cells to add the text. In this tutorial, we will focus more on the text cell and see how we can master it by using some simple commands that I will discuss in this tutorial. If you love documenting (like me) then you will enjoy reading this tutorial. You can start exploring Google Colab from below given link. Believe me, it’s an amazing tool.

Below I will discuss some main handy tricks and shortcuts that can use and become a pro in documenting. If you know Markdown, XML, and HTML coding then this might be a cakewalk or if you are not familiar with either of those well today is the day to learn them all. Google Colab supports both Markdown and HTML documentation. You can any of these to document. Just a heads-up the whole code for this tutorial can also be found on my GitHub repository below:

All right, let’s get started.

To experiment with all of these commands use the “Text cell”

Cheat-sheet for Google Colab (2)

Below is the shortcut command for headings. There are different types of headings from Heading 1 to 6.

Markdown

Use # heading-name, the more you append # the size of the heading decreases as seen below:

Cheat-sheet for Google Colab (3)

HTML

Similarly, you can use HTML tags such as h1, h2, h3, h4, h5 and h6 for headings as shown below:

Cheat-sheet for Google Colab (4)

Bold make the text bolder and increases the text’s visibility.

Markdown

To make the text bold in markdown surround it by ** (two stars) for example **Text-to-be-bold**

Cheat-sheet for Google Colab (5)

HTML

Using HTML we can bold the text by using the b tag as seen below:

Cheat-sheet for Google Colab (6)

Similar to bold the text can also be italicized

Markdown

To make the text italicize in markdown surround it by * (one star) for example *Text-to-be-italicize*

Cheat-sheet for Google Colab (7)

HTML

Also, this can be written in HTML using the i tag as shown below:

Cheat-sheet for Google Colab (8)

Used to strike through the text. A horizontal line is drawn in the middle of the text.

Markdown

To strikethrough, the text in markdown surround the text with two tilde’s character ~~, such as ~~Text to be striked~~.

Cheat-sheet for Google Colab (9)

HTML

In HTML we can use the s tag to strikethrough the text.

Cheat-sheet for Google Colab (10)

Also, we can combine all the formatting commands and style the text as shown below.

Markdown and HTML

Cheat-sheet for Google Colab (11)

As we all know there are two types of lists:

  1. Ordered List
  2. Unordered List

As the name suggests an ordered list has an order (1, 2, 3,… or other). But an unordered list has no order, as shown below.

Ordered and Unordered list in Markdown

In markdown for the ordered list, you can straightaway just type numbers like 1, 2, 3, and so on. But for the unordered list, you can start with a * and this intern creates a bullet list.

Cheat-sheet for Google Colab (12)

HTML

We can use the HTML tags to play with the lists as shown below:

Ordered list

In the ordered list there are normal list, type 1, A, a, I, i types as shown below:

Normal list

Use the ol tag and for the list contents use the li tag as shown below:

Cheat-sheet for Google Colab (13)

Type = “1”

Just add type = "1" inside the ol tag this will create an ordered list of 1, 2, 3, and so on. The list items will be numbered with numbers (default).

Cheat-sheet for Google Colab (14)

Type = “A”

Just add type = "A" inside the ol tag this will create an ordered list of A, B, C, and so on. The list items will be numbered with uppercase letters.

Cheat-sheet for Google Colab (15)

Type = “a”

Just add type = "a" inside the ol tag this will create an ordered list of a, b, c, and so on. The list items will be numbered with lowercase letters.

Cheat-sheet for Google Colab (16)

Type = “I”

Just add type = "I" inside the ol tag this will create an ordered list of I, II, III, and so on. The list items will be numbered with uppercase roman numbers.

Cheat-sheet for Google Colab (17)

Type = “i”

Just add type = "i" inside the ol tag this will create an ordered list of i, ii, iii, and so on. The list items will be numbered with lowercase roman numbers.

Cheat-sheet for Google Colab (18)

Unordered list

In the ordered list there are normal list, disc, square, circle, and none types as shown below:

Normal list

Use the ul tag and for the list contents use the li tag as shown below:

Cheat-sheet for Google Colab (19)

Disc

Just add type = "disc" inside the ul tag to create a disc-shaped list.

Cheat-sheet for Google Colab (20)

Circle

Just add type = "circle" inside the ul tag to create a circle-shaped list.

Cheat-sheet for Google Colab (21)

Square

Just add type = "square" inside the ul tag to create a square-shaped list.

Cheat-sheet for Google Colab (22)

None

Just add type = "none" inside the ul tag to create a none-shaped list. In this case, the list will have no points as shown below

Cheat-sheet for Google Colab (23)

Description list

A description list is a list of terms, with a description of each term. The dl tag consists dt which defines the name of the list and the dd tag describes each list.

Cheat-sheet for Google Colab (24)

Nested list

Nested lists are basically lists within lists.

Cheat-sheet for Google Colab (25)

Control list counting

An ordered list will start counting from 1. If you want to count from a specified number, you can use the start attribute as shown below:

Cheat-sheet for Google Colab (26)

To know more in-depth about the list in HTML please refer to the article below:

Links or hyperlinks allow users to click their way from page to page.

Markdown

In markdown write the title of the link inside square brackets [ ] and write the webpage address inside round brackets or parenthesis ( ). Make sure you write the title first, followed by the link.

Cheat-sheet for Google Colab (27)

HTML

In HTML for the hyperlinks, you can use the anchor a and href tag as shown below:

Cheat-sheet for Google Colab (28)

Sometimes one image is worth one thousand words. People can easily understand the concepts better by seeing an image.

Markdown

Similar to the link you need to insert the link of the image inside the parenthesis. Make sure you append ! at the beginning. If your link is broken or not valid, then the alt text would be displayed.

Cheat-sheet for Google Colab (29)

Image hover

You can simultaneously hover on the text to see the title of the image. To do this, you can put the text of your choice inside the command as shown below:

![alt text](https://media.makeameme.org/created/online-class-cant.jpg "Online Class Memes")

HTML

In HTML we can include an image using the img tag and you need to provide the source of the image to the src tag.

Adjusting height and width

You can adjust the height and width of the image. Also, you can embed a GIF image too as shown below.

Cheat-sheet for Google Colab (30)

Images along with captions

It’s a great practice to give credit to the images taken from different sources (I mean citing the images or providing the captions). With the help of figcaption tag we can provide captions to the images.

Cheat-sheet for Google Colab (31)

You can play with the align tag and try to align the caption according to your preference.

There are two things that you need to understand here are:

  1. Inline Code
  2. Syntax highlighting

Inline Code

Sometimes you might want to insert a few code samples you can use Inline codes. To use the inline code, you can use the backticks (``). Surround it with backticks as shown above.

Cheat-sheet for Google Colab (32)

Syntax highlighting

This is used when you write huge lines of codes inside Google Colab’s text editor. Sometimes including huge python code snippets is not a good idea using inline codes, use syntax highlight in this case. You must embed the code within ```as shown below

Default syntax highlighting

This works irrespective of any programming language.

Cheat-sheet for Google Colab (33)

Python syntax highlighting

This can be used explicitly for python programming. You should include the name pythonat the beginning.

Cheat-sheet for Google Colab (34)

Javascript syntax highlighting

This can be used explicitly for JavaScript programming. You should include the name javascript at the beginning.

Cheat-sheet for Google Colab (35)

C programming syntax highlighting

This can be used explicitly for C programming. You should include the name c at the beginning.

Cheat-sheet for Google Colab (36)

As seen above you can highlight the code snippets based on different programming languages.

There are a few times you might want to represent the information in the form of tables.

Markdown

You must use the | as an operator for different columns. By default, the table headers would be in bold.

Cheat-sheet for Google Colab (37)

Colons can be used to align columns.

If you need to create any table then use the below tool to generate tables for you. All you have to do select the type of table generators such as Latex, HTML, Markdown, and others. Enter the contents inside the table and then click on Generate. You can then copy-paste the generated code in the text editor and see a beautiful table without minimum effort.

HTML

In the case of HTML, you must use the table tag along with tr which is for the table rows and th is for the table headers (Company Name and Founder) in this case. The td is for the table description.

Cheat-sheet for Google Colab (38)

You can also use the align tag and align the contents accordingly.

This is very useful when you need to differentiate some text like NOTE , HINT or any extra useful information.

Markdown

You need to use the > for the indentation.

Cheat-sheet for Google Colab (39)

HTML

Similarly in HTML you can use the blockquote tag for the same purpose.

Cheat-sheet for Google Colab (40)

It is often a wonderful practice to draw a horizontal ruler after every chapter, or any concept while you are writing. This just helps in differentiating things from one another.

Markdown

In case of markdown, you need to just use 3 --- (Minus).

Cheat-sheet for Google Colab (41)

HTML

In case of HTML, you need to use the tag hr for inserting a horizontal ruler.

Cheat-sheet for Google Colab (42)

Often many times you will write big paragraphs in your notebooks, but sometimes you might want to justify them just to make it look neat. Here, you can use the align tag with justify as a value.

Cheat-sheet for Google Colab (43)
Cheat-sheet for Google Colab (44)

Similarly, you can use right , left , and center values and align the paragraph accordingly.

Some times you might want to start a new paragraph, so you will need to put a line break in between both of them. There are two options here either you can just press the “Enter” key and leave a line of space in the between or you can use the br tag also called a line break.

Cheat-sheet for Google Colab (45)

If you are using the notebooks for research purpose then you need to write a lot of equations and mathematical symbols.

Symbols

Make sure you write the symbol name between $ and start with \ after the first $.

Cheat-sheet for Google Colab (46)

Equations

Follow the same rules i.e surround the equations between $ and start with / after the first $.

Cheat-sheet for Google Colab (47)

To see more about the mathematical equations and symbols, please refer to the link below:

All right, folks, that’s the end of the tutorial. I hope you learned many new things today. I tried to keep this tutorial short but as there were many concepts I had to maximize it. But this cheat-sheet will be useful in most of the interviews (technical documentation) or when you are documenting your Jupiter notebooks. If I find more tips and tricks, then I will provide the details here. Until then, stay safe and have a wonderful day. See you next time.

Cheat-sheet for Google Colab (2024)

FAQs

How many hours of GPU is free in Colab? ›

In the version of Colab that is free of charge notebooks can run for at most 12 hours, depending on availability and your usage patterns. Colab Pro, Pro+, and Pay As You Go offer you increased compute availability based on your compute unit balance.

Is TPU faster than GPU Colab? ›

According to Google's team behind Colab's free TPU: “Artificial neural networks based on the AI applications used to train the TPUs are 15 and 30 times faster than CPUs and GPUs!”

How do I use Google colab efficiently? ›

Use Google Colab Like A Pro
  1. Check and Report on your GPU Allocation. ...
  2. No More Authenticating “gdrive. ...
  3. Bypass “pip install …” ...
  4. Import your own Python Modules/Packages. ...
  5. Copy files To Google Storage Bucket. ...
  6. Ensure all Files have been Completely Copied to GDrive. ...
  7. Quickly open your local Jupyter Notebook.

How much RAM does a free colab need? ›

Free-tier Colab will almost always provide ~12 GB of RAM with limited access to high-memory VMs which have 25 GB RAM. Colab Pro increases availability of high-memory VMs (32 GB RAM), while Colab Pro+ extends high memory VMs to 52 GB RAM.

Can I run colab overnight? ›

The 'maximum lifetime' of a running notebook is 12 hours (browser open)

Can I leave colab running overnight? ›

Colab has implemented a limit on the free usage, so that they can allocate the resources across all users and platforms. Notebooks run by connecting to virtual machines that have maximum lifetimes that can be as much as 12 hours. Notebooks will also disconnect from VMs when left idle for too long.

Is Kaggle GPU better than Colab? ›

Google Colab

It is easier to use as we can link it up with both google drive and github from where we can load data sets, files and images. We can also export our code directly to our github repo. While using tensor flow google colab offers TPUs instead of GPUs which are way more faster than any GPU in kaggle.

Is Kaggle GPU faster than Colab? ›

Like Colab, Kaggle provides free browser-based Jupyter Notebooks and GPUs. Kaggle also comes with many Python packages preinstalled, lowering the barrier to entry for some users. On the other hand, many users note that Kaggle kernels tend to be a bit slow (albeit still faster than Colab).

Is GPU or CPU better for AI? ›

GPU vs CPU Performance in Deep Learning Models

CPUs are everywhere and can serve as more cost-effective options for running AI-based solutions compared to GPUs. However, finding models that are both accurate and can run efficiently on CPUs can be a challenge. Generally speaking, GPUs are 3X faster than CPUs.

Is GPU faster in Colab? ›

RTX3060Ti - Data Science Benchmark Results. Not even close. RTX3060Ti dedicated GPU is almost 4 times faster on a non-augmented image dataset and around 2 times faster on the augmented set.

Is colab GPU faster than CPU? ›

From my point of view, GPU should be much faster than cpu, and changing device from cpu to gpu only need to add .to('cuda') in the definition of model/loss/variable and set google colab 'running on gpu'.

How can I run colab for more than 12 hours? ›

2. Virtual Machines (Sessions) Colab uses virtual machines to execute the notebook code on the server, these machines have a maximum life span of 12 hours. Therefore, anything that takes more than 12 hours to run will be incomplete.

Can I use 2 GPU in Colab? ›

I can successfully spin up a 2 GPU DeepLearning VM and connect to a Colab notebook via port-forwarding to a locally-hosted connection (Jupyter Notebook), as shown here.

How do I get 32gb RAM on Google Colab? ›

For that you have to open scratchpad by clicking into the link given below or open a new Google colab instance. Then, change the runtime type-setting to GPU like given below: Run the below command for eating all the available RAM and it will crash the instance allocated to you in google collaboratory.

Is colab faster than PC? ›

On Google Colab I went with CPU runtime in the first notebook and with the GPU runtime in the second. And there you have it — Google Colab, a free service is faster than my GPU-enabled Lenovo Legion Laptop. For some reason, MacBook outperformed it, even though it has only quad-core 1.4GHz CPU.

Is colab faster than Jupyter? ›

Jupyter runs in your local machine and uses your systems' ram storage and CPU while colab runs in google server and gives you access to free GPU and TPU for faster processing.

Is colab better than anaconda? ›

Anaconda distribution of Jupyter Notebook shipped with several pre-installed data libraries, such as Pandas, NumPy, Matplotlib, which is awesome. Google Colab, on the other hand, provides even more pre-installed machine learning libraries such as Keras, TensorFlow, and PyTorch.

Can I use colab without Internet? ›

Once you are in your Colab notebook you can use it just like any offline Jupyter notebook.

Is colab Pro worth? ›

That simple, they don't offer you good GPU's except you can get benefits of longer runtimes and more RAM. I never got Tesla T4 even once after subscribing to Colab Pro. I would say stick with the regular Colab which is free, also make use of the Kaggle Kernels they're really good. And yea summing up, it's not worth it.

How much is colab pro? ›

Google says that the update won't affect the free-of-charge Colab tier, which remains in its current form. The only material change is that users can buy access to compute in the form of “compute units,” starting at $9.99 for 100 units or $49.99 for 500.

How long can I run a code in Google Colab? ›

Even though Colab notebooks can only run for a maximum of 12 hours, with the hacks shared above, you should be able to get the most out of your session.

Is Jupyter or colab better? ›

Finally, Google Colab is a must for anyone looking to back their work up to the cloud and to sync their notebooks across multiple devices — but the ease of cloud sharing means reduced data security. Meanwhile, Jupyter is a better choice for sensitive files that need to be kept off the cloud.

Is TPU faster than GPU Kaggle? ›

Under these conditions, we observed that TPUs were responsible for a ~100x speedup as compared to CPUs and a ~3.5x speedup as compared to GPUs when training an Xception model (Figure 3).

Is 8 core GPU enough for machine learning? ›

The 7- or 8-core GPU is powerful enough for some deep learning work — you only need to think about upgrading to the MacBook Pro if you're doing a lot of this type of work and decide you really need your models to train faster.

Can we increase RAM in Colab? ›

Increase the 12GB limit to 25GB

But don't worry, because it is actually possible to increase the memory on Google Colab FOR FREE and turbocharge your machine learning projects! Each user is currently allocated 12 GB of RAM, but this is not a fixed limit — you can upgrade it to 25GB.

Is RTX 3060 good for deep learning? ›

Yes, it's a low end chip, but the 12GB make it quite attractive. It might not run fast, but it'll be able to run things that won't run on the 8GB cards, so if the 10/12GB cards are out of my budget, it seems like an option worth considering.

Is TensorFlow better on CPU or GPU? ›

They noticed that the performance of TensorFlow depends significantly on the CPU for a small-size dataset. Also, they found it is more important to use a graphic processing unit (GPU) when training a large-size dataset.

How much RAM do you need for AI? ›

Understanding machine learning memory requirements is a critical part of the building process. Sometimes, though, it is easy to overlook. The average memory requirement is 16GB of RAM, but some applications require more memory.

Is Python better than AI? ›

While machine learning and artificial intelligence are based on complex algorithms and workflows, Python, with its easy-to-write code, allows developers to focus on solving ML problems rather than technical nuances of the language. That's why many programmers consider Python to be more intuitive than other languages.

Is Python better for AI? ›

Python has proven to be one of the most efficient programming languages for AI and ML solutions. The technology transformation of AI can help in providing better outputs.

How can I get a free GPU? ›

Where To Get Free GPU Cloud Hours For Machine Learning
  1. An Introduction To The Need For Free GPU Cloud Compute. ...
  2. 1 – Google Colab. ...
  3. 2- Kaggle GPU (30 hours a week) ...
  4. 3- Google Cloud GPU. ...
  5. 4- Microsoft Azure. ...
  6. 5- Gradient (Free community GPUs) ...
  7. 6- Twitter Search for Free GPU Cloud Hours.
8 Aug 2020

Is TPU free in Google Colab? ›

TPUs (Tensor Processing Units) are application-specific integrated circuits (ASICs) that are optimized specifically for processing matrices. Google Colab provides experimental support for TPUs for free!

Is Google colab good for AI? ›

According to Google: “Colab is a product from Google Research, it allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education.

Does colab use alot of data? ›

Approx 4GB in 6 hours of training for single notebook .

Why is TPU faster than GPU? ›

GPUs have the ability to break complex problems into thousands or millions of separate tasks and work them out all at once, while TPUs were designed specifically for neural network loads and have the ability to work quicker than GPUs while also using fewer resources.

Does Internet speed affect Colab? ›

So if the Internet connection is slow, it will take more time for the client to receive the information and the whole process will be slow.

Is colab GPU free? ›

Google Colab is a free Jupyter notebook hosted on Google cloud that allows for executing your Python code in the browser and offers the ability to run it on a GPU for free.

What GPU does colab use? ›

The free version of Colab mostly provides a Tesla K80 GPU. Colab pro, the paid version ($9.99/month) provides access to Tesla T4 or P100 GPU's and also other benefits like longer runtimes and priority access to TPU's. Before you can post on Kaggle, you'll need to create an account or log in.

How much faster is colab pro than Colab? ›

On average, Colab Pro with V100 and P100 are respectively 146% and 63% faster than Colab Free with T4.

What is TPU vs GPU? ›

A single GPU can process thousands of tasks at once, but GPUs are typically less efficient in the way they work with neural networks than a TPU. TPUs are more specialized for machine learning calculations and require more traffic to learn at first, but after that, they are more impactful with less power consumption.

How many colab notebooks can I run at once? ›

Yes, you can run multiple colab instances of the same Google account. Also, you can use different google accounts with different browsers and their incognito ones to run as many colabs as you want.

Can I mine using Google Colab? ›

Hypothetically, can we mine cryptocurrency with the Free Google Colab GPU? You can use a GPU to mine some altcoins like Ethereum, Ravecoin etc. but certainly not Bitcoin as suggested.

Can I have 24gb RAM? ›

Yes. In a system with two RAM slots, you can have one 16GB and one 8GB DIMM. In a system with four RAM slots, you can have two 8GB and two 4GB DIMMs. I have a computer with 24 GB of RAM, as a matter of fact.

Is 8GB RAM sufficient for machine learning? ›

8 GB is often insufficient for industry-scale machine learning. 16 GB is decent. 32 GB is better, but already starting to get pretty expensive.

How powerful is Google colab GPU? ›

Google Colab is offering two different GPU Models since 2019: K80 and T4.
...
GPU VMs.
ParameterGoogle ColabKaggle Kernel
GPUNvidia K80 / T4Nvidia P100
GPU Memory12GB / 16GB16GB
GPU Memory Clock0.82GHz / 1.59GHz1.32GHz
Performance4.1 TFLOPS / 8.1 TFLOPS9.3 TFLOPS
5 more rows

Why kaggle is faster than Colab? ›

Kaggle gives NVIDIA Tesla P100 PCI based 16GB GPUS for approximately 9 straight hrs in a single commit, whereas Colab provides NVIDIA Tesla K80 GPU 12 GB for 12hrs. Kaggle has a limitation of 5 GB hard-drive space vs Colab's storage could vary from 30GB to 72GB as per the availability.

How many GPU are there in Colab? ›

You can only have 1 GPU in Colab.

Does Google colab use GPU or CPU? ›

Working with Google Sheets

Google provides the use of free GPU for your Colab notebooks.

How can I get free GPU in Colab? ›

Google provides the use of free GPU for your Colab notebooks.
  1. Enabling GPU. To enable GPU in your notebook, select the following menu options − Runtime / Change runtime type. ...
  2. Testing for GPU. ...
  3. Listing Devices. ...
  4. Checking RAM.

How long can I leave colab running? ›

Even though Colab notebooks can only run for a maximum of 12 hours, with the hacks shared above, you should be able to get the most out of your session.

Will Google colab always be free? ›

In its first pricing change since Google launched premium Colab plans in 2020, Colab will now give users the option to purchase additional compute time in Colab with or without a paid subscription.

Is Google colab faster than GPU? ›

That's something you should think about. To summarize, even a mid-range GPU dramatically outperforms the free Google Colab environment. Keep in mind that I was assigned with Tesla K80 12 GB, which might not be the case for you. Your benchmark results may vary.

Is colab Pro GPU faster? ›

On average, Colab Pro with V100 and P100 are respectively 146% and 63% faster than Colab Free with T4. (source: “comparison” sheet, table E6-G8) Even though GPUs from Colab Pro are generally faster, there still exist some outliers; for example, Pixel-RNN and LSTM train 9%-24% slower on V100 than on T4.

What is better than Colab? ›

Kaggle. Kaggle is another Google product with similar functionalities to Colab. Like Colab, Kaggle provides free browser-based Jupyter Notebooks and GPUs. Kaggle also comes with many Python packages preinstalled, lowering the barrier to entry for some users.

Top Articles
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated:

Views: 6120

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.