Deployment of a Machine Learning model into Amazon EC2(Part 2- Real-Time Deployment)

  • In the previous article, we set up a Linux-based EC2 instance so that we can deploy our model on AWS EC2.
  • Let’s proceed with model deployment!

Creating a Security Group:

  • Now that we have our EC2 instance, we will have to set up the EC2 instance accessible from anywhere.
Security Group
  • To do so, go to the EC2 instance and select the security group.
  • Select Inbound and click on add rule.
  • Set the type of the rule to All traffic.
Setting Inbound rules
  • In the source information, set the permission as Anywhere.
  • This indicates that we can use access the EC2 instance from anywhere with IPv4 and IPv6 network protocols.

Setting up the Network Interfaces:

  • After setting up the security groups, we need to go to the Network Interfaces section.
Network Interfaces
  • Right-click on the interface and select Change security groups.
Change Security groups

Setting up the system dependencies:

  • Now, we need to go back to the terminal and install the system dependencies in order to deploy our model.
  • For that, we will use the following command:
pip3 install -r requirements.txt
Installing using requirements.txt
  • After running the command we can see that the system dependencies have been successfully installed.
  • Upon successful installation, run the following command in the terminal:
python3 app.py
Running the app
  • We can now see that our app is running on port number 5000

Deploying into EC2:

  • As the final step, we will have to go back to the EC2 instances in the AWS management console.
Connecting the EC2 instance
  • From the instances, select the EC2 instance.
  • After that, we will have to click on actions and click on connect. We should be able to see an URL.
Getting the URL
  • We will simply add the port number. Here, the port number is 5000. So we can add the port number as follows:
<The EC2 URL>/5000
  • Open this entire link in a new tab and you can see your model live on Amazon Elastic Compute Cloud (EC2).

Conclusion:

  • In this article, we covered a high-level overview of how to deploy a machine learning model into Amazon EC2.
  • In the next article, we will see how the high-level overview of Amazon S3.
  • We will also understand how to run a jupyter notebook into the cloud using Amazon Sagemaker.

--

--

--

One of India’s leading institutions providing world-class Data Science & AI programs for working professionals with a mission to groom Data leaders of tomorrow!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Phlo’s Tech Talks

TDD in Go, Some Challenges

How to Easily Automate Excel SpreadsheetsWith Python and OpenPyXL

Collaborating with other users on Houndify

Using Homebrew on MAC

Space SIP Tournament — The Greatest Update in Play-to-Earn Mechanism

List View class

Custom BottomNavigationBar with custom images in flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
INSAID

INSAID

One of India’s leading institutions providing world-class Data Science & AI programs for working professionals with a mission to groom Data leaders of tomorrow!

More from Medium

Introduction Cloud computing on Amazon Web Services

Creating Custom AMIs for use in AWS SageMaker Studio

Control-M with AWS services

How to run EKS job with AWS state machine