Let's study Python

Unlock the power of free cloud GPUs with Google Colaboratory!

# Python getpass.getpass Usage

## Introduction
When it comes to implementing artificial intelligence neural network programming, what is essential? Data and algorithms are undoubtedly important, but a GPU that can handle a lot of computations quickly is also crucial. However, a decent GPU is not cheap enough to buy comfortably. But fear not, as our beloved Google has graciously started offering free cloud GPU services to users. They provide a Tesla K80 GPU through cloud services, which costs nearly close to 3 million won. While it may not meet the specifications of those deeply involved in AI research, for beginners like myself, it is a valuable service akin to a timely rain in a drought. We can use this GPU for free through cloud services, albeit with the drawback of being limited to only 12 hours per day. Nonetheless, we can access a Tesla K80 GPU for free. Let’s explore how to use it and link it to our Google account.

## Getting Started with Google CoLaboratory
Before delving into the actual usage, let’s first provide the link to the starting page. It is advisable to take a look at Google’s brief introduction page to understand what the service is and how it can be effectively utilized. [Google Colaboratory](colab.research.google.com) offers collaborative document management, data analysis, Python, libraries, and more. However, merely reading the introductory page is not sufficient to make proper use of the service. This is because you need to link Google’s services with your Google account. Let’s move on to linking the accounts right after a brief overview.

## Registering for Google Colaboratory
### 3 – 1. Preparing Google Drive
All documents and data created in Google Colab will be stored in your Google Drive. To ensure convenience, let’s create a dedicated folder for Colab within your Google Drive. Go to Google Drive, create a new folder (avoid using Korean), name it something like “colab.” Make sure to use English to avoid potential issues. Inside the created folder, go to “New” and then choose “More” to connect apps. In the search bar on the top right, type “colaboratory” and connect it by pressing the “+ Connect” button. By doing this, a new Colaboratory item will appear. Click on it to create a new file. This will open a blank document. Remember, this is just the connection step; the account linking is still pending.

### 3 – 2. Connecting GPU
Before connecting the GPU, let’s familiarize ourselves with a simple usage example. Execute the following code snippet:
“`python
import tensorflow as tf
tf.test.gpu_device_name()
“`
After running this code by pressing Shift + Enter, you will notice that it indicates using only the CPU. Now, let’s connect the GPU. Go to Runtime -> Change Runtime Type and Hardware Accelerator settings. To verify if the GPU is connected successfully, rerun the code snippet mentioned earlier. You should now see a different output, ‘/device:GPU:0,’ confirming the GPU connection. If you wish to ascertain which GPU is connected, execute the following code snippet:
“`python
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
“`
You will be able to verify the connection to the Tesla K80 GPU.

### 3 – 3. Linking Google Account
The final step involves linking your Google account (Google Drive) with Google Colab. Follow the steps below:
1. Copy the entire code snippet provided.
2. Paste and execute the code in Colab.
3. This will download the necessary packages and prompt you with a link for linking your Google Drive account.
4. Click on the link, log in to your account, copy the code provided, and paste it in the designated box.
5. Once done, the process will be completed.

In this post, we have covered linking the account, and in the next article, we will delve into an example using the MNIST dataset. Stay tuned for more exciting adventures in Google Colaboratory!