<?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 Utkarshkushwaha on Medium]]></title>
        <description><![CDATA[Stories by Utkarshkushwaha on Medium]]></description>
        <link>https://medium.com/@utkarsh.prt.w?source=rss-3d5e8d458837------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Utkarshkushwaha on Medium</title>
            <link>https://medium.com/@utkarsh.prt.w?source=rss-3d5e8d458837------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:47:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@utkarsh.prt.w/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[Turn Your Backend into an LLM Interface with an MCP Server using Spring AI]]></title>
            <link>https://medium.com/@utkarsh.prt.w/turn-your-backend-into-an-llm-interface-with-an-mcp-server-using-spring-ai-e42ed534d345?source=rss-3d5e8d458837------2</link>
            <guid isPermaLink="false">https://medium.com/p/e42ed534d345</guid>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[backend-architecture]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Utkarshkushwaha]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 19:23:35 GMT</pubDate>
            <atom:updated>2026-06-22T20:29:09.346Z</atom:updated>
            <content:encoded><![CDATA[<h3>MCP on Spring ?????</h3><p><em>Turn fragmented enterprise data into LLM-ready intelligence with a clean, extensible MCP design, powered by Spring AI.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wcwOu0oRVu74fiKNf2TBVQ.png" /></figure><p>A bit late to the party, but better late than never :)</p><p>Recently, I got the chance to work on a problem that’s both ubiquitous and surprisingly complex: making enterprise data truly accessible.</p><p>At scale, this becomes one of the hardest challenges organizations face today. Data is everywhere, spread across massive relational databases, Confluence pages, Google Docs, NoSQL stores, and countless internal tools.</p><p>While these sources may seem unrelated in isolation, understanding any real business or technical problem often requires stitching together context from multiple systems. You need to zoom out and connect the dots.</p><p>Traditional tools do exist to aggregate data from different sources. But when it comes to interconnecting that data in a meaningful way, so it can actually be explored, queried, and reasoned over, the problem is far from solved.</p><blockquote>Now this is where, LLMs start to provide real leverage.</blockquote><p>🗣️ “So basically… another wrapper? A few data sources, slap a ChatGPT or Claude API, and some glue code. What’s different now?”</p><p>To answer that, we first need to understand how MCP works. I think most of you might have probably come across it before, or at least heard the term.</p><p>But still let me try to picturize it for some cuties who might still be living under a rock</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*3zs_O76tJj909Jp6.gif" /></figure><p>Think of MCP as an integration layer that makes connections between tools, data sources, and LLMs seamless, almost like snapping together LEGO pieces.</p><p>It’s quickly becoming an emerging standard for connecting software systems with AI models. Developed by Anthropic in late 2024, MCP has already started reshaping how we think about integrating data and tools with LLMs.</p><p>So without further ado, let’s see how MCP helps us achieve our goal.</p><h3>Components of MCP Architecture</h3><ul><li><strong>Server</strong> (provides context: databases, file systems, Notion, etc.)</li><li><strong>Client</strong> (the consumer of these capabilities)</li><li><strong>Transport Layer</strong> (STDIO / HTTP streamable communication)</li><li><strong>Data Layer</strong> (typically JSON-RPC based)</li></ul><h4>MCP Server</h4><p>The MCP Server acts as a data and capability aggregator.</p><p>There can be multiple MCP servers in a system, each responsible for exposing a specific set of tools or data sources to the LLM in a <strong>plug-and-play manner</strong>, rather than relying on tightly coupled, manual integrations.</p><p>You can connect:</p><ul><li>Relational databases like Postgres or MySQL</li><li>Knowledge sources like Confluence (via APIs)</li><li>Issue trackers like Jira</li><li>Or any custom internal system</li></ul><p>In essence, any data source you want your LLM to interact with can be exposed via an MCP server.<br>MCP servers typically expose both <strong>tools (actions)</strong> and <strong>resources (readable data)</strong>, enabling LLMs not just to retrieve information, but also to interact with systems in a structured way.</p><h4>MCP Client</h4><p>The MCP Client acts as the <strong>consumer of capabilities exposed by MCP servers</strong>.</p><p>It is responsible for:</p><ul><li>Discovering available tools and resources</li><li>Sending structured requests</li><li>Receiving responses from servers</li></ul><p>One important thing to note is that the client itself does <strong>not make decisions, </strong>it simply acts as a communication layer. The actual decision of <em>which tool to call and when</em> is typically handled by the host application or the LLM.</p><h4>Transport Layer</h4><p>The Transport Layer defines <strong>how communication happens between the client and server</strong>.</p><p>MCP supports multiple transport mechanisms such as:</p><ul><li><a href="https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#stdio"><strong>STDIO</strong></a> (used for local integrations when client and server are on the same machine, which makes it very fast)</li><li><a href="https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http"><strong>HTTP (streamable)</strong></a><strong> </strong>for remote communication</li></ul><p>This abstraction allows MCP servers to be deployed either:</p><ul><li>Locally (for low-latency use cases), or</li><li>Remotely (for scalable, distributed systems)</li></ul><p>In simple terms, this is the <strong>plumbing layer</strong> that ensures smooth data flow between components.</p><h4>Data Layer</h4><p>The Data Layer in MCP is typically based on <strong>JSON-RPC</strong>, which provides a structured way to exchange messages.</p><p>Every interaction follows a well-defined format:</p><ul><li>Requests</li><li>Responses</li><li>Error handling</li></ul><p>This structure is crucial because it allows LLMs to:</p><ul><li>Understand available operations</li><li>Generate correct inputs</li><li>Reliably parse outputs</li></ul><p>In other words, the data layer acts as the <strong>contract</strong> that keeps communication predictable and machine-friendly.</p><h4>But how all of this works together ?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*63JeTuPBGcTX-sa9.jpg" /></figure><p>Think of an MCP server as a <strong>bartender</strong>, and the MCP client as the <strong>customer</strong>. You walk into a bar and ask the bartender for the menu. The bartender presents you with a list of available drinks, these are the <strong>tools exposed by the MCP server</strong>.</p><p>Based on your requirement (or “craving”), the decision is made on what to order. In the MCP world, this decision is typically made by the <strong>LLM or the host application</strong>, not the client itself.</p><p>Once the choice is made, the request is sent to the bartender, who prepares and serves the drink , just like an MCP server executes a tool and returns the result.</p><p><a href="https://modelcontextprotocol.io/docs/learn/architecture">Well, If you’re looking for a more technically fulfilling definition, you can find it here.</a></p><blockquote>So that was pretty much everything you need to know about the basics of how MCP works, now let’s see how we can actually use in a real backend?</blockquote><h3>Implementation using Spring AI</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z4QzZYCY_84k7kUO.jpeg" /></figure><h4>Why Spring AI?</h4><p>A significant portion of enterprise applications today are built using Java, which makes <strong>Spring AI</strong> a very natural choice for integrating AI capabilities into existing systems.</p><p>Spring AI is a relatively new framework, with its first stable release coming out in May last year. It aims to bring AI development into the familiar <strong>Spring ecosystem</strong>, allowing developers to build LLM-powered applications without stepping too far outside their existing workflows.</p><p>At a high level, it helps us to:</p><ul><li>Integrate with LLM providers (like OpenAI, Anthropic, etc.)</li><li>Work with vector databases for semantic search and RAG use cases</li><li>Build structured, maintainable AI-driven services</li><li>Orchestrate interactions between LLMs and external systems by leveraging <strong>MCP clients and servers</strong>, enabling a clean and modular integration layer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pFsSQagJTfJPn3eA.jpg" /></figure><h4>Let’s get Started !!</h4><p>In this section, we’ll build a simple <strong>MCP-compatible server using Spring AI</strong>.</p><p>This server will:</p><ul><li>Expose a set of tools that can be consumed by any MCP client</li><li>Be usable from environments like agent-enabled IDEs (e.g., VS Code)</li></ul><p>The goal is to demonstrate how we can make our backend systems <strong>directly accessible to LLM-powered clients in a plug-and-play manner</strong>.</p><p>First things first, let’s sort the dependencies</p><blockquote>In this blog, I’ll be using Maven for dependency management. If you’re using Gradle, the same dependencies can be added in your <em>build.gradle</em> file.</blockquote><p>Before adding individual Spring AI dependencies, we can include the Spring AI BOM</p><pre>&lt;dependencyManagement&gt;<br>    &lt;dependencies&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>            &lt;artifactId&gt;spring-ai-bom&lt;/artifactId&gt;<br>            &lt;version&gt;1.1.0&lt;/version&gt;<br>            &lt;type&gt;pom&lt;/type&gt;<br>            &lt;scope&gt;import&lt;/scope&gt;<br>        &lt;/dependency&gt;<br>    &lt;/dependencies&gt;<br>&lt;/dependencyManagement&gt;</pre><p>The BOM ensures that all Spring AI dependencies use <strong>compatible and aligned versions</strong>, so we don’t have to manually manage versions for each dependency.</p><p>Now, if you want to expose your MCP server over a<strong> </strong>streamable HTTP transport layer (recommended for remote deployments), you can use the following dependency (I’m also proceeding with this for my example) :</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-ai-starter-mcp-server-webmvc&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>For local integrations using the STDIO transport layer, it looks something like this:</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-ai-starter-mcp-server&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>Important application.properties configurations for running this MCP server using the HTTP streamable transport layer</p><pre><br>#mcp server<br>server.port=8181<br><br>spring.ai.mcp.server.name=mcp-inventory-management<br>spring.ai.mcp.server.version=0.0.1<br>spring.ai.mcp.server.description=MCP server for Inventory Management System<br><br>spring.ai.mcp.server.type=sync<br>spring.ai.mcp.server.protocol=streamable<br>spring.ai.mcp.server.stdio.enabled=false<br>spring.ai.mcp.server.request-timeout=30s<br>spring.ai.mcp.server.annotation-scanner.enabled=true</pre><p>Let’s take a simple <strong>inventory management</strong> scenario.</p><p>We’ll work with a small application backed by a SQLite database consisting of two tables: <strong>Stock</strong> and <strong>Material</strong>.</p><p>Our goal is to expose selected service layer methods as tools via our MCP server, allowing us to query inventory data using natural language.</p><p>In other words, instead of writing SQL queries or calling some REST API, an MCP-compatible client (like an IDE agent or chatbot) can directly interact with our system and fetch information such as:</p><ul><li>Current stock levels by Material Type</li><li>Material details</li><li>Stock Availability by location</li></ul><p>The project structure looks fairly similar to a standard Spring Boot application.</p><p>These layers follow the typical CRUD-based architecture that most backend applications use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*DFjhvs4nuy4sWfUJYcoG0A.png" /></figure><p>The main difference lies in the tools layer, this is where we bridge our existing application with the .</p><p>In the tools layer, we expose selected service methods as <strong>MCP tools</strong>, via the MCP Server allowing them to be discovered and invoked by MCP-compatible clients.</p><p>Spring AI provides a very seamless way to implement this using annotations, for MCP Server following annotations are available:</p><ul><li>@McpResource: Used to expose read-only data, typically accessed via URI-based patterns</li><li>@McpTool : Used to expose methods as tools (when you want to do more than just read), with automatic JSON schema generation handled under the hood</li><li>@McpPrompt : Helps define reusable prompt templates that guide LLM behavior</li><li>@McpComplete : Enables auto-completion capabilities, useful for suggesting inputs dynamically</li></ul><p>In my example I am using @McpTool annotation, with this we can expose any method as an MCP tool without worrying about low-level details like JSON-RPC handling, request parsing, or schema generation</p><p>All we need to do is define a method, annotate it, and Spring AI takes care of making it discoverable and callable by MCP clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cDXbbMYuVFHUQ0Q46b68Xg.png" /></figure><blockquote>While implementing MCP tools ensure that the name and description are clear and self-explanatory. These metadata fields are used by MCP clients and ultimately by LLMs to decide which tool to invoke for a given query. A well-defined name and description significantly improve the model’s ability to select the correct tool.</blockquote><h4>Results</h4><p>Once the server is up and running, it can be connected to any AI application that supports MCP servers, or to an IDE with agent capabilities.</p><p>In this example, I’ll be using <strong>Visual Studio Code</strong> with <strong>GitHub Copilot</strong> in agent mode to test the functionality.</p><p>Additionally, I’ll also demonstrate how to use the MCP Inspector to validate and debug tool outputs.</p><p><strong>VS Code Copilot</strong></p><blockquote>To configure your MCP server on vs code copilot, refer this <a href="https://code.visualstudio.com/docs/copilot/customization/mcp-servers">doc</a>.</blockquote><p>For this demo, I wanted to go beyond just raw JSON outputs.<br>The goal was to interact with the inventory management system using natural language, simulating a more realistic usage scenario where an LLM-powered agent queries backend systems directly.</p><p>Here are some example interactions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbizSjiQv5039J4QMlI2hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hy5QPzqkN2lHgHpXsOiEhQ.png" /></figure><p><strong>MCP Inspector</strong></p><p>Once you have nodejs installed on your machine you can run this command: npx @ModelContextProtocol/inspector</p><p>It should launch this webapp on your browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UNP-50jNLm6mRSbgJ57mjw.png" /></figure><p>Pass on your server URL and make sure to select the right Transport Type (Streamble HTTP in my case), then you can hit List Tools to see the list of available tools on your MCP server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*8DHuiOzXqPHKj2rmzA8Zcg.png" /></figure><p>In this example I am trying to fetch different materials against a material type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*qyA7obrqi-3H-H2Gz-kt7w.png" /></figure><p>Output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*EkTb3v6N59SRVoeSKGPy4A.png" /></figure><h4>Conclusion</h4><p>In this example, I used @McpTool to expose service layer methods as callable tools.</p><p>However, this can be extended further to expose <strong>read-only data and external systems</strong> using @McpResource.</p><p>With @McpResource, we can make things like:</p><ul><li>API responses</li><li>Database records</li><li>Static or dynamic data sources</li></ul><p>available to MCP clients in a structured way, without defining them as executable actions.</p><p>In a broader sense, MCP enables a clear separation of responsibilities across components.</p><p>MCP servers act as <strong>aggregators</strong>, bringing together data and capabilities from multiple systems such as databases, APIs, and external tools, and exposing them in a structured manner.</p><p>On the other hand, the MCP host (or the application driving the LLM) acts as the <strong>orchestrator</strong>, deciding which tools to invoke and how to combine results to fulfill a given task.</p><p>Together, they form a powerful system where data from diverse sources can be seamlessly stitched together and made accessible through a unified, LLM-driven interface.</p><p>This separation allows us to build systems that are both modular and intelligent, where servers focus on exposing capabilities, and hosts focus on reasoning and orchestration.</p><p>Hope this was helpful, adding the repo link <a href="https://github.com/utkarsh23kushwaha/inventory-mgmt-mcp">here</a>. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e42ed534d345" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Containerizing Nvidia DeepStream Apps]]></title>
            <link>https://medium.com/@utkarsh.prt.w/containerizing-nvidia-deepstream-apps-a62d5c01a150?source=rss-3d5e8d458837------2</link>
            <guid isPermaLink="false">https://medium.com/p/a62d5c01a150</guid>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[deepstream]]></category>
            <category><![CDATA[nvidia-docker]]></category>
            <category><![CDATA[nvidia-deepstream]]></category>
            <dc:creator><![CDATA[Utkarshkushwaha]]></dc:creator>
            <pubDate>Sat, 19 Aug 2023 19:18:24 GMT</pubDate>
            <atom:updated>2023-08-22T09:36:34.623Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine a situation in which real-time video streams from security cameras are intelligently analyzed to find objects, identify anomalies, and make important judgments while smoothly scaling to suit the needs of a busy metropolitan setting. Thanks to advancements in technology like Nvidia DeepStream, this futuristic vision is quickly becoming a reality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*oN9u5bQvWcX7KmX05d5Twg.png" /></figure><p>But as video analytics applications become more complicated, so does the demand for effective deployment and administration methods. Containerization can help in this situation. DeepStream applications can achieve unprecedented heights of flexibility, scalability, and repeatability by being enclosed within small, portable containers. Other than this the amount of time required to set up an environment in order to work with Deepstream is still a lot, and working with Deepstream containers can also help you save that setup time, and focus more on the development part.</p><p>In this article, I’ll be covering the issues that I faced during the containerization of Nvidia Apps, things you need to know before dockerizing Deepstream Apps, and how you can Dockerize Nvidia Deepstream Apps and run and develop Deepstream pipelines on any Device running on Nvidia GPU. (*which is compatible and capable of Handling Nvidia Deepstream)</p><p>So I am assuming two situations here :</p><p><strong>Category A</strong>. You have already developed a DeepStream App on your local machine and now want to containerize it <br><strong>Category B</strong>. You want to get started with Nvidia DeepStream and Instead of getting into the hassle of installation and everything you want to run Deepstream on a Docker Container.</p><p>Pre-requisites: <br>1. You should have an idea of what Nvidia Deepstream is and some experience in building Deepstream pipelines<br>2. Know what is docker, containerization, etc. (You can check out <a href="https://www.youtube.com/watch?v=eGz9DS-aIeY">NetworkChuck</a> or <a href="https://www.youtube.com/watch?v=17Bl31rlnRM">KunalKushwaha</a>, I found their tutorials really helpful)<br>3. Basic Linux Commands</p><p>Let’s get started :</p><ol><li>Install the Docker engine on your machine, since Nvidia DeepstreamSDK is only available on Linux, you can simply follow the installation steps from <a href="https://docs.docker.com/desktop/install/linux-install/">here</a> and I think you’d be good to go.</li><li>Installing the <a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html">Nvidia Container Toolkit</a>: If you want your containerized apps to leverage the compute capabilities of Nvidia GPUs, you’ll have to install this (basically you can&#39;t think of running Nvidia Deepstream in containers without having this installed on Host). The NVIDIA Container Toolkit allows users to build and run GPU-accelerated containers. The toolkit includes a container runtime <a href="https://github.com/NVIDIA/libnvidia-container">library</a> and utilities to automatically configure containers to leverage NVIDIA GPUs.</li></ol><blockquote>Follow this guide: <a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html">https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html</a> to install Nvidia Container Toolkit on your device (Comment down if you think I should write a dedicated blog on container toolkit installation)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*wwBAjN0PGG3-6LiPNe_bkQ.png" /><figcaption>Image Credits: <a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html">Nvidia-Docs</a></figcaption></figure><p>Now if you belong to <strong>Category B </strong>(as mentioned above), the steps are pretty simple ad straightforward. You can follow the steps given below in the order in which they are written and you can start building Video Analytics Pipeline on a container.</p><pre># Pull the latest DeepstreamSDK image from Nvidia Container Registry <br>#(I think this can act as good base image has all dependenices to run<br># .. Deepstream Apps you only need to install python bindings if you want<br># .. to work with DeepstreamSDK using Python)<br><br>sudo docker pull nvcr.io/nvidia/deepstream:6.3-sample<br><br># Run the container using this image, in interactive mode, and start playing <br># .. with Deepstream<br><br>sudo docker run -it --runtime nvidia --gpus all &lt;imageid or deepstream:6.3-sample&gt; /bin/bash</pre><p>The first command was to just pull the image from Nvidia Container Registry, but if the second command got you all confused, let me break it down for you.</p><ol><li>docker run: Run a new Docker container.</li><li>-it: Allocate an interactive terminal session within the container. This allows you to interact with the container&#39;s command-line interface.</li><li>--runtime nvidia: Specify the NVIDIA runtime for the container. This is used when the container needs to access NVIDIA GPUs, this is why we installed Nvidia Container Toolkit before.</li><li>--gpus all: Make all available GPUs accessible to the container, you can either set it to all, or any specific GPU accessible to your container</li><li>&lt;imageid&gt;: Replace &lt;imageid&gt; with the actual ID or name of the Docker image you want to run. This specifies the base image for the container.</li><li>/bin/bash: Start an interactive Bash shell (/bin/bash) inside the container.</li></ol><p>For the folks belonging to <strong>Category B</strong>, who already have developed a DeepStream app on their machine and now want to containerize it for either deployment or sharing the entire project with other teams.<br>You can create your own image using Dockerfile, where you can specify the installation for all other dependencies of your project place it in the directory of your project, and either run this command,<br>sudo docker build -t &lt;name&gt;:&lt;version&gt;</p><p>Or Just Add a docker-compose.yaml file in the same directory, using this file you can also take care of network configuration, and volume management if needed. <em>(if these terms sound foreign to you, then I’d suggest checking out some Docker Tutorial first) , </em>after that, you can simply run <br>sudo docker-compose up</p><p>Now you must be thinking about how to prepare a Dockerfile for containerizing Deepstream Apps: Here’s a sample Docker file for dGPU type device</p><pre># Choosing a deepstream base image<br>FROM nvcr.io/nvidia/deepstream:6.3-samples <br><br>#setting the workdir<br>WORKDIR /app<br><br>#copy the contents of cwd to image<br>COPY . . <br><br>#Like this you can add one or more packages to install that is needed by your app <br>RUN pip install xyz_package<br>RUN pip install abc_package<br><br># To get video driver libraries at runtime (libnvidia-encode.so/libnvcuvid.so)<br>ENV NVIDIA_DRIVER_CAPABILITIES $NVIDIA_DRIVER_CAPABILITIES,vide</pre><p>References : <a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_docker_containers.html">https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_docker_containers.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a62d5c01a150" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a simple Nvidia Deepstream Pipeline with HLS streaming capability]]></title>
            <link>https://medium.com/@utkarsh.prt.w/building-a-simple-nvidia-deepstream-pipeline-with-hls-streaming-capability-be7b26b3eeab?source=rss-3d5e8d458837------2</link>
            <guid isPermaLink="false">https://medium.com/p/be7b26b3eeab</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[nvidia-deepstream]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[object-detection]]></category>
            <dc:creator><![CDATA[Utkarshkushwaha]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 10:41:22 GMT</pubDate>
            <atom:updated>2023-08-22T09:33:54.419Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a simple Nvidia Deepstream Pipeline with HLS streaming</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*csieF0s24PZs29Nz" /><figcaption>Photo by <a href="https://unsplash.com/@pawel_czerwinski?utm_source=medium&amp;utm_medium=referral">Pawel Czerwinski</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Well, technically this should’ve been my first post on Nvidia Deepstream Series, but anyways better late than never, also earlier this was going to be “How to build your first Deepstream app” but then I found there are plenty of them already, plus a lot of basic pipeline examples are already provided in this repo which one can any time visit and understand how to build a basic pipeline, so I thought let’s take it a step forward, let’s try building a more generalized Pipeline, which can act as a boilerplate for your current or future projects.</p><p><em>Pre-requisites:<br>1. Knowledge of GStreamer Pipelines<br>2. Experience in Python Programming</em></p><p>All the code which has been shown/used in this article is from this git repo: <a href="https://github.com/utkarsh23kushwaha/Nvidia_Deepstream_BoilerPlate">https://github.com/utkarsh23kushwaha/Nvidia_Deepstream_BoilerPlate</a></p><h4>What is Nvidia Deepstream ??</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*vJn0Cj1iWFeE7YYF.gif" /></figure><p>If you’ve decided to read this article, then I guess you at least have a thin idea about DeepstreamSDK, but still, let me give a quick and short intro about it.</p><p><strong>The fancy way:</strong><br>In the rapidly evolving world of video analytics and AI-driven applications, Nvidia DeepStream has emerged as a cutting-edge solution, empowering developers to build sophisticated and efficient video processing pipelines. Whether you are delving into the realms of surveillance, smart cities, or industrial automation. It enables developers to build complicated Deep Learning Applications in a much easy to-handle and deploy manner. Built on top of Gstreamer (a popular multimedia processing framework) It allows harnessing GStreamer&#39;s extensive plugin ecosystem and combining it with Nvidia’s optimized hardware acceleration, DeepStream delivers an efficient and scalable solution for processing multiple video streams simultaneously.</p><p><strong>The simple way:</strong><br>Nvidia DeepstreamSDK is a software development kit, which allows developers to build video analytics, and deep learning pipelines using GStreamer elements and improve its performance using Nvidia’s hardware acceleration. Think of it like Lego pieces, to build the full architecture you need to combine Lego pieces together, it’s very much like that, but here you gotta be more careful about which piece to choose and where to place it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*-2LiAa5A2Imozgd1.gif" /></figure><p>Now if you want a more technically fulfilling definition, go through this: <a href="https://developer.nvidia.com/deepstream-sdk">https://developer.nvidia.com/deepstream-sdk</a> :)</p><h4><strong>Why DeepStream ??</strong></h4><p>Okay, now you have a decent enough idea about Deepstream, but the better question now would be why we need DeepstreamSDK, and an even better question would be who needs this?</p><p>Well if you’re looking for the toolkit which helps you deploy your Deep-Learning Models (Object Detection, Activity Detection, Object Segmentation) or if you want to build a video analytics app, Deepstream might be the solution you were looking for.</p><p>Now, why should one consider using DeepstreamSDK to build their Video Analytics products?</p><p>I’ll try to list a few :</p><ol><li><strong>Real-time Video Analytics</strong>: DeepStream enables real-time processing and analysis of video streams from multiple sources. This is essential for applications like surveillance, where quick and accurate detection of objects, events, or anomalies is crucial.</li><li><strong>Hardware Acceleration</strong>: Nvidia GPUs are renowned for their parallel processing capabilities, making them ideal for computationally intensive tasks like deep learning inference. DeepStream leverages this hardware acceleration to achieve high performance and efficiency in video analytics.</li><li><strong>Scalability</strong>: DeepStream is designed to handle multiple video streams concurrently, making it suitable for deployments that require analyzing data from numerous cameras or sensors at the same time.</li><li><strong>Easy Integration</strong>: By building on top of Gstreamer, DeepStream benefits from its extensive plugin ecosystem, simplifying the integration of AI models and enabling developers to focus on application-specific functionalities.</li><li><strong>Pre-optimized Models</strong>: Nvidia provides pre-trained deep learning models and optimized inference engines through TensorRT, facilitating the development process and ensuring high accuracy in video analytics tasks.</li><li><strong>Edge Computing Capabilities</strong>: DeepStream can be deployed on edge devices like Nvidia Jetson platforms, enabling video analytics to be performed at the edge of the network. This reduces latency, conserves bandwidth, and enhances privacy in certain applications.</li><li><strong>Wide Range of Applications</strong>: DeepStream is versatile and finds applications in various industries, including smart cities, retail, healthcare, transportation, industrial automation, and more.</li><li><strong>Intelligent Decision Making</strong>: By extracting meaningful insights from video data in real-time, DeepStream enables intelligent decision-making processes, improving operational efficiency and enhancing security.</li><li><strong>Developer-Friendly SDK</strong>: DeepStream provides a comprehensive and user-friendly SDK with documentation, sample applications, and tools, making it easier for developers to get started and build sophisticated video analytics solutions.</li></ol><h4>Understanding the Basic structure of the Pipeline</h4><p>As I’ve told you before, Nvidia Deepstream is built on top of GStreamer which means all the GStreamer elements, and the main idea of the “pipeline” is pretty much the same as those of a GStreamer pipeline. We just have a bunch of additional GStreamer elements in the case of Deepstream which help us to achieve our video analytics task.<br>So the basic structure is also pretty much the same, we have a source element that handles the video input: mp4 file (<strong>filesrc</strong>), or RTSP link (<strong>rtspsrc</strong>) of the camera, and in between we have video processing and Inferencing element<strong>s (nvstreammux), (nvvideoconvert), (nvinfer) ,(tracker), (nvod)</strong>, etc<strong> </strong>for first converting the video in desired video format, rescaling and color conversion and then performing inferencing on the video at last, we have a sink element for handling the video output, either saving it as file (<strong>filesink</strong>) or streaming the output using RTSP (<strong>udpsink</strong>) or HLS(<strong>hlssink</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*ykOZPHWN3aOQOAD7KrUoxg.png" /></figure><h4><strong>Building your first Deepstream Pipeline</strong></h4><p>Okay so, enough talking folks, let’s see the real thing, let’s get our hands dirty and build our first Deepstream pipeline</p><ol><li><strong>Device Requirements: </strong>First of all, let me clarify one thing, you need a machine with <strong>Nvidia GPUs</strong>, which runs <strong>Ubuntu OS</strong> or jetson devices (Orin, Nano, AGX) in order to work with Nvidia Deepstream SDK, for the latest version of Deepstream 6.2, you can go through this page for the exact requirements details: <a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/graphtools-docs/docs/text/GraphComposer_quickstart.html">https://docs.nvidia.com/metropolis/deepstream/dev-guide/graphtools-docs/docs/text/GraphComposer_quickstart.html</a></li><li><strong>Setting up Nvidia DeepstreamSDK and installing all the dependencies: <br></strong>For this step, I have a dedicated medium post and won&#39;t be discussing it here as it would be redundant.<br>Go through this I think everything must be pretty much clear :<br><a href="https://medium.com/@utkarshkushwaha72/nvidia-deepstreamsdk-installation-ce356d1e2a2"><strong>https://medium.com/@utkarshkushwaha72/nvidia-deepstreamsdk-installation-ce356d1e2a2</strong></a> (my medium post)<br><a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html"><strong>https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html</strong></a> (Nvidia’s Installation Guide) if you have trust issues 🤣 (Make sure you also install Python bindings if you want to follow along with this article)</li><li><strong>Let’s Build</strong>: So now get to the coding part, I’ll be writing my entire code in Python for building this pipeline, you also have the option to work in C++, examples of cpp apps are available in the installation folder of Deepstream inside : <br><em>/opt/nvidia/deepstream/deepstream-6.2/sources/apps</em> (for cpp examples)</li></ol><p>The objective of our pipeline: So the pipeline which we’re going to build today, is going to accept any number of video inputs in pretty much any form, perform Object Detection on it, and stream the video output as HLS streaming, and also extract metadata from the inferenced frames.</p><p>Intialize the GStreamer, create a pipeline.</p><blockquote>Important Note: I am only sharing snippets of code in this article, to get you an idea about how to use a particular element, you can/may visit my GitHub repo to see the entire code for the pipeline to get even clear idea.</blockquote><p><strong>Source:</strong> For handling the video input we will be using nvurisrcbin, why ?, because it selects a source element (like rtspsrc or filesrc) based on the raw input and sends it to the decode bin, which automatically handles tasks like depacketizing (in case of rtsp source), decoding and parsing of the input video and chooses best-suited elements, for achieving those tasks for that particular input type. <br>Also, it has special features like (auto-reconnect after a certain timeout) for the RTSP link and file loop for mp4/.h264/.h265 files</p><p><em>Note: When you’ll look at the full code, you’ll see input has been handled by a </em><em>create_source_bin function, and might not be able to make sense out of it but don&#39;t worry you leave that part as it is for now, I’ll create a separate article where I’ll discuss the need for that function</em></p><p><a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvstreammux2.html"><strong>Muxer</strong></a><strong>:</strong> Since we have multiple input sources we need an element to manage these streams and batch them together to send them downstream elements like nvinfer, tracker, etc. For this, we’ll be using nvstreammux</p><p>Nvstreammux is an essential element in DeepStream applications for combining multiple video streams into a single stream. It allows you to aggregate and synchronize multiple video streams from various sources, such as cameras, files, or network streams, before passing them to downstream components for further processing, analysis, or encoding.</p><p>The primary use of nvstreammux is to efficiently handle and batch-process video streams in parallel, taking advantage of the powerful parallel processing capabilities of NVIDIA GPUs. This batching enables more efficient utilization of the GPU, leading to better real-time performance in video analytics applications. In the older version of nvstreammux we had options to set the Height, Width of the frames, that are to be batched and many other useful properties like gpu-id, nvbuf-memory-typ etc. But in the new nvstreammux all of this was deprecated, and options like adaptive batching, and dynamic addition removal of batches were introduced.<br>I’d highly suggest going through each of these elements so that you have a better understanding of the data flow in the pipeline and the importance of each element.</p><blockquote>Important note: Whether you choose, new or old nvstreammux, try to keep the batch size to no. of sources, <strong>which means 1 frame per unique source,</strong> although in newer one if you have adaptive batching on, it will automatically set it to 1, or based on the priority of the source. Yes, in the new nvstreammux you can set the priority of the source, Also DO NOT confuse batch size of nvvstreammux with batch size of nvinfer, batch size of nvinfer simply means <strong>how many unique inputs we’ll have<em>.</em></strong></blockquote><p><a href="https://gstreamer.freedesktop.org/documentation/coreelements/queue.html?gi-language=c"><strong>Queue:</strong></a> The queue element of GStreamer helps to can control the flow of data through a pipeline, manage buffer size, and balance the load, we should ideally add it between nvinferand nvstreammuxbecause it’s quite possible that the rate of inference might not be the same as the rate of incoming data from the upstream element to tackle that we use a queue, to test and understand its usage, try removing the queue from the original code and run the pipeline, you’ll get an even better idea.</p><p><a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvinfer.html"><strong>Nvinfer:</strong></a> The nvinfer element is responsible for performing deep learning inference on the video frames received from the upstream components of the DeepStream pipeline. It leverages the power of NVIDIA GPUs to efficiently run deep neural networks and perform various AI-based tasks, such as object detection, classification, tracking, segmentation, and more. You can say this is the heart and soul of our Deep learning pipeline, this is where the magic happens, you can either use already available models in the deepstream installation folder, <em>(which are good but definitely not at all enough for varied use cases, and most probably won&#39;t fit your specific use case as well) </em>OR you can import your own custom models, as long as you can convert them into a form which is compatible with Deepstream.<br>Whatever your model&#39;s specs are, like batch size, labels file, model file, network mode etc, you can define it in a config.txt file and share the path of the config file in the config-file-path property of nvinfer. <br>This time I’ll be using Resnet 10 caffemodel available in Nvidia Deepstreams’s sample model folder. (4 class detection) , yes this is the one used in deepstream-test-1 app.</p><p><strong><em>A dedicated article on how to use custom models with Deepstream Python apps will come soon… :)</em></strong></p><p><a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvmultistreamtiler.html"><strong>Nvtiler:</strong></a> If you have multiple inputs and want to view all of them in a grid output then you should use nvmultistreamtilerelement for this. The element accepts batched NV12/RGBA data from upstream components and composites the tile based on stream IDs, obtained from NvDsBatchMeta and NvDsFrameMeta in row-major order (starting from source 0, left to right across the top row, then across the next row).</p><p><a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvdsosd.html"><strong>Nvvideoconvert</strong></a>&amp; Capsfilter<strong>: </strong>nvvideoconvert &amp; capsfilter is needed before the encoder, sets the color format and height and width of the output video</p><p><em>Note: Not only here you can use it anywhere between the pipeline, to convert the color format of the Buffer, if needed</em>.</p><p><a href="https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvdsosd.html"><strong>Nvdsosd:</strong></a> This is another important element of the pipeline, which is responsible for drawing bounding boxes, text, arrows, lines, circles, and region of interest (RoI) polygons. (Polygons are presented as a set of lines.) The plugin accepts an RGBA buffer with attached metadata from the upstream component when CPU process mode. It can accept RGBA/NV12 PL/NV12 BL buffer when GPU process mode. Basically, Whatever you see on the output, from bounding boxes to detection count, and labels on detected objects, it’s all done by this element</p><p><strong>Sink:</strong> For the sink, you have plenty of options, if you want to display the output on screen use nv3dsink for Jetson devices or nveglglessink for dGPUs, if you want to store the output as a file using filesink if you want to do nothing with the output and are more interested in the metadata simply use fakesink which will simply discard the output. But we will be using hlssink because we want to stream the output via HLS.</p><p>For using hlssink you need to add some more elements after nvdsosd which won&#39;t be needed in other sink elements, like filesink or fakesink <br>These are, another nvvideoconvert, capsfilter (to convert the output into your desired format and size), encoder (for encoding the video into desired codec .h264/.h265, parser (for parsing the encoded video), and a muxer( to multiplex various audio and video streams into a single MPEG-TS container which will be sent to hlssink for streaming)</p><blockquote>Now of course, you’ll need more things, a tracker, secondary inference engine, a stream demuxer, any other type of sink, with error handling capabilites to build a project that can be deployed in the real world, but more or less the basic structure of the pipeline is going to be like this, or you can take this as a reference, to build even more complex pipelines.</blockquote><p>If you feel like anything has been wrongly communicated or could’ve been explained differently feel free to comment and let me know :)</p><p>Test Video Source: <a href="https://www.pexels.com/video/video-of-famous-landmark-on-a-city-during-daytime-1721294/">https://www.pexels.com/video/video-of-famous-landmark-on-a-city-during-daytime-1721294/</a></p><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*J5-JA19REcRkbxePDw_k9w.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be7b26b3eeab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimising Performance in Nvidia Deepstream Pipelines]]></title>
            <link>https://medium.com/@utkarsh.prt.w/handling-memory-leaks-and-bottlenecks-in-nvidia-deepstream-pipeline-80e0ad70c9a3?source=rss-3d5e8d458837------2</link>
            <guid isPermaLink="false">https://medium.com/p/80e0ad70c9a3</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nvidia-deepstream]]></category>
            <category><![CDATA[troubleshooting]]></category>
            <category><![CDATA[gstreamer]]></category>
            <category><![CDATA[bottleneck]]></category>
            <dc:creator><![CDATA[Utkarshkushwaha]]></dc:creator>
            <pubDate>Sat, 22 Jul 2023 19:26:48 GMT</pubDate>
            <atom:updated>2024-09-04T19:58:37.054Z</atom:updated>
            <content:encoded><![CDATA[<p>Efficient video processing and real-time analytics have become critical components in various industries, ranging from surveillance and security to autonomous vehicles. NVIDIA DeepStream, a powerful video analytics framework, has emerged as a go-to solution for developing GPU-accelerated applications that harness the immense computational capabilities of NVIDIA GPUs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kger_T1UzuS12zb5" /><figcaption>Photo by <a href="https://unsplash.com/@carlosirineu?utm_source=medium&amp;utm_medium=referral">Carlos Irineu da Costa</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Although DeepStream provides unmatched video processing capability, memory management issues and performance bottlenecks are frequently a problem for developers. Memory leaks and poor data flow might decrease system stability, use up more resources, and limit the potential of your DeepStream application.</p><p>So, in this article, we’ll be looking at some of the ways to tackle these bottlenecks and memory leaks in a Deepstream pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*rTcuc2t5Rib0V2CJ.gif" /></figure><h3>Bottlenecks vs Memory leaks</h3><p>Bottlenecks are places or sections where the flow of data or processing is impeded, resulting in delays. It resembles a pipeline with a thin part that restricts the flow of water, slowing it down. Bottlenecks in computer systems can develop in a variety of areas, including the CPU, GPU, memory, disc, or network, and they impede the efficient completion of operations, resulting in decreased performance.</p><p>Memory leaks occur when a computer program fails to release or free up memory that is no longer needed, causing a gradual increase in memory usage over time. It’s like having a leak in a bucket, causing water to slowly overflow and be wasted.</p><p>Either of them, can be a good enough reason to ruin your day, or just extend your project deadline if you don’t how to deal with them correctly. So I have come up with a smol guide to figure out what possibly could be the reason behind your slowed or choked Deepstream Pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*Qzb3PvvyM6O046qT.gif" /></figure><h3>Let’s Get Started 🚀🚀:</h3><p><strong>1. Optimize GPU Usage:</strong> Utilize the GPU efficiently by offloading computationally intensive tasks to the GPU. Make sure to use appropriate CUDA memory types (nvbuf-mem-cuda-pinned, nvbuf-mem-cuda-device, or nvbuf-mem-cuda-unified) and manage data transfers between the CPU and GPU efficiently.</p><p>Give special attention to this when using nvtiler , nvstreammuxand multiple nvvideoconvertelements in your pipeline. Make sure they’re all using the same CUDA memory type : nvbuf-mem-cuda-unified <br>You can assign the CUDA memory types to the elements using .set_property() function</p><p>Note that: we have to take care of this only in dGPU-type devices like Tesla(T4), RTX series, NVIDIA GeForce® GTX series, A100, V100, etc.</p><p>Jetson type devices (Nano, Orin, AGX, etc), have a unified memory architecture, which enables access to the same memory address space by the CPU and GPU. Since the CPU and GPU already share the same memory pool, there is no need to explicitly configure nvbuf-memory-type for memory allocation or data transfers between the two.</p><p><strong>2. Unmap NvBufSurface for Jetson: </strong>If<strong> </strong>you’re extracting detected video frames using pyds.get_nvds_buf_surface(hash(gst_buffer)) make sure you unmap the buffer by : pyds.unmap.get_nvds_buf_surface(hash(gst_buffer)) <br>This will free the memory associated with the buffer after processing the frame and prevent potential memory leaks. (If you don&#39;t unmap this it will result in heavy memory utilization resulting in the pipeline getting slowed down or even killed if free memory gets too low.) On dGPU you don&#39;t have to worry about it. When working with dGPU devices, DeepStream’s functions internally manage the memory mapping and unmapping, making it transparent to the developer. DeepStream automatically handles memory transfers and ensures that resources are properly released after processing.</p><p><strong>3. Use the “queue” element: </strong>queue element of GStreamer is a blessing 🛐, you can control the flow of data through a pipeline, manage buffer size, and balance the load, using this element, and is very helpful in preventing bottlenecks. Try to add a queue between every element, especially between nvinfer and nvstreammux , A queue acts as a buffer, storing the incoming frames temporarily. If, for any reason, the downstream elements, experience a temporary delay or processing issue. To learn more about queue element <a href="https://gstreamer.freedesktop.org/documentation/coreelements/queue.html">click here.</a></p><p><em>Note: First read thoroughly about this element and it’s properties before implementing, don’t just use it anywhere and everywhere if you don’t know what you’re doing</em></p><p><strong>4. Profile and Monitor: </strong>Profile your application to identify bottlenecks and memory usage. Tools like NVIDIA’s nvprof and nsight-sys can help you analyze the performance of your DeepStream pipeline.</p><p><strong>5. Use GST DEBUG: </strong>You can also make use of the GST_DEBUG feature of GStreamer to get detailed log messages it has different levels of logging from 0 to 9, to implement it in Python script I can’t recall the correct way, I used it once, either it is Gst.Debug = 3 or os.environ[“GST_DEBUG”] = “3” , Google it, simple :)</p><ul><li>0: Errors only</li><li>1: Warnings</li><li>2: Info</li><li>3: Debug (useful for detailed debugging information)… till 9</li></ul><p>You can also use this to get a dot file of how the data is flowing through the pipeline, use graphviz to convert dot file to png.<br>Gst.debug_bin_to_dot_file(pipeline, GST_DEBUG_GRAPH_SHOW_ALL, “pipeline”)<br>It will look something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*c7Xz-v_Hsf1gWn8-A3WZkQ.png" /></figure><p>Definitely, your flowchart will change based on the elements you’ve used but yeah, I guess you get the idea. 🤔</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jrdF82-W_q6cKr3K" /><figcaption>Photo by <a href="https://unsplash.com/@frugalflyer?utm_source=medium&amp;utm_medium=referral">Frugal Flyer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>BONUS POINT</strong>: If you’re using caps filter element in your Deepstream pipeline, make sure you use (memory: NVMM), When working with NVIDIA hardware and accelerated video processing, using memory:NVMM ensures that the video frames are allocated in the NVIDIA Memory (NVMM), which is a special memory domain that provides direct access to the GPU. This memory type allows for efficient data transfer between the CPU and the GPU, avoiding unnecessary data copying and improving performance for video processing tasks.</p><p>Handling bottlenecks and memory leaks in DeepStream pipelines is essential to ensure optimal performance, stability, and resource efficiency. By implementing effective strategies and best practices, developers can create robust and scalable video analytics solutions.</p><p>I hope this blog helps you to either correctly figure out what was causing your pipeline to slow down, or narrow down the list of potential reasons to a few, or simply added something new to your brain’s encyclopedia. ;)</p><p>References: <br>1. <a href="https://developer.nvidia.com/blog/unified-memory-cuda-beginners/">https://developer.nvidia.com/blog/unified-memory-cuda-beginners/</a><br>2. <a href="https://docs.nvidia.com/metropolis/deepstream/5.0DP/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_app_config.3.2.html">https://docs.nvidia.com/metropolis/deepstream/5.0DP/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_app_config.3.2.html</a><br>3. <a href="https://deci.ai/blog/build-deepstream-pipeline/">https://deci.ai/blog/build-deepstream-pipeline/</a></p><p>Disclaimer: <strong>none</strong> of the content in this or other medium stories on my page contain any sensitive/proprietary data belonging to any institution, these are just a conglomeration of facts and information from varied sources and my personal experiences, if anyone has any issue with the ownership of the content being published here, please feel free to drop a comment and it will be responded asap.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80e0ad70c9a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>