I am starting this tutorial series because I couldn’t find a good step-by-step tutorial on exploring deep-learning using Google Cloud Platform GCP. I use GCP because I don’t have local access to a GPU and you can easily use a computer instance with a high-end GPU using Google Compute Engine (GCE).
GCE is an infrastructure as a service (IaaS) that is part of Google Cloud Platform that lets users launch and use virtual machines on demand. Although none of the services of Google Cloud Platform is free, Google lets you sign up for a free trial that lasts for 12 months (a full year!) and gives you $300 US in credit so you can play around and explore all the services without spending any money.
To learn more about Google Compute Engine, you can check their documentation page here.
To sign up for the free trial, go to Google Cloud website here and sign in with your gmail account. Once you are logged in, click on “Try It Free” button and follow the instructions provided. You will be asked to provide credit card information but that information will only be used for identity purposes and you won’t get charged before your free trial ends. The good thing about GCP is that unlike some other similar services, you will be notified before your free trial ends and you can cancel your services anytime you want.
First thing first, you are going to need to create a GCE Instance which is a Virtual Machine(VM) hosted on Google infrastructure (Google’s innovative data centers and worldwide fiber network).
The VM instance you create, can run a Linux or Windows image and install all the software you need to do deep learning (you can even boot from docker images). To create am instance, you need to create a console project (each project can have multiple instances). When you create an instance you can specify the OS, Machine Type, number of CPUs, etc..
Each instance only has a small root persistent disk that contains the OS and you should add storage to your instance for additional memory. You can launch and manage an instance by using the Google Cloud Platform Console, the gcloud command-line tool or the REST API’s. You can then connect to your instance, using Secure Shell (SSH) for Linux instances or Remote Desktop Protocol (RDP) for Windows Server instances.
Using the Google Cloud Platform Console:
Go to Google Cloud Platform page and log in, then click “Go To Console” button.
Click “create” to create a project or select an existing project.
Enable Billing for your project:
- Click 3 horizontal lines at the top left corner of your console and select Billing.
- Click the New billing account button.
- Enter the name of the billing account and enter your billing information.
- Click Submit and enable billing.
By default, the person who creates the billing account is a billing administrator for the account.
Create an instance:
Click on 3 horizontal lines at the top left corner of your console and scroll down to find Compute engine. You can pin this service so you don’t have to scroll down to find it every time. Hover over “Compute Engine”, and click “VM instances” and create an instance.
Here you can select “Machine type” and add cores, memory, and GPUs to your instance. There are four classes of predefined machine types with a fixed collection of resources which are managed by Google Compute Engine.
Standard machine types: Standard machine types are suitable for tasks that have a balance of CPU and memory needs. They have 3.75 GB of system memory per virtual CPU.
High-memory machine types: High-memory machine types are ideal for tasks that require more memory relative to virtual CPUs. They have 6.50GB of system memory per virtual CPU.
High-CPU machine types: High-CPU machine types are ideal for tasks that require more virtual CPUs relative to memory. High-CPU machine types have 0.90 GB of system memory per virtual CPU.
Shared-core machine types: Shared-core machine types provide one virtual CPU that is allowed to run for a portion of the time on a single hardware hyper-thread on the host CPU running your instance. They can be more cost-effective for running small, non-resource intensive applications than standard, high- memory or high-CPU machine types.
For more information on machine types visit here.
If you do not specify a desired CPU platform when you create an instance, the instance uses whichever platform is the default for the zone where the instance will live. You can see a list of zones and their default CPU platforms here.
The following CPU platforms are available on Compute Engine:
- 2.6 GHz Intel Xeon E5 (Sandy Bridge)
- 2.5 GHz Intel Xeon E5 v2 (Ivy Bridge)
- 2.3 GHz Intel Xeon E5 v3 (Haswell)
- 2.2 GHz Intel Xeon E5 v4 (Broadwell)
- 2.0 GHz Intel Xeon (Skylake)
You can attach GPUs only to instances with a predefined machine type or custom machine type that you are able to create in a zone. GPUs are not supported on shared-core machine types. Instances with lower numbers of GPUs are limited to a maximum number of vCPUs. In general, higher numbers of GPU dies allow you to create instances with higher numbers of vCPUs and system memory. You can use these GPUs to accelerate specific workloads on your instances such as machine learning and data processing.
Compute Engine provides NVIDIA® Tesla® V100, P100 and K80 GPUs for your instances in passthrough mode so that your virtual machine instances have direct control over the GPUs and their associated memory. For a list of available GPUs in different zones visit here.
To the right of your instance specs, you can see the price of the instance that is automatically updated when you change the specifications.
In the Boot Disk section, You can choose operating system images to create boot disks for your instances. As of now the latest Linux image is Debian 9.
In the Firewall section, select Allow HTTP traffic and click Create to create the instance.
To connect to your instance, click SSH in the row of the instance and now you have a terminal window for interacting with your Linux instance.
Reference: Google Compute Engine Documentation webpage