Commit 08ce33e5 authored by guillermo.gomez's avatar guillermo.gomez
Browse files

deployment of documentation via gitlab.com pages

parent 0c290407
Pipeline #20690 passed with stages
in 4 minutes and 44 seconds
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 274b2d66364a7c4742fcdd412bbe42bb
tags: 645f666f9bcd5a90fca523b33c5a78b7
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>10. Annex 1. AI Models Server installation procedure &mdash; AIAgents for OSM latest documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="11. Annex 2. AI Agent Code" href="code.html" />
<link rel="prev" title="9. Acknowledgement" href="acknowledgement.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> AIAgents for OSM
<img src="_static/aiagents-logo.PNG" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="scope.html">1. Scope</a></li>
<li class="toctree-l1"><a class="reference internal" href="architecture.html">2. Understanding the Concept</a></li>
<li class="toctree-l1"><a class="reference internal" href="how_to_use.html">3. Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="how_to_contribute.html">4. Contribute to the code</a></li>
<li class="toctree-l1"><a class="reference internal" href="q_and_a.html">5. Q&amp;A</a></li>
<li class="toctree-l1"><a class="reference internal" href="roadmap.html">6. Roadmap</a></li>
<li class="toctree-l1"><a class="reference internal" href="license.html">7. Usage License</a></li>
<li class="toctree-l1"><a class="reference internal" href="contact.html">8. Contact</a></li>
<li class="toctree-l1"><a class="reference internal" href="acknowledgement.html">9. Acknowledgement</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">10. Annex 1. AI Models Server installation procedure</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#installing-tensorflow-serving">10.1. Installing TensorFlow Serving</a></li>
<li class="toctree-l2"><a class="reference internal" href="#configuring-ai-models">10.2. Configuring AI Models</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="code.html">11. Annex 2. AI Agent Code</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">AIAgents for OSM</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
<li><span class="section-number">10. </span>Annex 1. AI Models Server installation procedure</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/Annex1.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="annex-1-ai-models-server-installation-procedure">
<h1><span class="section-number">10. </span>Annex 1. AI Models Server installation procedure<a class="headerlink" href="#annex-1-ai-models-server-installation-procedure" title="Permalink to this headline"></a></h1>
<p>This Annex describes the step-by-step procedure for installing an <em>AI Models Server</em> instance based on
<a class="reference external" href="https://www.tensorflow.org/tfx/guide/serving">TensorFlow Serving</a>. It also describes the basics for configuring the AI Models deployed on it.</p>
<blockquote>
<div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>The installation is based on <a class="reference external" href="https://www.docker.com/resources/what-container">Docker Containers</a>, following the procedure described in <a class="reference external" href="https://github.com/brianalois/tensorflow_serving_tutorial.git">this</a> TensorFlow Serving Tutorial repo.</p>
</div>
</div></blockquote>
<div class="section" id="installing-tensorflow-serving">
<h2><span class="section-number">10.1. </span>Installing TensorFlow Serving<a class="headerlink" href="#installing-tensorflow-serving" title="Permalink to this headline"></a></h2>
<p>Let’s execute the following steps:</p>
<ol class="arabic">
<li><p>Clone the repo in your home directory:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git clone https://github.com/brianalois/tensorflow_serving_tutorial.git
</pre></div>
</div>
</div></blockquote>
</li>
<li><p>Install Docker:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>sudo apt install docker.io
</pre></div>
</div>
</div></blockquote>
</li>
</ol>
<ol class="arabic" start="3">
<li><p>Build the Dockerfile inside the tutorial repo folder (this process may take some minutes):</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span> tensorflow_serving_tutorial
<span class="gp">$ </span>sudo docker build --pull -t test-tensorflow-serving.
</pre></div>
</div>
</div></blockquote>
</li>
<li><p>Once the image is built, you can proceed to run it using:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span>sudo docker run -it -p <span class="m">8500</span>:8500 -p <span class="m">8501</span>:8501 -v /home/ubuntu/serving/tensorflow_serving/tools/docker/tensorflow_serving_tutorial/model_volume/:/home/ test-tensorflow-serving
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This command cannot be copy-pasted. You need to use your own absolute path for the
shared volume (-v). You can use “pwd” in your directory to copy the path.</p>
</div>
</li>
</ol>
<p>If everything worked properly, you should now see the shell of the container (you will see a different number in the prompt):</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">root@15954c4d0666:/#</span>
</pre></div>
</div>
</div></blockquote>
<ol class="arabic" start="5">
<li><p>Once inside the container’s terminal, you can deploy the server with:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">root@15954c4d0666:/# </span>tensorflow_model_server --port<span class="o">=</span><span class="m">8500</span> --rest_api_port<span class="o">=</span><span class="m">8501</span> --model_config_file<span class="o">=</span>/home/configs/models.conf
</pre></div>
</div>
</div></blockquote>
</li>
</ol>
<p>This command starts the server on port 8501 with some by-default AI Models already defined in the <em>models.conf</em> file. By default, the TensowrFlow Serving repo provides two models, named “xor” and “iris” (the “xor” model is an implementation of the well-known <a class="reference external" href="https://books.google.es/books?hl=en&amp;lr=&amp;id=PLQ5DwAAQBAJ&amp;oi=fnd&amp;pg=PR5&amp;dq=Minsky+and+Papert+(Perceptons:+An+introduction+to+Computational+Geometry,+&amp;ots=zzFzxMujW3&amp;sig=PIOuck_nYM_hUbNXq5_cXrQQARs#v=onepage&amp;q=Minsky%20and%20Papert%20(Perceptons%3A%20An%20introduction%20to%20Computational%20Geometry%2C&amp;f=false">XOR Problem</a>; the “iris” model is a sample model that can be used to classify different types of the <a class="reference external" href="https://en.wikipedia.org/wiki/Iris_(plant)">Iris</a> flower based on certain parameters).</p>
<ol class="arabic" start="6">
<li><p>Now that we have the server up and running let’s test it; you can do it by sending ‘curl’ requests to the AI Models Server; for instance, this one for quering the “iris” model:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">curl -X POST http://localhost:8501/v1/models/iris:classify -H &#39;cache-control: no-cache&#39; -H &#39;postman-token: f7fb6e3f-26ba-a742-4ab3-03c953cefaf5&#39; -d &#39;{ &quot;examples&quot;:[{&quot;x&quot;: [5.1, 3.5, 1.4, 0.2]}]}&#39;</span>
</pre></div>
</div>
</div></blockquote>
</li>
</ol>
<p>We should receive a response similar to this one:</p>
<blockquote>
<div><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="s2">&quot;results&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">[</span>
<span class="p">[</span>
<span class="s2">&quot;Iris-setosa&quot;</span><span class="p">,</span>
<span class="mf">0.872396886</span>
<span class="p">],</span>
<span class="p">[</span>
<span class="s2">&quot;Iris-versicolor&quot;</span><span class="p">,</span>
<span class="mf">0.108623177</span>
<span class="p">],</span>
<span class="p">[</span>
<span class="s2">&quot;Iris-virginica&quot;</span><span class="p">,</span>
<span class="mf">0.0189798642</span>
<span class="p">]</span>
<span class="p">]</span>
<span class="p">]</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
<p>(it seems the model is clasifiying the provided flower parameters as “Iris-setosa”; anyway, we will not enter in the details about the AI Model itself).</p>
</div>
<div class="section" id="configuring-ai-models">
<h2><span class="section-number">10.2. </span>Configuring AI Models<a class="headerlink" href="#configuring-ai-models" title="Permalink to this headline"></a></h2>
<p>The models available in the TensorFlow Serving are described in the ‘models.conf’ configuration file. It is possible to define multiple models (with multiple versions also) in a single docker container, which will be available through a common port.</p>
<p>This is the configuration for the by-default “xor” and “iris” models we’ve been mentioning above:</p>
<blockquote>
<div><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="p">{</span> <span class="n">config</span><span class="p">:</span> <span class="p">{</span>
<span class="n">name</span><span class="p">:</span> <span class="s2">&quot;xor&quot;</span><span class="p">,</span>
<span class="n">base_path</span><span class="p">:</span> <span class="s2">&quot;/home/models/xor&quot;</span><span class="p">,</span>
<span class="n">model_platform</span><span class="p">:</span> <span class="s2">&quot;tensorflow&quot;</span><span class="p">,</span>
<span class="n">model_version_policy</span><span class="p">:</span> <span class="p">{</span> <span class="nb">all</span><span class="p">:</span> <span class="p">{}</span> <span class="p">}</span>
<span class="p">},</span>
<span class="n">config</span><span class="p">:</span> <span class="p">{</span>
<span class="n">name</span><span class="p">:</span> <span class="s2">&quot;iris&quot;</span><span class="p">,</span>
<span class="n">base_path</span><span class="p">:</span> <span class="s2">&quot;/home/models/iris&quot;</span><span class="p">,</span>
<span class="n">model_platform</span><span class="p">:</span> <span class="s2">&quot;tensorflow&quot;</span><span class="p">,</span>
<span class="n">model_version_policy</span><span class="p">:</span> <span class="p">{</span> <span class="nb">all</span><span class="p">:</span> <span class="p">{}</span> <span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
<p>As we can see, the configuration file is a list of config objects. Each of them has:</p>
<blockquote>
<div><ul class="simple">
<li><p>name : the name of the model</p></li>
<li><p>base_path: indicates the directory in which the model itself is stored</p></li>
<li><p>model_platform: platform used for the model (‘tensorflow’ by-default)</p></li>
<li><p>model_version_policy: allows to define which version of the model will be in use (different versions are allowed).</p></li>
</ul>
</div></blockquote>
<p>To see how to generate and configure your own models you can check the step-by-step guide in Section 3.1.
Also, for additional information on the AI Models configuration you can access to the official <a class="reference external" href="https://www.tensorflow.org/tfx/guide/serving">TensorFlow Serving website</a>.</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="code.html" class="btn btn-neutral float-right" title="11. Annex 2. AI Agent Code" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="acknowledgement.html" class="btn btn-neutral float-left" title="9. Acknowledgement" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2021, ATOS SE.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment