 Some of you watching this video might just be breaking into the field of machine learning, or deep learning. Others may have some knowledge of executing models through packages like scikit-learn, and some of you may even know about deep learning frameworks like Keras with the TensorFlow, Theano, or CNTK backend. Regardless of your experience, if you've ever trained a model on your computer, you know that it can take a while, like a really long time. This is especially true for training neural networks because of the sheer amount of data we need for training. Computers take a lot of time because it only uses the CPU for performing millions of mathematical operations. Nowadays, this task can be extended to other parts of our computer, specifically the GPU. GPUs were traditionally used for gaming and video rendering, but we also find it useful in training models for deep learning. Some computers may come with built-in GPUs, but they're probably enough just to render basic graphics, kind of like iris on MacBooks or Nvidia on Windows PCs and laptops, the latter being more powerful. 9 out of 10 times, this processing power is still not enough to train models, with all the data that is required by many problems, and even for models that can be trained, the training is very slow. I'm making this video because I ran into a problem not too long ago. I wanted to train a DC GAN to generate some digit images using the MNIST dataset. I wrote a program and it worked, but there was a problem. It was training slow, like very, very slow. It would take a significant amount of time to train the CNN and a deconvolutional network over 3,000 iterations. Chances are, it would have taken an entire day to train this hello world model with a GAN. Imagine the time it would have taken to train a really complicated model with a really large dataset. It's crazy. One way to solve this problem, like I said, is to use GPUs. You could get an external GPU and configure it for your computer, but GPUs are several hundreds of dollars and you'll have to deal with the hardware maintenance. Nowadays, technology advances too fast to keep track of it. What you buy today will probably be obsolete next year. Furthermore, I'm on a Mac and I saw this concerning message about TensorFlow GPU support and how it would discontinue at version 1.2. So this led me to another option, using the cloud. So in this video we're going to talk about the steps we need to take to get an AMI instance up and running for training your large models in Amazon's EC2. A lot of words, yeah, but I'll explain everything. You first need to create an account. The link to this page will be down in the description below. But alas for basic information, including credit or debit card info. Make sure you choose the developer account, which is $29.99 at the time of making this video. The free basic account doesn't allow you to access as many resources. You might as well just run the programs on your own laptop. Once logged in, you should see a console page that looks something like this. What you want to do from here is search for EC2, EC2 by the way stands for Elastic Cloud Compute. This will link you to the dashboard. You can do a lot of stuff here, but I'm only going to go through the essentials to get you up and running with an AMI instance. Amazon does well explain to themselves here, so you can come back to it when you have time. For now, click on the limits link. You'll see the available instances and their capacities you have in the current plan, which is at least developer I hope. I'm running you through this section because when I first set up my account, the first thing I wanted to do was launch an instance and get my program running. Really late in the instance set up, I realized that it kept failing because I didn't see this page. I know I've been throwing the terms instance and AMI a lot, so a few words on this before I actually continue. Basically, Amazon provides many services, one of which they call Amazon Elastic Cloud Compute or Amazon EC2. As soon as you hear the word cloud, you're probably going to ask a question about what kind of cloud service model is it? This particular service is an infrastructure as a service. So why is that? I say so because the underlying hardware and storage is abstracted from the user, but the user has control over operating system resources, like setting up a virtual machine for example. This distinguishes it from a pass, a platform as a service, and obviously a software as a service, a SaaS. Now in this infrastructure, they provide something called AMIs, Amazon Machine Images, and AMI is basically a virtual appliance. And like any virtual appliance, AMI consists of a template, which is a layout of an operating system and a software configuration. This is used to generate virtual machines, also known as instances. We can generate many instances from a single AMI. Okay, we got that theory out of the way. On this limits page, each instance listed provides different resources and different amounts of resources. In the free tier for example, you have access to create a T2 micro instance. T2s are typically used for general CPU computations. It's already available to you so you can just begin launching an instance. In my opinion, your laptop may already have more computing power and so you're better off training these models on your laptop. What we need now is GPU computation power, and this is provided by P2 instances. One problem though is that they're not immediately available to us, so I cannot just say create a P2X large instance right off the bat. We need to request for a limit increase on this resource, so why does AWS do this? The idea is to protect their infrastructure and ensure that their clients only use what they need to use and want to use. If there were to say grant 10 of these P2 instances from the get-go, then you would be compelled to use all of them, utilizing all these resources would cost them thousands of dollars. Well no matter, when putting forward a request, usually they deal with it pretty quickly. It may take a few hours for them to send their response, and another day or two to actually grant the request though. Once the limit instance is taken care of, you'll see the update on the page. Let us now see how we can generate this instance. Go back to the dashboard and click launch instance. By this we mean creating a virtual machine instance. Now we just have to follow a sequence of seven steps. We'll first choose the AMI. Every AMI listed here has the name as well as when you want to use it. Since I want to perform deep learning with Kerosene TensorFlow, I choose the deep learning AMI. Next we determine the type of instance we want this AMI to generate. Remember, we need GPU computation power, so it makes sense to choose from that family alone. We choose the P2X large instance, and click review and launch. If everything is okay here, then click launch. Now we create a key pair and download it as a .pem file. If everything is looking good, click view instances on the bottom. As a first time user, you will only see one instance running. Now to use the instance we'll need to remotely log in. Go to the terminal and enter the directory where you have the key pair file downloaded. First off, change the permissions of the file to be slightly more restrictive. I changed it to 600 so only the file owner can read and write to this file. Next, type in the secure shell command where we'll be using port 8888. Type the name of the key pair file followed by the user and the public IP address of our AMI instance. Once we're in, start an environment with TensorFlow, Kerosene and CUDA for GPU utility. We are now ready to code. Let's open a Jupyter Notebook and execute the digit recognition model for the MNIST data set. This is a built-in test program already available to us, so there's really no need to code. Just execute the cell. If you're using GPU computation instance, you'll notice that the program execution speed is several times faster than that on a local machine. You can see why we use this now. When you're done, remember to stop your launched instance so you're not charged when it's not in use. And that's how we train a deep learning model in the cloud. Hope this video helped you get started with launching instances in Amazon's EZ2. If you liked the video, hit that like button and subscribe for more awesome content. Oh, and sharing is caring, so share the video. And I'll see you in the next one. Bye-bye.