In the Google Colaboratory commentary series so far, we have explained the overview of Google Colaboratory and the features of the paid version of Google Colab Pro.
However, I think there are many people who have the question, “I understand Colaboratory, but how do I actually use it?” So, in this third installment, I would like to introduce how to actually create a notebook with Google Colaboratory and how to install TensorFlow.
- What is a Colab Notebook?
- How to create a Colab notebook
- How to install TensorFlow
- in conclusion
In Google Colaboratory, Python is written in a notebook. The notebook is called a “Colab notebook”. You can run Python by entering Python code into code cells in this Colab notebook.
Now, I will explain how to actually create a Colab notebook.
Colab notebooks are created from Google Drive.
First, after logging in with your Google account, access Google Drive and click “New” in the upper left.
Then select “Other” from the list and click “Google Colaboratory”.
If “Google Colaboratory” is not displayed in “Other”, Google Colaboratory is not installed, so please install Google Colaboratory from “Add apps” on the bottom.
Your Colab notebook is now created.
A new code cell is created on your notebook, and you can run Python by entering Python code in this cell.
In this way, with Google Colaboratory, you can easily create a notebook just by logging in to Google Drive.
Google Colaboratory allows you to install the libraries you want to use. As an example, this time I will explain how to install TensorFlow. There are two versions of TensorFlow, a CPU version and a GPU version, but this time we will install the GPU version of TensorFlow.
First, reset all runtimes and set the runtime to GPU. Click “Runtime” from the menu as shown below and click “Reset runtime to factory settings”.
After resetting, click “Runtime” again and click “Change runtime type”.
Here, to set Colab’s environment to GPU, change “Hardware Accelerator” to “GPU” and click “Save”.
Colab’s execution environment is now set to GPU.
Next, use the pip command to install TensorFlow.
!pip install tensorflow-gpu
and enter the install command in the code cell. After entering the command, click the button indicated by the red frame in the figure to execute the installation command.
TensorFlow is now installed. The installation itself is very easy, taking about 1 minute to install TensorFlow.
Next, to check if TensorFlow was successfully installed, print the installed version.
import tensorflow as tf print(tf.__version__)
in the code cell to run the code.
If the version is printed, TensorFlow is successfully installed.
This time, I introduced how to create a notebook in Google Colaboratory and how to install TensorFlow.
In the Google Colaboratory commentary series so far, I have mainly explained the outline, but I hope this blog gave you a concrete image of how to use it.
Google Colaboratory can be used easily just by having a Google account, so why not try it once?
Skill Up AI is currently offering a related course, ” Introduction to Python for Machine Learning “.
In this course, we aim to be able to build machine learning models using scikit-learn from a Python programming inexperienced level. Please consider it.
In addition, we hold a practical AI study session ” Skill Up AI Camp ” every Wednesday. At the study session, we also have hands-on sessions using Google Colaboratory (*Depending on the theme to be covered).
If you are interested, please join us!