<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Márcio Dos Santos on Medium]]></title>
        <description><![CDATA[Stories by Márcio Dos Santos on Medium]]></description>
        <link>https://medium.com/@marcio_santos?source=rss-4bd3124f2454------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pJ7Dad28ZPcWlhCzduuMQg.jpeg</url>
            <title>Stories by Márcio Dos Santos on Medium</title>
            <link>https://medium.com/@marcio_santos?source=rss-4bd3124f2454------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:02:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcio_santos/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to a create a SageMaker Execution role]]></title>
            <link>https://medium.com/ml-bytes/how-to-a-create-a-sagemaker-execution-role-539866910bda?source=rss-4bd3124f2454------2</link>
            <guid isPermaLink="false">https://medium.com/p/539866910bda</guid>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Márcio Dos Santos]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 04:39:37 GMT</pubDate>
            <atom:updated>2018-07-25T05:10:10.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tFl-8wQUENETYLjX5mYWuA.png" /></figure><p>As a managed service, Amazon SageMaker performs operations on your behalf on other AWS services.</p><p>To authorize SageMaker to do these operations, it is necessary to provide a role to AWS SageMaker. The script below creates a role name <strong>SagemakerRole </strong>with full access to S3.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e5ba9363d1fa497f4426545995454f9/href">https://medium.com/media/1e5ba9363d1fa497f4426545995454f9/href</a></iframe><p><strong>WARNING</strong>: This policy gives<strong> full S3 access </strong>to the container that is running in SageMaker. You can change this policy to a more restrictive one, or create your own policy.</p><h4>Related Articles:</h4><ul><li><a href="https://medium.com/ml-bytes/how-to-create-a-tensorflow-serving-container-for-aws-sagemaker-4853842c9751">How to Create a TensorFlow Serving Container for AWS SageMaker</a></li><li><a href="https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-repository-fba579a9f419">How to Push a Docker Image to AWS ECS Repository</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=539866910bda" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-bytes/how-to-a-create-a-sagemaker-execution-role-539866910bda">How to a create a SageMaker Execution role</a> was originally published in <a href="https://medium.com/ml-bytes">ml-bytes - Code snippets on how to productionize Machine Learning models</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy an AWS SageMaker Container Using TensorFlow Serving]]></title>
            <link>https://medium.com/ml-bytes/how-to-deploy-an-aws-sagemaker-container-using-tensorflow-serving-4587dad76169?source=rss-4bd3124f2454------2</link>
            <guid isPermaLink="false">https://medium.com/p/4587dad76169</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[serving]]></category>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Márcio Dos Santos]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 04:38:15 GMT</pubDate>
            <atom:updated>2018-07-25T05:03:37.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*XzLw3Ci6OKgJMsPBISHlRw@2x.jpeg" /></figure><p>In the previous articles we learned <a href="https://medium.com/p/4853842c9751/edit"><strong>how to create a TensorFlow Serving container for SageMaker</strong></a><strong> </strong>and <a href="https://medium.com/p/fba579a9f419/edit"><strong>how to push the container image to an ECS repository</strong></a><strong>.</strong></p><p>In the <a href="https://medium.com/p/fba579a9f419/edit">last article</a>, we created a docker image named <strong>sagemaker-tf-serving </strong>and pushed it to ECR. We will use that image to create a SageMaker endpoint.</p><p>This example requires an AWS IAM execution role authorizing SageMaker to use another AWS services. If you do not have a role, this <a href="https://medium.com/p/539866910bda">article teaches you <strong>how to create the execution role</strong>.</a> I’m assuming that you have an execution role name <strong>SageMakerRole</strong>.</p><h4>SageMaker Endpoints</h4><p>A SageMaker endpoint is a <strong>fully-managed, highly secure, </strong>hosting environment. It supports <strong>auto scaling, one click deployments, automatic A/B testing, and model versioning.</strong></p><p>An endpoint is composed of one or multiple models.</p><h4>Creating a SageMaker Model</h4><p>We will use the <strong>sagemaker-tf-serving </strong>image to create a <strong>SageMaker model. </strong>A <strong>SageMaker model</strong> is essentially a pointer to an ECS repository:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/565feb9b2f887ae580a466b529a938ca/href">https://medium.com/media/565feb9b2f887ae580a466b529a938ca/href</a></iframe><p>In the script above, we created the model <strong>half-plus-three-v1</strong> pointing the ECS image <strong>sagemaker-tf-serving</strong>. We are ready to create the endpoint.</p><h4>Creating the Endpoint Configuration</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10025df6ea6479a2efca570ce57e5ee0/href">https://medium.com/media/10025df6ea6479a2efca570ce57e5ee0/href</a></iframe><p>The script above creates an <strong>endpoint config </strong>named <strong>half-plus-three-config-v1</strong>. It determines that the endpoint will be composed of <strong>one instance type ml.c4.large</strong>. And that will be deployed with the mode <strong>half-plus-three-v1 </strong>that we created previously.</p><p>After creating the endpoint configuration, we create the endpoint using the command aws sagemaker create-endpoint --endpoint-name ${ENDPOINT_NAME} --endpoint-config-name ${ENDPOINT_CONFIG_NAME} .</p><p>I usually add the suffix -<em>v1 </em>for both the model and endpoint config names. It makes it easier to create new versions of the model, which I will cover that in future articles.</p><h4>Checking the Endpoint Status</h4><p>After creating an endpoint. You can use the command <strong>aws describe-endpoint --endpoint-name half-plus-three </strong>to check the endpoint status:</p><pre>$ <strong>aws sagemaker describe-endpoint --endpoint-name </strong><strong>half-plus-three</strong></pre><pre>{<br>  &quot;EndpointName&quot;: &quot;<strong>half-plus-three</strong>&quot;,<br>  &quot;EndpointArn&quot;: &quot;arn:aws:sagemaker:us-west-2:369233609183:endpoint/<strong>half-plus-three</strong>&quot;,<br>  &quot;EndpointConfigName&quot;: &quot;sagemaker-byoc-tf-serving&quot;,<br><strong>  &quot;EndpointStatus&quot;: &quot;Creating&quot;,<br></strong>  &quot;CreationTime&quot;: 1532266772.13,<br>  &quot;LastModifiedTime&quot;: 1532266772.13<br>}</pre><p>Next article will cover how to <a href="https://medium.com/p/8b423b9b316a/edit"><strong>make predictions against a</strong> <strong>SageMaker endpoint</strong></a><strong>!</strong></p><h4>Related Articles:</h4><ul><li><a href="https://medium.com/ml-bytes/how-to-create-a-tensorflow-serving-container-for-aws-sagemaker-4853842c9751">How to Create a TensorFlow Serving Container for AWS SageMaker</a></li><li><a href="https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-repository-fba579a9f419">How to Push a Docker Image to AWS ECS Repository</a></li></ul><p>Did you use the container? Do you have questions or requests for more articles? Add comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4587dad76169" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-bytes/how-to-deploy-an-aws-sagemaker-container-using-tensorflow-serving-4587dad76169">How to Deploy an AWS SageMaker Container Using TensorFlow Serving</a> was originally published in <a href="https://medium.com/ml-bytes">ml-bytes - Code snippets on how to productionize Machine Learning models</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Make Predictions Against a SageMaker Endpoint Using TensorFlow Serving]]></title>
            <link>https://medium.com/ml-bytes/how-to-make-predictions-against-a-sagemaker-endpoint-using-tensorflow-serving-8b423b9b316a?source=rss-4bd3124f2454------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b423b9b316a</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serving]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sagemaker]]></category>
            <dc:creator><![CDATA[Márcio Dos Santos]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 04:28:07 GMT</pubDate>
            <atom:updated>2018-09-14T13:51:52.829Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*jTpThXigFG7v7JD5z8VXiA@2x.jpeg" /></figure><p>In this article, we will use the endpoint <strong>half-plus-three </strong>that we created in the previous article <a href="https://medium.com/p/4587dad76169/edit"><strong>How to Create an AWS SageMaker Endpoint for Predictions</strong></a><strong> </strong>to make predictions against AWS SageMaker.</p><p>AWS CLI and AWS SDK provide <strong>sagemaker-runtime </strong>, the library responsible to make endpoint requests against SageMaker. The AWS SDK has versions available in the most common computer languages available.</p><p>The <strong>invoke-endpoint </strong>is the operation responsible to make predictions using <strong>aws sagemaker-runtime:</strong></p><h4>using AWS CLI to make requests</h4><pre>#!/usr/bin/env bash </pre><pre>ENDPOINT_NAME=half-plus-three </pre><pre><strong>aws sagemaker-runtime invoke-endpoint</strong> \<br><strong>--endpoint-name</strong> ${ENDPOINT_NAME} \<br><strong>--body</strong> &#39;{&quot;instances&quot;: [1.0,2.0,5.0]}&#39; <strong>prediction_response.json </strong></pre><pre>cat <strong>prediction_response.json</strong></pre><h4><strong>using boto3</strong></h4><pre>import json </pre><pre>import boto3 </pre><pre>client = boto3.client(&#39;runtime.sagemaker&#39;)<br> <br>data = {&quot;instances&quot;: [1.0,2.0,5.0]} </pre><pre>response = client.<strong>invoke_endpoint</strong>(<strong>EndpointName=</strong>&#39;half-plus-three&#39;,<br>                                  <strong>Body=</strong>json.dumps(data))</pre><pre>response_body = response[&#39;Body&#39;] <br>print(response_body.read())</pre><h4>using node</h4><pre>var AWS = require(&#39;aws-sdk&#39;);</pre><pre>var sageMakerRuntime = new <strong>AWS.SageMakerRuntime</strong>();</pre><pre>var params = {<br>  <strong>Body</strong>: new Buffer(&#39;{&quot;instances&quot;: [1.0,2.0,5.0]}&#39;),<br>  <strong>EndpointName</strong>: &#39;half-plus-three&#39;<br>};</pre><pre><strong>sageMakerRuntime.invokeEndpoint</strong>(params, function(err, data) {<br>  responseData = JSON.parse(Buffer.from(data.Body).toString(&#39;utf8&#39;))<br>  console.log(responseData);<br>});</pre><p>You have access to the entire list of examples below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/493b225905a4e2a857039c8a06ffc3bc/href">https://medium.com/media/493b225905a4e2a857039c8a06ffc3bc/href</a></iframe><h4>Related Articles:</h4><ul><li><a href="https://medium.com/ml-bytes/how-to-create-a-tensorflow-serving-container-for-aws-sagemaker-4853842c9751">How to Create a TensorFlow Serving Container for AWS SageMaker</a></li><li><a href="https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-repository-fba579a9f419">How to Push a Docker Image to AWS ECS Repository</a></li></ul><p>Did you use the container? Do you have questions or requests for more articles? Add comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b423b9b316a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-bytes/how-to-make-predictions-against-a-sagemaker-endpoint-using-tensorflow-serving-8b423b9b316a">How to Make Predictions Against a SageMaker Endpoint Using TensorFlow Serving</a> was originally published in <a href="https://medium.com/ml-bytes">ml-bytes - Code snippets on how to productionize Machine Learning models</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Push a Docker Image to AWS ECS Repository]]></title>
            <link>https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-repository-fba579a9f419?source=rss-4bd3124f2454------2</link>
            <guid isPermaLink="false">https://medium.com/p/fba579a9f419</guid>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <dc:creator><![CDATA[Márcio Dos Santos]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 04:20:44 GMT</pubDate>
            <atom:updated>2018-07-26T14:06:07.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UOVilOGnlIGljX2VRMNig.png" /></figure><p>The script below pushes a Docker image to an ECS repository.</p><p>We will use the image <strong>sagemaker-tf-serving </strong>created in <a href="https://medium.com/p/4853842c9751/edit"><strong>How to Create a TensorFlow Serving Container for AWS SageMaker</strong></a><strong>. </strong>To push another image, you need to change IMAGE_NAME to the name of the image that you want to push.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d3a5c38cffa08fa7c0d0fe97ee54fec/href">https://medium.com/media/4d3a5c38cffa08fa7c0d0fe97ee54fec/href</a></iframe><h4>Moving Forward With How to Push a Docker Image to AWS ECS Repository</h4><p>In the follow up articles you will learn:</p><ul><li><a href="https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-repository-fba579a9f419">How to Push a Docker Image to AWS ECS Repository</a></li><li><a href="https://medium.com/ml-bytes/how-to-deploy-an-aws-sagemaker-endpoint-4587dad76169">How to deploy an AWS SageMaker endpoint - Márcio Dos Santos - Medium</a></li><li><a href="https://medium.com/ml-bytes/how-to-make-predictions-against-a-sagemaker-endpoint-using-tensorflow-serving-8b423b9b316a">How to Make Predictions Against a SageMaker Endpoint Using TensorFlow Serving</a></li></ul><p>Did you use the container? Do you have questions or requests for more articles? Add comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fba579a9f419" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-repository-fba579a9f419">How to Push a Docker Image to AWS ECS Repository</a> was originally published in <a href="https://medium.com/ml-bytes">ml-bytes - Code snippets on how to productionize Machine Learning models</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a TensorFlow Serving Container for AWS SageMaker]]></title>
            <link>https://medium.com/ml-bytes/how-to-create-a-tensorflow-serving-container-for-aws-sagemaker-4853842c9751?source=rss-4bd3124f2454------2</link>
            <guid isPermaLink="false">https://medium.com/p/4853842c9751</guid>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[serving]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[tensorflow]]></category>
            <dc:creator><![CDATA[Márcio Dos Santos]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 03:53:35 GMT</pubDate>
            <atom:updated>2018-07-26T14:03:39.508Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzhD_h0xFtynYdEYyF8mBg.jpeg" /></figure><blockquote>I finished training my TensorFlow model, what should I do now?</blockquote><p><em>Finally, after hard work, study, and trial and error you finished your Neural Network to identify cancer in cartilage tissues. That is real cancer by the way. You’re ready to share your discovery until you realize how hard is to set up a scalable and secure 24/7 reliable web server…</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*XmZ9mSLdE33WJc9kzxQyzw.jpeg" /><figcaption>The most common internet meme that I found at least a little relevant to this article</figcaption></figure><p><strong>Not anymore.</strong> AWS SageMaker hosts your model so you only have to worry about curing cancer. Deploying your host in SageMaker gives you access to auto-scaling, multi-regional, and high available host endpoints. You can even do<strong> </strong>A/B testing. You might be thinking… <em>I’m in! What do I need to do?</em> The answer is that you need to <strong>provide a Docker container with your TensorFlow model</strong>. But, don’t worry, it’s super easy — I’ve got you covered.</p><p>In this tutorial, I will explain how to create and test locally a TensorFlow Serving container for AWS SageMaker.</p><h4><em>Why TensorFlow?</em></h4><p>Because it’s awesome, and everybody uses it. Ok, I admit that hipsters, and most of the more relevant Machine Learning researchers these days are on the PyTorch train. But, that it’s not the point. The point is that you can host <em>anything</em> in SageMaker and I had to start with <em>something</em>. If you consider “<em>something</em>” a high performance, scalable, reliable web server—enough said. Let’s get this thing done.</p><p>Let’s consider that you already transformed your model to the TensorFlow Serving saved model format. If you have not already done this, the following links are helpful:</p><ul><li><a href="https://www.tensorflow.org/guide/saved_model#build_and_load_a_savedmodel">How to build and load a saved model</a></li><li><a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md">The TensorFlow saved model</a> format</li><li>Use the <a href="https://www.tensorflow.org/guide/saved_model#cli_to_inspect_and_execute_savedmodel">CLI to inspect and execute the TensorFlow saved model</a></li></ul><p>The <a href="http://github.com/tensorflow/serving/">GitHub TensorFlow Serving</a> repository provides some ready to use saved models for testing.</p><p>For this example, download the model <strong>saved_model_half_plus_three</strong> from the <a href="http://github.com/tensorflow/serving/">GitHub TensorFlow Serving</a> repository:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e60965b191af6ec7665ca23acf558af7/href">https://medium.com/media/e60965b191af6ec7665ca23acf558af7/href</a></iframe><h4>How AWS SageMaker Containers Handle Serve Requests</h4><p>To be able to serve using AWS SageMaker, a container needs to implement a web server that handles the requests <strong>/invocations</strong> and <strong>/ping</strong>, on port 8080.</p><p>Client applications send POST requests to <strong>/invocations</strong> to receive predictions, usually the using AWS CLI, boto3, or a AWS SDK. The article <a href="https://medium.com/ml-bytes/how-to-make-predictions-against-a-sagemaker-endpoint-8b423b9b316a"><strong>How to Make Predictions Against an AWS SageMaker Endpoint</strong></a><strong> </strong>include some examples of these predictions.</p><p>SageMaker sends <strong>/ping</strong> requests to the container to check if the container is working.</p><p>Let’s create a container that handles these requests.</p><h4>Creating the TensorFlow Serving Image</h4><p>Create a file named <strong>Dockerfile </strong>with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/098b180044b6edddb4c4873d7023a40e/href">https://medium.com/media/098b180044b6edddb4c4873d7023a40e/href</a></iframe><p>Some notes about the <strong>Dockerfile</strong>:</p><ul><li>We are using the official <a href="https://hub.docker.com/r/tensorflow/serving/"><strong>tensorflow/serving</strong></a><strong> </strong>image. For GPU instances, you should use <strong>tensorflow/serving:latest-gpu</strong> instead.</li><li>AWS SageMaker inference requests and TensorFlow Servings requests don’t match the signature. We are using <strong>NGINX </strong>to receive a request in the format that AWS SageMaker expects and forwards it to TensorFlow Serving. This technique is called <strong>reverse proxy.</strong></li><li>We are copying inside the image of the <strong>TensorFlow Serving model </strong>(in our case, saved_model_helf_plus_three), and a <strong>nginx.conf, </strong>setting up the reverse proxy.</li><li>The <strong>ENTRYPOINT </strong>starts the services. <strong>TensorFlow Serving </strong>is configured to receive requests from <strong>saved_model_half_plus_three </strong>in the format <strong><em>localhost:8501/v1/models/half_plus_three:predict</em></strong></li></ul><p>Let’s take a deeper look at the <strong>nginx.conf</strong> file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/460c5da87faacbf6d1ae73032533bde1/href">https://medium.com/media/460c5da87faacbf6d1ae73032533bde1/href</a></iframe><p>With this configuration, <strong>NGINX </strong>will redirect requests in the format {<strong><em>address}:8080/invocations </em></strong><em>to </em><a href="http://localhost:8501/v1/models/half_plus_three:predict"><strong><em>http://localhost:8501/v1/models/half_plus_three:predict</em></strong></a><strong><em>, </em></strong><em>which is the request format expected by TF serving.</em></p><h4>Building the Docker Image</h4><p>Make sure you have <a href="https://store.docker.com/search?type=edition&amp;offering=community">Docker installed</a>.</p><p>The command docker build -t sagemaker-tf-serving . builds a docker image named <strong>sagemaker-tf-serving</strong>:</p><pre>$ <strong>docker build -t sagemaker-tf-serving .</strong></pre><pre>Step 1/5 : FROM tensorflow/serving<br>Step 2/5 : RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends nginx git<br>Step 3/5 : COPY saved_model_half_plus_three /saved_model_half_plus_three<br>Step 4/5 : COPY nginx.conf /etc/nginx/nginx.conf<br>Step 5/5 : ENTRYPOINT service nginx start | tensorflow_model_server --rest_api_port=8501  --model_name=half_plus_three  --model_base_path=/saved_model_half_plus_three</pre><pre>Successfully built ac2cc25f0ee6<br>Successfully tagged <strong>sagemaker-tf-serving:latest</strong></pre><h4>Testing the SageMaker Container locally</h4><p>docker run --rm -p 8080:8080 sagemaker-tf-serving starts the container and makes port 8080 available outside the container.</p><p>Now we are ready to make requests against the container:</p><pre>$ <strong>curl -X POST </strong><a href="http://localhost:8080/invocations"><strong>http://localhost:8080/invocations</strong></a><strong> -d &#39;{&quot;instances&quot;: [1.0,2.0,5.0]}&#39;</strong></pre><pre>{<br>    &quot;predictions&quot;: [3.5, 4.0, 5.5]<br>}</pre><p>The command above makes a <strong>POST </strong>request /<strong>invocations </strong>passing the payload {&quot;instances&quot;: [1.0,2.0,5.0]} as a JSON. Remember that the input and output format of a <strong>TF serving saved model </strong>is defined when the model is <strong>created.</strong></p><p>The request payload &#39;{&quot;instances&quot;: [1.0,2.0,5.0]}&#39; is in the same format expected by TensorFlow Serving. I will cover the <a href="https://www.tensorflow.org/serving/api_rest">TensorFlow Serving REST API</a> in future articles — make sure you are following me in medium and <a href="https://twitter.com/marcio_santos">Twitter</a> to get updates.</p><p><strong>We’re ready to deploy your container to SageMaker.</strong></p><h4>Moving Forward With Our SageMaker Container Using TensorFlow Serving</h4><p>In the follow up articles you will learn:</p><ul><li><a href="https://medium.com/ml-bytes/how-to-push-a-docker-image-to-aws-ecs-fba579a9f419"><strong>How to Push the Container Image to AWS ECS repository</strong></a></li><li><a href="https://medium.com/ml-bytes/how-to-deploy-an-aws-sagemaker-endpoint-4587dad76169"><strong>How to Deploy an AWS SageMaker Endpoint</strong></a></li><li><a href="https://medium.com/ml-bytes/how-to-make-predictions-against-a-sagemaker-endpoint-8b423b9b316a"><strong>How to Make Predictions Against a SageMaker Endpoint</strong></a></li></ul><h4>References</h4><ul><li><a href="https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-main.html?shortFooter=true"><strong>AWS SageMaker — </strong>Using Your Own Inference Code</a></li><li><a href="https://github.com/aws/sagemaker-tensorflow-container"><strong>GitHub — </strong>SageMaker TensorFlow Container</a></li><li><a href="http://nginx.org/en/docs/http/ngx_http_proxy_module.html"><strong>NGINX — </strong>Proxy Pass</a></li></ul><p>Did you use the container? Do you have questions or requests for more articles? Add comments below! <strong>And don’t forget to clap.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4853842c9751" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-bytes/how-to-create-a-tensorflow-serving-container-for-aws-sagemaker-4853842c9751">How to Create a TensorFlow Serving Container for AWS SageMaker</a> was originally published in <a href="https://medium.com/ml-bytes">ml-bytes - Code snippets on how to productionize Machine Learning models</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>