- Hands-On Artificial Intelligence for Beginners
- Patrick D. Smith
- 399字
- 2025-02-23 08:58:39
EC2 and virtual machines
The building block for AWS systems is the Elastic Cloud Compute (EC2) instance; it is a virtual server that allows you to run applications in the cloud. In this chapter, EC2 will be the basis for our cloud computing work. For developers and data scientists, Amazon has a suite of virtual machines called Amazon Machine Images (AMI) that come preloaded with everything you need to get up and running with deep learning in the cloud. For our purposes, Amazon has both an Ubuntu AMI as well as an Amazon Linux distribution AMI, which are preloaded with Python 3 and TensorFlow, PyTorch, and Keras.
To get started with utilizing EC2 for deep learning, we'll just have to follow a few steps:
- Log in to your Amazon Web Services Account.
- Search for EC2 in the Search bar and select the service to open a new console.
- Choose the Launch Instance button and search for the AWS deep learning AMI in the AWS Marketplace. You can select either the Ubuntu version or Amazon Linux.
- Select a GPU instance to run your image on. We suggest either a G2 or P2 instance. Choose Next on each page until you reach Configure Security Group. Under Source, choose My IP to allow access using only your IP address.
- Click Launch Instance.
- Create a new Private Key and store this somewhere locally; this will help you connect to your instance later on.
Now, you should have your AMI set up and ready to utilize. If you already have an EC2 instance up and running 0n your AWS account, select the instance and right-click on Image, Create Image under the dropdown for that instance:

Follow the prompts and select Create Image. Afterwards, you can find that AMI by selecting EC2 -> AMIs under the main Explorer toolbar. If you still can't see your AMI, you can find more detailed instructions on AWS website https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/tkv-create-ami-from-instance.html.
To utilize your new virtual machine, first launch the instance on AWS. Here ssh is initialized by utilizing the following command (make sure you are in the same directory as the pem key file you just downloaded):
cd /Users/your_username/Downloads/
ssh -L localhost:8888:localhost:8888 -i <your .pem file name> ubuntu@<Your instance DNS>
Once you've connected with your terminal or command line, you can utilize the interface just as you would the command line on your local computer.