Up till now, we have only briefly discussed the hardware requirements for training deep learning models, as almost all of the examples in this book run on any modern computer. While you do not need a GPU (Graphical Processing Unit) based computer to run the examples in this book, there is no getting away from the fact that training complicated deep learning models requires a computer with a GPU. Even if you have a suitable GPU on your machine, installing the necessary software to train deep learning models using GPUs is not a trivial task. This section will briefly discuss how to install the necessary software to run deep learning models on GPUs and also discusses the advantages and disadvantages of using cloud computing for deep learning. We will use various cloud providers to create virtual instances or access services that will allow...
You're reading from R Deep Learning Essentials. - Second Edition
Setting up a local computer for deep learning
At the time of writing this book, it is possible to purchase a computer with a GPU card suitable for deep learning for under $1,000. The current on-demand cost of the cheapest GPU computer on AWS is $0.90 per hour, which is equivalent to using the machine constantly for 46 days. So, if you are just starting with deep learning, cloud resources are the cheapest way to begin. Once you have learned the basics, then you may decide to get a GPU-based computer, but even then you may continue using cloud resources for deep learning. You have much more flexibility in the cloud. For example, in AWS, you can get a p3.16xlarge machine with 8 Tesla V100 GPU cards for an on-demand price of $24.48 per hour. An equivalent box is the DGX-1 from NVIDIA (https://www.nvidia.com/en-us/data-center/dgx-1/), which has 8 Tesla V100 GPU cards and costs $149...
Using AWS for deep learning
AWS is the biggest cloud provider, and so it deserves our attention. If you know how to use AWS and especially if you are familiar with spot requests, it can be a very cost-effective method to train complex deep learning models.
A brief introduction to AWS
This section gives you a brief introduction to how AWS works. It describes EC2, AMIs, and how to create a virtual machine in the cloud. This will not be an exhaustive introduction to AWS – there are plenty of tutorials online that will guide you.
AWS is a suite of cloud resources. Another term for it is Infrastructure as a Service (IaaS), as opposed to Software as a Service (SaaS) or Platform as a Service (PaaS). In IaaS, as opposed to...
Using Azure for deep learning
Azure is the brand name for Microsoft's cloud services. You can use Azure for deep learning and, similar to AWS, it provides deep learning virtual machines that is pre-configured with deep learning libraries installed. In this example, we are going to create a Windows instance that can be used for Keras or MXNet. This assumes that your local computer is also a Windows computer, as you will be using Remote Desktop Protocol (RDP) to access the cloud instance.
- The first step is to create an account in Azure and then log in to Azure at https://portal.azure.com. You will see a screenshot similar to the following. Click Create a resource and search for Deep Learning Virtual Machine:
- When you select Deep Learning Virtual Machine, the following screen will appear. Click Create:
Using Google Cloud for deep learning
Google Cloud also has GPU instances. At the time of writing this book, the price of an instance with an NVIDIA Tesla K80 GPU card (which is also the GPU card in an AWS p2.xlarge instance) is $0.45 per hour on-demand. This is significantly cheaper than the AWS on-demand price. Further details of Google Cloud's GPU instances are at https://cloud.google.com/gpu/. However, for Google Cloud, we are not going to use instances. Instead, we are going to use the Google Cloud Machine Learning Engine API to submit machine learning jobs to the cloud. One big advantage of this approach over provisioning virtual machines is that you only pay for the hardware resources that you use and do not have to worry about setting up and terminating instances. More details and pricing can be found at https://cloud.google.com/ml-engine/pricing.
Go through the following...
Using Paperspace for deep learning
Paperspace is another interesting way to perform deep learning in the cloud. It might be the easiest way to train deep learning models in the cloud. To set up a cloud instance with Paperspace, you can log in to their console, provision a new machine, and connect to it from your web browser:
- Start by signing up for a Paperspace account, log in to the console, and go into the Virtual Machine section by selecting Core or Compute. Paperspace has an RStudio TensorFlow template with NVIDIA GPU libraries (CUDA 8.0 and cuDNN 6.0) already installed, along with the GPU version of TensorFlow and Keras for R. You will see this machine type when you select Public Templates, as shown in the following screenshot:
- You will be given a choice of three GPU instances and the choice of pay by the hour or monthly. Select the cheapest...
Summary
We have covered a lot of options for training deep learning models in this chapter! We discussed options for running it locally and showed the importance of having a GPU card. We used the three main cloud providers to train deep learning models in R on the cloud. Cloud computing is a fantastic resource – we gave an example of a super-computer costing $149,000. A few years ago, such a resource would have been out of reach for practically everyone, but now thanks to cloud computing, you can rent a machine like this on an hourly basis.
For AWS, Azure, and Paperspace, we installed MXNet on the cloud resources, giving us the option of which deep learning library to use. I encourage you to use the examples in the other chapters in this book and try all the different cloud providers here. It is amazing to think that you could do so and your total cost could be less than...