<?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"><channel><title><![CDATA[Tech with Mirza]]></title><description><![CDATA[Tech with Mirza - Explore AWS, deep learning, cloud computing, product management, server management, devops, logging,leadership insights, and more. Expert guides await your discovery]]></description><link>https://mirzabilal.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1698575565075/_4ZQ99HEn.png</url><title>Tech with Mirza</title><link>https://mirzabilal.com</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Apr 2026 22:29:34 GMT</lastBuildDate><atom:link href="https://mirzabilal.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Fluent Bit + OpenObserve: The Ultimate Guide to Log Ingestion & Visualization]]></title><description><![CDATA[You can’t fix what you aren’t aware of. That’s why we log events to gain clear insight into what’s happening inside your system, even when you are not watching. Logs are one of the best ways, and sometimes the only option, to identify and fix issues....]]></description><link>https://mirzabilal.com/fluent-bit-openobserve-the-ultimate-guide-to-log-ingestion-and-visualization</link><guid isPermaLink="true">https://mirzabilal.com/fluent-bit-openobserve-the-ultimate-guide-to-log-ingestion-and-visualization</guid><category><![CDATA[Devops]]></category><category><![CDATA[backend]]></category><category><![CDATA[analytics]]></category><category><![CDATA[logging]]></category><category><![CDATA[ log-visualization]]></category><category><![CDATA[guide]]></category><category><![CDATA[step-by-step guide]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Mon, 11 Aug 2025 22:39:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455976698/49c21e4f-78bd-4c62-be2e-4dbc098416ab.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You can’t fix what you aren’t aware of. That’s why we log events to gain clear insight into what’s happening inside your system, even when you are not watching. Logs are one of the best ways, and sometimes the only option, to identify and fix issues.</p>
<p>Generally, applications emit so much data in a live environment that extracting meaningful information from a large dataset can be exhausting — especially when a production tech stack runs multiple types of applications, each outputting data in its own format and often scattered across systems. Things get more complicated for developers or DevOps engineers who are not proficient in UNIX text-processing tools like <code>grep</code>, <code>sed</code>, <code>awk</code>, etc. Identifying the problem is only the first step, and in production, time is never on your side. In those moments, we all wish we could visualize everything and see the whole picture instantly instead of sifting through endless lines of raw logs and columns.</p>
<p>Managing or implementing such a system is no mean feat. Managed solutions cost money or require you to send data outside your infrastructure, and it’s not always easy to justify the big bucks or the security trade-offs for something that isn’t a direct source of revenue. There are so many options available, but they are either expensive or fall short. After trying a plethora of combinations, I finally found the holy grail for logging infrastructure: <a target="_blank" href="https://fluentbit.io"><strong>Fluent Bit</strong></a> and <a target="_blank" href="https://openobserve.ai"><strong>OpenObserve</strong></a>. Both of these projects are open source, have free versions, are actively maintained, can be self-hosted easily, and work great in tandem.</p>
<p>In this guide, we’ll build a complete logging pipeline, from raw Nginx logs to ingestion and visualization, using Docker Compose to set up <strong>Fluent Bit</strong> and <strong>OpenObserve</strong> step by step. By the end, you’ll have a fully functional, end-to-end logging system that you can run locally for development or adapt for production environments.</p>
<h2 id="heading-architecture-overview">Architecture Overview</h2>
<p>Nginx writes its access and error logs to disk, where Fluent Bit picks them up, processes them according to our requirements, and sends them to OpenObserve via HTTP ingestion. LogRotate automatically handles log file rotation, preventing uncontrolled growth and archiving old data according to the defined retention policy. OpenObserve stores the logs—backed by a PostgreSQL metadata store—and makes them available for search and visualization through its web interface, as shown in the diagram.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754786001584/61db2214-ce39-44fd-8656-92b721677f57.png" alt="Architecture Overview" class="image--center mx-auto" /></p>
<h2 id="heading-setting-up-nginx-openobserve-amp-postgresql-containers">Setting up Nginx, OpenObserve &amp; PostgreSQL Containers</h2>
<p>We’ll start by spinning up three containers, <strong>Nginx</strong> for generating logs, <strong>PostgreSQL</strong> as the metadata store for OpenObserve, and <strong>OpenObserve</strong> itself for log ingestion, storage, and visualization.<br />Here’s the <code>docker-compose.yml</code> snippet:</p>
<pre><code class="lang-dockerfile">name: logging-infra

services:
  nginx:
    image: nginx:alpine
    container_name: nginx
    ports:
      - <span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>:<span class="hljs-number">8080</span>:<span class="hljs-number">80</span>
    volumes:
      - ./data/logs/nginx:/var/log/nginx
    restart: always
    depends_on:
      - postgres

  postgres:
    image: postgres:<span class="hljs-number">17</span>
    container_name: postgres
    ports:
      - <span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>:<span class="hljs-number">5432</span>:<span class="hljs-number">5432</span>
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=test1234
      - POSTGRES_DB=openobserve
    restart: always

  openobserve:
    image: openobserve/openobserve:v0.<span class="hljs-number">15.0</span>-rc5
    container_name: openobserve
    ports:
      - <span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>:<span class="hljs-number">5080</span>:<span class="hljs-number">5080</span>
    volumes:
      - ./data/openobserve:/data
    environment:
      - ZO_META_STORE=postgres
      - ZO_COMPACT_DATA_RETENTION_DAYS=<span class="hljs-number">14</span>
      - ZO_ROOT_USER_EMAIL=test@mirzabilal.com
      - ZO_ROOT_USER_PASSWORD=test1234
      - ZO_META_POSTGRES_DSN=postgres://postgres:test1234@postgres:<span class="hljs-number">5432</span>/openobserve?sslmode=disable
</code></pre>
<blockquote>
<p>Notes:</p>
<ul>
<li><p>The Nginx container will store logs in <code>./data/logs</code>.</p>
</li>
<li><p>PostgreSQL stores OpenObserve’s metadata in <code>./data/postgres</code>.</p>
</li>
<li><p>Data retention in OpenObserve is set to <strong>14 days</strong> for this demo, but you can adjust as needed.</p>
</li>
</ul>
</blockquote>
<p>After deploying with <code>docker-compose up</code>, you’ll be able to access the Nginx demo server at <a target="_blank" href="http://localhost:8080">http://localhost:8080</a> and the OpenObserve server at <a target="_blank" href="http://localhost:5080">http://localhost:5080</a>. You can also view the logs being generated in <code>./data/logs/nginx</code>.</p>
<h2 id="heading-openobserve-http-credentials">OpenObserve HTTP credentials</h2>
<p>OpenObserve HTTP credentials are <strong>different</strong> from dashboard login credentials. While the username is the same, the password is different. This is where OpenObserve’s excellent documentation comes to the rescue. After logging into the OpenObserve dashboard, navigate to:</p>
<blockquote>
<p><strong>Data Sources → Custom tab → Fluent Bit</strong></p>
</blockquote>
<p>You’ll see a sample Fluent Bit output configuration. In that configuration, locate the <code>Passwd</code> parameter — <strong>copy its value</strong>. We’ll need this password in the next step.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754789394448/d62908dd-9ecf-4cee-a19a-ce0e29a93668.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-setting-up-fluent-bit-container">Setting up Fluent Bit Container</h2>
<p>At this point, we have Nginx generating logs and OpenObserve ready to ingest and visualize them, but nothing is actually sending the logs over yet. This is where Fluent Bit comes in. Fluent Bit will tail Nginx log files, parse them into structured events, and forward them securely to OpenObserve using the HTTP API credentials we just retrieved.</p>
<p>Let’s add the <strong>Fluent Bit</strong> service to our <code>docker-compose.yml</code>. Now update the <code>OPENOBSERVE_API_PASSWORD</code> environment variable with the password we saved in the last step (from the <code>Passwd</code> field in OpenObserve’s Fluent Bit sample configuration). This value will be used in the Fluent Bit config files to authenticate with OpenObserve.</p>
<pre><code class="lang-dockerfile">  fluent-bit:
    image: fluent/fluent-bit:<span class="hljs-number">4.0</span>.<span class="hljs-number">7</span>
    container_name: fluent-bit
    volumes:
      <span class="hljs-comment"># Log volumes</span>
      - ./data/logs:/var/log/host:ro
      - ./data/logs/fluentbit-out:/fluentbit-out
      - ./data/logs/fluentbit-out/fluentbit-db:/fluentbit-db
      <span class="hljs-comment"># Mapping local config files and scripts</span>
      - ./config/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro
      - ./config/parsers.conf:/fluent-bit/etc/parsers.conf:ro
      - ./config/scripts:/fluent-bit/etc/scripts:ro
    restart: always
    environment:
      - OPENOBSERVE_API_USERNAME=test@mirzabilal.com
      - OPENOBSERVE_API_PASSWORD=T231Fquv <span class="hljs-comment"># This needs to be updated</span>
</code></pre>
<h2 id="heading-creating-fluent-bit-configurations">Creating Fluent Bit Configurations</h2>
<p>Now that our log sources, <strong>Nginx access</strong> and <strong>error</strong> logs are ready, we need to configure Fluent Bit to:</p>
<ol>
<li><p>Tail the log files we mounted from Nginx.</p>
</li>
<li><p>Apply the appropriate parser depending on the log type.</p>
</li>
<li><p>Send the structured events to the OpenObserve HTTP ingestion API.</p>
</li>
</ol>
<p>We’ll create two configuration files: <code>config/fluent-bit.conf</code> and <code>config/parsers.conf</code>.</p>
<h3 id="heading-1-creating-parsersconf">1. Creating <code>parsers.conf</code></h3>
<p>We will start with Nginx <strong>access log</strong> format. Here’s a real example:</p>
<pre><code class="lang-plaintext">172.19.0.1 - - [11/Aug/2025:19:46:57 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0" "-"
</code></pre>
<p>Our goal is to break this single log entry into structured fields:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Field</td><td>Extracted Value</td></tr>
</thead>
<tbody>
<tr>
<td><code>client_ip</code></td><td><code>172.19.0.1</code></td></tr>
<tr>
<td><code>ident</code></td><td><code>-</code></td></tr>
<tr>
<td><code>user</code></td><td><code>-</code></td></tr>
<tr>
<td><code>time</code></td><td><code>11/Aug/2025:19:46:57 +0000</code></td></tr>
<tr>
<td><code>method</code></td><td><code>GET</code></td></tr>
<tr>
<td><code>path</code></td><td><code>/</code></td></tr>
<tr>
<td><code>protocol</code></td><td><code>HTTP/1.1</code></td></tr>
<tr>
<td><code>status</code></td><td><code>304</code></td></tr>
<tr>
<td><code>size</code></td><td><code>0</code></td></tr>
<tr>
<td><code>referer</code></td><td><code>-</code></td></tr>
<tr>
<td><code>agent</code></td><td><code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0</code></td></tr>
</tbody>
</table>
</div><p>To do this, we’ll define a regex-based parser in <code>parsers.conf</code> that matches the log format and assigns each captured group a meaningful name. These field names will make it easier to query and visualize the data in OpenObserve.</p>
<p>We’ll also add a second parser to handle Nginx error logs.</p>
<p>Here’s the <code>config/parsers.conf</code>:</p>
<pre><code class="lang-plaintext">[PARSER]
    Name   nginx
    Format regex
    Regex ^(?&lt;client_ip&gt;\S+) (?&lt;ident&gt;\S+) (?&lt;user&gt;\S+) \[(?&lt;time&gt;[^\]]+)\] "(?&lt;method&gt;\S+) (?&lt;path&gt;[^"]*?) (?&lt;protocol&gt;HTTP\/[^"]+)" (?&lt;status&gt;\d{3}) (?&lt;size&gt;\d+|-) "(?&lt;referer&gt;[^\"]*)" "(?&lt;agent&gt;[^\"]*)
    Time_Key time
    Time_Format %d/%b/%Y:%H:%M:%S %z
    Time_Keep On

[PARSER]
    Name   nginx_error
    Format regex
    Regex  ^(?&lt;time&gt;[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9:]+) \[error\] \d+#\d+: \*\d+ (?&lt;message&gt;.*?), client: (?&lt;client_ip&gt;[^,]+), server: (?&lt;server&gt;[^,]+), request: "(?&lt;method&gt;\S+) (?&lt;path&gt;\S+) (?&lt;protocol&gt;[^"]+)", host: "(?&lt;host&gt;[^"]+)", referrer: "(?&lt;referer&gt;[^"]+)"
    Time_Key time
    Time_Format %Y/%m/%d %H:%M:%S
    Time_Keep On
</code></pre>
<h3 id="heading-2-creating-fluent-bitconf">2. Creating <code>fluent-bit.conf</code></h3>
<p>With our parsers file read to transform logs and error in to an structural format, we can configure Fluent Bit to tail the Nginx access and error logs, tag events, and send them to OpenObserve.</p>
<p>Our <code>config/fluent-bit.conf</code> sets up two tail inputs for the mounted log files, applies the correct parser for each, enriches them with metadata (e.g., <code>log_type</code> and <code>stage</code>), and outputs the structured JSON to OpenObserve’s HTTP ingestion endpoint.</p>
<pre><code class="lang-plaintext">[SERVICE]
    flush        1
    daemon       Off
    log_level    info
    parsers_file parsers.conf
    plugins_file plugins.conf
    storage.metrics on
    Mem_Buf_Limit 10MB
    Skip_Long_Lines On

[INPUT]
    Name   tail
    Path   /var/log/host/nginx.access.log
    Tag    nginx.access
    Parser nginx
    DB     /fluentbit-db/nginx-access.db

[INPUT]
    Name   tail
    Path   /var/log/host/nginx.error.log
    Tag    nginx.error
    Parser nginx_error
    DB     /fluentbit-db/nginx-error.db

[FILTER]
    Name modify
    Match  nginx*
    Rename time @timestamp

[FILTER]
    Name   modify
    Match  nginx.access
    Add    log_type access

[FILTER]
    Name   modify
    Match  nginx.error
    Add    log_type error

[FILTER]
    Name modify
    Match *
    Add stage production 

[OUTPUT]
    Name http
    Match nginx.*
    URI /api/default/nginx/_json
    Host openobserve
    Port 5080
    tls Off
    Format json
    Json_date_key    @timestamp
    Json_date_format iso8601
    HTTP_User ${OPENOBSERVE_API_USERNAME}
    HTTP_Passwd ${OPENOBSERVE_API_PASSWORD}
    compress gzip
</code></pre>
<p>This Fluent Bit config has four sections:</p>
<ul>
<li><p><code>[SERVICE]</code> → Sets global options like buffer size, logging level, parser files, and handling long lines.</p>
</li>
<li><p><code>[INPUT]</code> → Tails Nginx access and error logs, tags them, and applies the correct parser.</p>
</li>
<li><p><code>[FILTER]</code> → Renames the <code>time</code> field to <code>@timestamp</code>, adds <code>log_type</code> based on source, and sets <code>stage</code> to <code>production</code>.</p>
</li>
<li><p><code>[OUTPUT]</code> → Sends processed logs in JSON format to OpenObserve over HTTP with authentication and gzip compression.</p>
</li>
</ul>
<h2 id="heading-fluent-bit-configuration-with-lua-enhancements">Fluent Bit Configuration with Lua Enhancements</h2>
<p>With the Fluent Bit setup, we’ve configured tail inputs for both access and error logs, applied relevant parsers, tagged and enriched events with metadata, and sent everything off to OpenObserve in JSON format.<br />A real world example would be to make timestamps consistent across these logs (since Nginx’s access and error logs use different formats), a Lua script can normalize the timestamps to <code>ISO 8601</code> before forwarding them. This example Lua script, named <code>normalize_time.lua</code>, is available in the GitHub repository:</p>
<p><a target="_blank" href="https://github.com/bilalmughal/nginx-fluentbit-openobserve-stack/blob/main/config/scripts/normalize_time.lua">View the timestamp normalization Lua script</a></p>
<p>To use it, add a Lua filter to your Fluent Bit configuration:</p>
<pre><code class="lang-plaintext">[FILTER]
    Name    lua
    Match   *
    script  scripts/normalize_time.lua
    call    normalize_timestamp
</code></pre>
<h2 id="heading-full-working-example">Full Working Example</h2>
<p>If you’d like to see a complete, ready-to-run implementation of everything covered in this article—including Nginx, Fluent Bit, OpenObserve setup, parsers, the Lua timestamp normalization script, and a Logrotate service to automatically clean up logs based on your requirements so they never grow out of control—you can check out the GitHub repository:</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/bilalmughal/nginx-fluentbit-openobserve-stack">https://github.com/bilalmughal/nginx-fluentbit-openobserve-stack</a></div>
<p> </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755384808681/5f9099da-ef45-42db-9166-4a9cff40c53f.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755384827060/81851761-3b8b-44d6-84aa-9938a7a394ad.png" alt class="image--center mx-auto" /></p>
<p>Feel free to explore, adapt, and use it in your own projects.<br />⭐ If you find it helpful, consider giving the repo a star—it really helps others discover it and shows appreciation for the work.</p>
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>With the setup in this article, you can stream, parse, normalize, and visualize Nginx logs in real time using Fluent Bit and OpenObserve.<br />For production environments, make sure you handle sensitive credentials securely. For example:</p>
<ul>
<li><p>On AWS, use <strong>AWS Secrets Manager</strong></p>
</li>
<li><p>On GCP, use <strong>Secret Manager</strong></p>
</li>
<li><p>On Azure, use <strong>Key Vault</strong></p>
</li>
</ul>
<p>Avoid storing API keys or passwords directly in configuration files.</p>
<p>By combining proper parsing, normalization, and secure credential management, you’ll have a robust, scalable, and secure logging pipeline ready for real-world workloads.</p>
<hr />
<h2 id="heading-more-from-the-author">More From the Author</h2>
<ul>
<li><p><strong>Is AWS Deep Learning AMIs saving you time?</strong> <em>A counterproductive approach hindering your progress!</em> Learn About the Issues and Solution at <a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix">How Your AWS Deep Learning AMI is Holding You Back</a></p>
</li>
<li><p><strong>A Cost-Effective Creating Deep Learning AMIs deployment with Spot Instances:</strong> <em>Navigate parallel frontier!</em> Read the full article at: <a target="_blank" href="https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d">Deep Learning on AWS Graviton2 powered by Nvidia Tensor T4g</a></p>
</li>
<li><p><strong>Fine-Tune FFmpeg for Optimal Performance with detailed compilation guide:</strong> <em>Optimize your multimedia backend for optimal performance!</em>. A comprehensive guide is available at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source">Tailor FFmpeg for your needs</a>.</p>
</li>
<li><p><strong>GPU Acceleration for FFmpeg:</strong> <em>A Step-By-Step Guide with Nvidia GPU on AWS!</em> Check the complete guide at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws">Enable Harware Accelaration with FFmpeg</a></p>
</li>
<li><p><strong>CPU vs GPU Benchmark for video Transcoding on AWS:</strong> <em>Debunking the CPU-GPU myth!</em> See for yourself at <a target="_blank" href="https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth">Challenging the Video Encoding Cost-Speed Myth</a></p>
</li>
<li><p><strong>Crafting the Team for Sustainable Success:</strong> <em>Are "Rockstars" the Ultimate Solution for a Thriving Team?</em> Explore the insights at <a target="_blank" href="https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success">Beyond Rockstars</a></p>
</li>
<li><p><strong>How "Builders" Transform Team's Productivity:</strong> <em>Navigating Vision &amp; Ideas to Reality!</em> Discover more about Builders at <a target="_blank" href="https://mirzabilal.com/bridging-dreams-and-reality-how-builders-transform-teams">Bridging Dreams and Reality</a></p>
</li>
<li><p><strong>Mental Well-being in Tech:</strong> <em>Cultivating a Healthier Workplace for Tech Professionals</em> Explore insights: <a target="_blank" href="https://mirzabilal.com/the-dark-side-of-high-tech-success-addressing-mental-well-being-in-tech">The Dark Side of High-Tech Success!</a></p>
</li>
<li><p><strong>Freelancer to Full-Time:</strong> <em>Understanding Corporate Reluctance. Discover insights at</em> <a target="_blank" href="https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons">Why Businesses Hesitate to Employ Freelancers</a></p>
</li>
<li><p><strong>Transitioning from Freelancer to Full-Time:</strong> <em>Hurdles to Overcome!</em> Check out <a target="_blank" href="https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons">Why Businesses Hesitate to Employ Freelancers</a></p>
</li>
<li><p><strong>Scaling the Cloud:</strong> <em>Discover the Best Scaling Strategy for Your Cloud Infrastructure at</em> <a target="_blank" href="https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies">Vertical and Horizontal Scaling Strategies</a></p>
</li>
<li><p><strong>The Future of Efficient Backend Development:</strong> <em>Efficient Backend Development with Outerbase!</em> Discover the details at <a target="_blank" href="https://mirzabilal.com/building-a-robust-backend-in-just-30-minutes-with-outerbase">Building a Robust Backend with Outerbase</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[The Downside of Vertical Scaling GPU Instances]]></title><description><![CDATA[The artificial intelligence, machine learning, and generative AI application's growth have swelled the demand for high-performance GPU workloads. To fulfill these needs, cloud services have introduced a broad range of instances to fulfill diverse nee...]]></description><link>https://mirzabilal.com/the-downside-of-vertical-scaling-gpu-instances</link><guid isPermaLink="true">https://mirzabilal.com/the-downside-of-vertical-scaling-gpu-instances</guid><category><![CDATA[gpu intensive tasks]]></category><category><![CDATA[gpu-workloads]]></category><category><![CDATA[GPU]]></category><category><![CDATA[Hardware Acceleration]]></category><category><![CDATA[AWS Graviton Processors]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Sun, 14 Jan 2024 09:38:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755442538136/bc574928-59ea-4443-9b5d-1abf89a7a161.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The artificial intelligence, machine learning, and generative AI application's growth have swelled the demand for high-performance GPU workloads. To fulfill these needs, cloud services have introduced a broad range of instances to fulfill diverse needs. For many <a target="_blank" href="https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies#heading-vertical-scaling">vertical scaling</a> has been an quick fix to increase computational power by replacing a smaller instance with a more powerful one. However, this methodology might be less effective, or even pointless for GPU-intensive workloads.</p>
<h2 id="heading-understanding-gpu-workloads">Understanding GPU Workloads</h2>
<p>GPUs are designed for high-speed mathematical calculations. These specialized computational capabilities make them a good choice or for some applications the only option for handling large dataset mathematical operations in machine learning (ML) and video editing. CPUs primary aim is to perform sequential task execution, whereas GPUs excel as the workhorses when it comes to deep learning, 3D rendering, and scientific computations.</p>
<h2 id="heading-the-basics-of-gpu-scaling">The Basics of GPU Scaling</h2>
<p>Instances can be scaled vertically, horizontally or through a combination of both as explained <a target="_blank" href="https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies">here</a>. The Vertical scaling strategy means upgrading to a larger server with more computational power, such as CPU, memory, and GPU. The Horizontal scaling strategy involves adding more instances instead of upgrading the current one, hence increasing resources in parallel, very much like buying additional properties in the neighborhood to accommodate your growing family.</p>
<h2 id="heading-limitations-of-vertical-scaling-for-gpus">Limitations of Vertical Scaling for GPUs</h2>
<p>Vertical scaling's effectiveness is evident when we need more CPU or memory resources, but it hits a roadblock with GPU workloads. This is because upgrading to a larger instance does not necessarily increase the GPU's computational power. For example, the <a target="_blank" href="https://instances.vantage.sh/?filter=g5g%7Cg4dn&amp;sort=gpus">g5g.large and g4dn.large</a> instances from AWS both house the Nvidia Tesla T4 and T4G respectively. Despite any vertical scaling between these instance types, the GPU power remains unchanged, as they contain the same number of GPU cores as shown in the following image. Hence vertical scaling will not address the actual bottleneck in GPU-intensive tasks.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755442594487/25197fc2-361b-46e0-a7e9-00d1101fb763.webp" alt class="image--center mx-auto" /></p>
<h2 id="heading-practical-implications">Practical Implications</h2>
<p>The implication is evident: when your application demands more GPU power, vertically scaling your instance will not deliver the required performance improvements. This inefficiency can lead to not just stagnant performance, but also increased costs, as you are paying for additional CPU and memory resources that your workload may never utilize.</p>
<h2 id="heading-an-alternative-to-vertical-scaling">An alternative to Vertical Scaling</h2>
<p>When the bottleneck is GPU computational capabilities, horizontal scaling becomes a more viable solution. By adding more instances to your cloud infrastructure, you can achieve a near-linear increase in GPU capabilities. Horizontal scaling with right kind of servers will improve your infrastructure's resource utilization, thus offering a more cost-effective solution. Training an ML model with a vertically scaled server will add more CPU and memory but will not improve GPU power. Therefore, there will not be any improvement in training time. Shifting to horizontal scaling, with multiple GPU instances working in tandem, can significantly reduce the training time, showcasing the right approach to scaling for such tasks.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>While vertical scaling offers a quick solution for prompt performance boost in certain scenarios, it falls short with GPU instances option available. I highly recommend checking out <a target="_blank" href="https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies">horizontal and vertical scaling</a> for a deeper understanding of when to employ each strategy. A nuanced grasp of these scaling methods is crucial for optimizing performance and effective cost management in various computational scenarios. For tasks that are GPU-bound, adding more GPU power through horizontal scaling or re-architecting the solution is often the more effective path. Even for horizontal scaling, opt for the least powered instance, such as <strong>G5g.xlarge</strong> or <strong>G4dn.xlarge</strong>, to avoid paying for extra unused CPU power that is not required. Adopting the right scaling strategy, you can ensure that your infrastructure is not just robust but also cost-effective and performance-optimized for your specific computational needs.</p>
<h2 id="heading-more-from-the-author">More From the Author</h2>
<ul>
<li><p><strong>Is AWS Deep Learning AMIs saving you time?</strong> <em>A counterproductive approach hindering your progress!</em> Learn About the Issues and Solution at <a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix">How Your AWS Deep Learning AMI is Holding You Back</a></p>
</li>
<li><p><strong>A Cost-Effective Creating Deep Learning AMIs deployment with Spot Instances:</strong> <em>Navigate parallel frontier!</em> Read the full article at: <a target="_blank" href="https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d">Deep Learning on AWS Graviton2 powered by Nvidia Tensor T4g</a></p>
</li>
<li><p><strong>Fine-Tune FFmpeg for Optimal Performance with detailed compilation guide:</strong> <em>Optimize your multimedia backend for optimal performance!</em>. A comprehensive guide is available at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source">Tailor FFmpeg for your needs</a>.</p>
</li>
<li><p><strong>GPU Acceleration for FFmpeg:</strong> <em>A Step-By-Step Guide with Nvidia GPU on AWS!</em> Check the complete guide at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws">Enable Harware Accelaration with FFmpeg</a></p>
</li>
<li><p><strong>CPU vs GPU Benchmark for video Transcoding on AWS:</strong> <em>Debunking the CPU-GPU myth!</em> See for yourself at <a target="_blank" href="https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth">Challenging the Video Encoding Cost-Speed Myth</a></p>
</li>
<li><p><strong>Crafting the Team for Sustainable Success:</strong> <em>Are "Rockstars" the Ultimate Solution for a Thriving Team?</em> Explore the insights at <a target="_blank" href="https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success">Beyond Rockstars</a></p>
</li>
<li><p><strong>How "Builders" Transform Team's Productivity:</strong> <em>Navigating Vision &amp; Ideas to Reality!</em> Discover more about Builders at <a target="_blank" href="https://mirzabilal.com/bridging-dreams-and-reality-how-builders-transform-teams">Bridging Dreams and Reality</a></p>
</li>
<li><p><strong>Mental Well-being in Tech:</strong> <em>Cultivating a Healthier Workplace for Tech Professionals</em> Explore insights: <a target="_blank" href="https://mirzabilal.com/the-dark-side-of-high-tech-success-addressing-mental-well-being-in-tech">The Dark Side of High-Tech Success!</a></p>
</li>
<li><p><strong>Freelancer to Full-Time:</strong> <em>Understanding Corporate Reluctance. Discover insights at</em> <a target="_blank" href="https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons">Why Businesses Hesitate to Employ Freelancers</a></p>
</li>
<li><p><strong>Transitioning from Freelancer to Full-Time:</strong> <em>Hurdles to Overcome!</em> Check out <a target="_blank" href="https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons">Why Businesses Hesitate to Employ Freelancers</a></p>
</li>
<li><p><strong>Scaling the Cloud:</strong> <em>Discover the Best Scaling Strategy for Your Cloud Infrastructure at</em> <a target="_blank" href="https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies">Vertical and Horizontal Scaling Strategies</a></p>
</li>
<li><p><strong>The Future of Efficient Backend Development:</strong> <em>Efficient Backend Development with Outerbase!</em> Discover the details at <a target="_blank" href="https://mirzabilal.com/building-a-robust-backend-in-just-30-minutes-with-outerbase">Building a Robust Backend with Outerbase</a></p>
</li>
<li><p><strong>GPU Acceleration for FFmpeg:</strong> <em>A Step-By-Step Guide with Nvidia GPU on AWS!</em> Check the complete guide at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws">Enable Harware Accelaration with FFmpeg</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Scaling the Cloud: Vertical and Horizontal Scaling Strategies]]></title><description><![CDATA[In the ever-expanding digital empire, a multitude of apps and solutions emerge with the intent to simplify human lives and boost productivity. As the demand grew, cloud services have been proactive in providing diverse array of options to cater these...]]></description><link>https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies</link><guid isPermaLink="true">https://mirzabilal.com/scaling-the-cloud-vertical-and-horizontal-scaling-strategies</guid><category><![CDATA[cloud scalability]]></category><category><![CDATA[horizontal scaling]]></category><category><![CDATA[optimization]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[scalability]]></category><category><![CDATA[cost-optimisation]]></category><category><![CDATA[Infrastructure-as-a-Service (IaaS) Market]]></category><category><![CDATA[vertical scaling]]></category><category><![CDATA[AWS]]></category><category><![CDATA[GCP]]></category><category><![CDATA[Azure]]></category><category><![CDATA[alibaba cloud]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Sat, 06 Jan 2024 23:16:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755457174166/2fe06172-bfb5-4f70-86ee-28354a48e8de.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the ever-expanding digital empire, a multitude of apps and solutions emerge with the intent to simplify human lives and boost productivity. As the demand grew, cloud services have been proactive in providing diverse array of options to cater these needs. Organizations strive for an cost-effectiveness infrastructure without compromising on quality of service.</p>
<p>The need to efficiently scale infrastructure has never been greater. No infrastructure can remain stagnant, and inevitably, scaling is needed to match these growing needs. In this article, I will discuss the idea of horizontal and vertical scaling, delving into the details of each approach. This writing aims to provide insights into which scaling strategy and which methodology will best suit your specific requirements. Thus helping you make the informed decisions to fulfill infrastructure needs.</p>
<h2 id="heading-vertical-scaling">Vertical Scaling</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755457367408/5289361c-b224-40c6-b10f-ed5498ba255e.webp" alt class="image--center mx-auto" /></p>
<p>Picture a house, meeting your needs comfortably. Life is good; everything fits adequately within available space. However, as your family grows and your lifestyle evolves, the need for additional space becomes apparent. To address this demand, you opt to extend upwards, and adds more floors to meet your expanding requirements.</p>
<p>Let's draw a parallel to this housing expansion in terms of cloud infrastructure. Imagine you have an AWS <strong>C6g.large</strong> instance with 2 vCPUs and 4GiB of Memory to process PDF documents. It has served you well for a while, but as your product gains more traction, the demand for processing PDFs increases and now you need more computational power. To address this demand, you replace <strong>C6g.large</strong> instance with a larger one, like <strong>C6g.xlarge</strong> with 4 vCPUs and 8GiB of memory. This upgrade effectively adds more "floors" to your digital dwelling, theoretically allowing you to process twice as many PDFs as compared to the previous instance. This phenomenon of replacing a smaller instance with a larger one is termed as "Vertical Scaling" in the cloud computing landscape.</p>
<h2 id="heading-horizontal-scaling">Horizontal Scaling</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755457375547/aff3dea2-f910-4485-a219-e97c8cebe4df.webp" alt class="image--center mx-auto" /></p>
<p>Imagine the same scenario where your home has become insufficient to match your growing needs. However, instead of stacking more floors onto the existing structure, you decide to build or buy an adjacent building. Let's relate this house expansion strategy with increasing processing capability of cloud computing where your C6g.large instance is insufficient to process ever increasing PDF document processing. Instead of replacing the existing instance with a larger one, you adopt a different strategy. You decide to add another C6g.large instance to your computing arsenal. Each instance operates independently but contributes to the overall processing power. This concept of adding replica instances is known as "Horizontal Scaling" in the cloud computing realm.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>Vertical and Horizontal Scaling both strategies play a crucial role in optimizing computational resources. Vertical scaling, with its simplicity in enhancing power without altering workloads, offers a straightforward approach for immediate performance improvements. On the other hand, horizontal scaling stands out in cloud computing for its remarkable flexibility, allowing easy adjustment of resources to meet fluctuating demands. However the most effective solutions often emerge from a hybrid approach: optimizing an instance through vertical scaling to align precisely with targeted workload requirements and then employing this tailored size within a horizontal scaling framework. This combination harnesses the strengths of both vertical and horizontal scaling, providing a robust and adaptable infrastructure for various computing needs.</p>
<h2 id="heading-more-from-the-author">More From the Author</h2>
<ul>
<li><p><strong>Dark Truth about AWS Deep Learning AMIs:</strong> <em>The Silent Roadblock to Your Success!</em> Learn How to Break Free at <a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix">How Your AWS Deep Learning AMI is Holding You Back</a></p>
</li>
<li><p><strong>Cost-Effective Deep Learning with Custom AMIs and Spot Instances:</strong> <em>Discover Cutting-Edge Insights!</em> Explore the full article: <a target="_blank" href="https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d">Deep Learning with AWS Graviton2 and Nvidia Tensor T4g</a></p>
</li>
<li><p><strong>How to Compile and Fine-Tune FFmpeg for Optimal Performance:</strong> <em>Tailoring your multimedia toolkit for best performance!</em> Follow the detailed instructions on <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source">Install FFmpeg from Source</a></p>
</li>
<li><p><strong>GPU Acceleration for FFmpeg:</strong> <em>A Step-By-Step Guide with Nvidia GPU on AWS!</em> Check the complete guide at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws">Enable Harware Accelaration with FFmpeg</a></p>
</li>
<li><p><strong>CPU vs GPU Benchmark for video Transcoding on AWS:</strong> <em>Debunking the CPU-GPU myth!</em> See for yourself at <a target="_blank" href="https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth">Challenging the Video Encoding Cost-Speed Myth</a></p>
</li>
<li><p><strong>Crafting the Team for Sustainable Success:</strong> <em>Are "Rockstars" the Ultimate Solution for a Thriving Team?</em> Explore the insights at <a target="_blank" href="https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success">Beyond Rockstars</a></p>
</li>
<li><p><strong>How "Builders" Transform Team's Productivity:</strong> <em>Navigating Vision &amp; Ideas to Reality!</em> Discover more about Builders at <a target="_blank" href="https://mirzabilal.com/bridging-dreams-and-reality-how-builders-transform-teams">Bridging Dreams and Reality</a></p>
</li>
<li><p><strong>Mental Well-being in Tech:</strong> <em>Cultivating a Healthier Workplace for Tech Professionals</em> Explore insights: <a target="_blank" href="https://mirzabilal.com/the-dark-side-of-high-tech-success-addressing-mental-well-being-in-tech">The Dark Side of High-Tech Success!</a></p>
</li>
<li><p><strong>Freelancer to Full-Time:</strong> <em>Understanding Corporate Reluctance. Discover insights at</em> <a target="_blank" href="https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons">Why Businesses Hesitate to Employ Freelancers</a></p>
</li>
<li><p><strong>Transitioning from Freelancer to Full-Time:</strong> <em>Hurdles to Overcome!</em> Check out <a target="_blank" href="https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons">Why Businesses Hesitate to Employ Freelancers</a></p>
</li>
<li><p><strong>The Future of Efficient Backend Development:</strong> <em>Efficient Backend Development with Outerbase!</em> Discover the details at <a target="_blank" href="https://mirzabilal.com/building-a-robust-backend-in-just-30-minutes-with-outerbase">Building a Robust Backend with Outerbase</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Why Businesses Hesitate to Employ Freelancers]]></title><description><![CDATA[Hiring the right candidate for an organization can be a daunting task, as finding the perfect fit is never guaranteed despite a thorough hiring process. There is no mathematical equation for assessing a candidate's qualifications. Evaluating a candid...]]></description><link>https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons</link><guid isPermaLink="true">https://mirzabilal.com/why-businesses-hesitate-to-employ-freelancers-unveiling-the-reasons</guid><category><![CDATA[Freelancing]]></category><category><![CDATA[jobs]]></category><category><![CDATA[hiring]]></category><category><![CDATA[organization]]></category><category><![CDATA[workfromhome]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Wed, 08 Nov 2023 10:03:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755443907672/cf6446fb-d624-4bdb-8716-de5d115f7b33.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hiring the right candidate for an organization can be a daunting task, as finding the perfect fit is never guaranteed despite a thorough hiring process. There is no mathematical equation for assessing a candidate's qualifications. Evaluating a candidate primarily hinges on two factors: "<strong>Technical Ability</strong>" and "<strong>Cultural Fit</strong>". Technical skills are relatively easier to measure than finding a cultural fit for the team, especially while evaluating during the few hours of the interview process.</p>
<h2 id="heading-the-guiding-principles"><strong>The Guiding Principles</strong></h2>
<p>Despite the effort invested, there's no surety the selected candidate is technically equipped and the perfect fit for the team, leading to a leap of faith. To mitigate hiring risks for a full-time job, we have formalized several rules. One significant rule emphasizes:</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Prefer candidates with full-time experience over long-term freelancers.</div>
</div>

<h2 id="heading-freelancers-and-challenges"><strong>Freelancers and Challenges</strong></h2>
<p>Drawing from our experiences working with long-term freelancers, we have identified some common quirks among many individuals. If you're a freelancer considering this shift, we've pinpointed traits that should be addressed for a successful transition.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699437190256/b6750e99-e646-46cf-a33a-d511b203e0d8.png" alt="Source: https://imgur.com/orEha77" class="image--center mx-auto" /></p>
<ol>
<li><h3 id="heading-approach-to-problem-solving">Approach to Problem Solving 🧩</h3>
<p> Freelancers often approach problem-solving differently from full-time employees. Through their extensive experience in various freelance projects, they might start embracing the "<strong>If It's Working, It's Done"</strong> mindset. This approach prioritizes immediate functionality and might disregard the best practices for task completion, potentially impacting the project's overall health, team coordination, and successful goal achievement.</p>
</li>
<li><h3 id="heading-collaboration-struggles">Collaboration Struggles 🖇️</h3>
<p> Freelancers' prolonged solo work impacts their team collaboration skills, making it challenging for them to coordinate within the team and other teams in the organization. This lack of team experience often results in difficulties when attempting to synchronize efforts within the organization.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1699428096265/e9f75d9a-5319-47af-be88-dadfffb4b38a.png" alt="Source: https://cheezburger.com/16245253/cursed-and-flawed-stairs-that-are-up-to-something" class="image--center mx-auto" /></p>
<h3 id="heading-no-strings-attached-mindset">No Strings Attached Mindset 🔄</h3>
<p> Freelancers often cultivate a habit of transiting from one project to another, nurturing a constant "<strong>Urge for Change</strong>" within themselves. Organizations looking for stability invest in candidates with the anticipation of a more enduring commitment and are caught off guard by departures within a short span of 2 to 3 months at times.</p>
</li>
<li><h3 id="heading-short-sightedness">Short-Sightedness ⚙️</h3>
<p> The idea of "Be your own man" and doing everything on your own may seem powerful, but it's even more important to recognize the significance of being part of something bigger and creating things that fit flawlessly with others. The nature of freelancing sometimes requires a shorter-term focus on immediate tasks or projects and does not realize "<strong>Your work will be a cog in the machine instead of the machine itself</strong>". Companies prefer candidates who can take a more holistic and long-term view, contributing to the broader vision and goals of the company, rather than focusing solely on short-term tasks. Forward-thinkers who foresee future needs are the architects behind groundbreaking products.</p>
</li>
<li><h3 id="heading-the-performance-metrics">The Performance Metrics 📈</h3>
<p> High-performance applications significantly influence user satisfaction, productivity, and competitive advantage in today's market. The Freelancer's "<strong>quantity over quality</strong>" approach for delivering tasks quickly, with minimal effort and time, often leads to subpar unoptimized output. These modules and products adversely affect product performance, leading to customer dissatisfaction, impeding growth, and negatively impacting customer retention.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<blockquote>
<p>"<em>Pleasure in the job puts perfection in the work.</em>"</p>
<p>-- Aristotle</p>
</blockquote>
<p>The purpose of the discussion is not to devalue the role of freelancers, rather it is important to acknowledge their significant contributions to the thriving tech industry. While freelancers bring so much to the table, their alignment with organizational objectives often poses challenges. Recognizing the strengths and understanding the potential discord between freelancing and long-term goals is essential for refining hiring strategies and ensuring an ideal match for both employees and organizations. Freelancers, too, should introspect on these common issues discussed and address them, regardless of pursuing a full-time job or continuing in their freelancing career.</p>
<hr />
<h2 id="heading-more-from-the-author">More From the Author</h2>
<ul>
<li><p><strong>Dark Truth about AWS Deep Learning AMIs:</strong> <em>The Silent Roadblock to Your Success!</em> Learn How to Break Free at <a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix">How Your AWS Deep Learning AMI is Holding You Back</a></p>
</li>
<li><p><strong>Cost-Effective Deep Learning with Custom AMIs and Spot Instances:</strong> <em>Discover Cutting-Edge Insights!</em> Explore the full article: <a target="_blank" href="https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d">Deep Learning with AWS Graviton2 and Nvidia Tensor T4g</a></p>
</li>
<li><p><strong>How to Compile and Fine-Tune FFmpeg for Optimal Performance:</strong> <em>Tailoring your multimedia toolkit for best performance!</em> Follow the detailed instructions on <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source">Install FFmpeg from Source</a></p>
</li>
<li><p><strong>GPU Acceleration for FFmpeg:</strong> <em>A Step-By-Step Guide with Nvidia GPU on AWS!</em> Check the complete guide at <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws">Enable Harware Accelaration with FFmpeg</a></p>
</li>
<li><p><strong>CPU vs GPU Benchmark for video Transcoding on AWS:</strong> <em>Debunking the CPU-GPU myth!</em> See for yourself at <a target="_blank" href="https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth">Challenging the Video Encoding Cost-Speed Myth</a></p>
</li>
<li><p><strong>Crafting the Team for Sustainable Success:</strong> <em>Are "Rockstars" the Ultimate Solution for a Thriving Team?</em> Explore the insights at <a target="_blank" href="https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success">Beyond Rockstars</a></p>
</li>
<li><p><strong>How "Builders" Transform Team's Productivity:</strong> <em>Navigating Vision &amp; Ideas to Reality!</em> Discover more about Builders at <a target="_blank" href="https://mirzabilal.com/bridging-dreams-and-reality-how-builders-transform-teams">Bridging Dreams and Reality</a></p>
</li>
<li><p><strong>Mental Well-being in Tech:</strong> <em>Cultivating a Healthier Workplace for Tech Professionals</em> Explore insights: <a target="_blank" href="https://mirzabilal.com/the-dark-side-of-high-tech-success-addressing-mental-well-being-in-tech">The Dark Side of High-Tech Success!</a></p>
</li>
<li><p><strong>The Future of Efficient Backend Development:</strong> <em>Efficient Backend Development with Outerbase!</em> Discover the details at <a target="_blank" href="https://mirzabilal.com/building-a-robust-backend-in-just-30-minutes-with-outerbase">Building a Robust Backend with Outerbase</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How To Enable Hardware Acceleration on Chrome, Chromium & Puppeteer on AWS in Headless mode]]></title><description><![CDATA[Running Google Chrome with hardware acceleration in headless mode can be more challenging than it appears. We embarked on this journey with Remotion, which is an excellent framework that enables developers to "Make Videos Programmatically". On our wa...]]></description><link>https://mirzabilal.com/how-to-enable-hardware-acceleration-on-chrome-chromium-puppeteer-on-aws-in-headless-mode</link><guid isPermaLink="true">https://mirzabilal.com/how-to-enable-hardware-acceleration-on-chrome-chromium-puppeteer-on-aws-in-headless-mode</guid><category><![CDATA[google chrome browser]]></category><category><![CDATA[AWS]]></category><category><![CDATA[headless]]></category><category><![CDATA[Hardware Acceleration]]></category><category><![CDATA[GPU Acceleration]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Wed, 25 Oct 2023 11:50:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755446195213/6d3b8924-ed04-405c-8660-30dbaa7f0ecd.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Running <a target="_blank" href="https://developer.chrome.com/blog/headless-chrome/">Google Chrome</a> with hardware acceleration in headless mode can be more challenging than it appears. We embarked on this journey with <a target="_blank" href="https://remotion.dev">Remotion</a>, which is an excellent framework that enables developers to "Make Videos Programmatically". On our way, explore various Nvidia driver versions, including those from Nvidia's website and Ubuntu's official repositories.</p>
<p>We collaborated with the vibrant <a target="_blank" href="https://remotion.dev">Remotion</a> Open-source community to find the answer for using <a target="_blank" href="https://github.com/remotion-dev/remotion/issues/2889">GPU with Remotion for server-side rendering</a>. After encountering some setbacks on our way, we were able to make it work for Remotion eventually. We consolidated our findings in the Remotion Docs at <a target="_blank" href="https://remotion-git-gpu-on-ec2-remotion.vercel.app/docs/miscellaneous/cloud-gpu">Using the GPU in the Cloud</a> and simplified the instructions for Remotion developers to make the most out of it. Although the whole research was done for <a target="_blank" href="https://remotion.dev">Remotion</a>, the same process will work for any headless application that requires GPU power, especially in headless mode.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755446212826/86563e27-1273-44c0-84cf-bb3ded479f6e.webp" alt class="image--center mx-auto" /></p>
<h3 id="heading-hardware-acceleration-in-browser-rendering"><strong>Hardware Acceleration in Browser Rendering</strong></h3>
<p>Hardware Acceleration is to your browser what "<strong>Nitrogen Fuel</strong>" is for a gasoline car. It uses the power of specialized hardware like GPUs to make your web pages load faster and videos play smoothly. Hardware acceleration improves the part where the web page is displayed and shown to you, known as rendering. This results in a smoother and snappier browsing experience.</p>
<h3 id="heading-dlami-from-marketplace">DLAMI from Marketplace?</h3>
<p>One may wonder why we didn't opt for the AWS Deep Learning AMI or DLAMI. But we needed fine-grained control over the GPU drivers and utilities, and the outdated DLAMIs despite all the bloatware was not the answer. Such tasks are often challenging to achieve with pre-packaged AMIs as discussed in "<a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix">Why Deep Learning AMI is Holding You Back</a>". Tailoring the environment to our exact requirements also helped us troubleshoot issues effectively.</p>
<p>We experimented with multiple packages, to identify the key ones needed for Google Chrome to recognize the GPU. Despite these efforts, GPU recognition remained elusive, and in some instances, GPU drivers were crashing even at initialization. The long and arduous journey has brought us to the end of the tunnel, yet the darkness persists, and the solution remains as elusive as ever. As we decided to call it a day, We stumbled upon <a target="_blank" href="https://github.com/puppeteer/puppeteer/issues/3637">this thread</a> on <a target="_blank" href="https://pptr.dev">Puppeteer</a>'s Github issues, which did not give us any hope, but did give us a new perspective and drive to achieve our goal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696893635495/449420b3-29fb-45e1-830b-1d88ee7270f4.png" alt="Developers are facing similar issues with hardware acceleration in headless mode" class="image--center mx-auto" /></p>
<h2 id="heading-the-fresh-start"><strong>The Fresh Start</strong></h2>
<p>It was time to return to the drawing board and start afresh. We started with a clean base Ubuntu AMI on AWS EC2 Instance. After that, we downloaded and installed the Nvidia Tesla T4G drivers from Nvidia's official website.</p>
<p>Once confirmed that the GPU was working properly using <code>nvidia-smi</code>, We installed Google Chrome and tested it for hardware acceleration, to our relief Google Chrome finally gave a nod to work with Hardware Acceleration.</p>
<h2 id="heading-launching-an-ec2-instance">Launching an EC2 Instance</h2>
<p>Launching an EC2 instance can be achieved in various ways, with the AWS Web Console and AWS CLI being two notable options. Regardless of the method, the important parameters are instance type and AMI selection. At the time of writing, the AMI ID for our chosen instance <code>g4dn.xlarge</code> is <code>ami-053b0d53c279acc90</code>. For launching the EC2 instance via <code>aws-cli</code>, the following command can be used, after replacing the placeholders with actual values.</p>
<pre><code class="lang-bash">aws ec2 run-instances \
  --instance-initiated-shutdown-behavior <span class="hljs-string">"terminate"</span> \
  --image-id <span class="hljs-string">"ami-053b0d53c279acc90"</span> \
  --instance-type <span class="hljs-string">"g4dn.xlarge"</span> \
  --key-name <span class="hljs-string">"&lt;KEY_NAME&gt;"</span> \
  --subnet-id <span class="hljs-string">"&lt;SUBNET_ID&gt;"</span> \
  --security-group-ids <span class="hljs-string">"&lt;SECURITY_GROUP_ID&gt;"</span> \
  --iam-instance-profile Arn=<span class="hljs-string">"&lt;ARN&gt;"</span> \
  --block-device-mappings <span class="hljs-string">'[
  {
    "DeviceName": "/dev/sda1",
    "Ebs": {
      "VolumeSize": 8,
      "VolumeType": "gp3"
    }
  }
]'</span>
</code></pre>
<h2 id="heading-ubuntu-upgrade">Ubuntu Upgrade</h2>
<p>Ubuntu 22.04 AMI <code>ami-053b0d53c279acc90</code> on AWS comes with Linux Kernel <code>v5</code> (specifically <code>5.19.0-1025-aws</code>). At this point, we have two options either we stick with Kernel <code>v5</code> or Upgrade to <code>v6</code> (<code>v6.2.0-1013-aws</code>), we decided to upgrade the Kernel. This decision is crucial as the Nvidia driver compiled for one version will not work for the other.</p>
<p>After launching the instance, SSH into the instance and initiate the Ubuntu packages upgrade process. To update all the installed packages including Linux Kernel execute the following one-liner.</p>
<pre><code class="lang-bash">sudo bash -c <span class="hljs-string">"apt update &amp;&amp; export DEBIAN_FRONTEND=noninteractive &amp;&amp; export NEEDRESTART_MODE=a &amp;&amp; apt upgrade -y &amp;&amp; reboot"</span>
</code></pre>
<p>We can also split <code>apt update</code>, <code>apt upgrade -y</code> and <code>reboot</code>. But the reason behind doing it like this is to install these updates in non-interactive mode.</p>
<p>After the execution, the system will reboot with Linux Kernel Version 6. We can confirm the kernel update with <code>uname -r</code>. Rebooting is essential when upgrading the Ubuntu system because it loads the new Kernel on the next boot, and Nvidia drivers will subsequently be built for the updated version.</p>
<h2 id="heading-nvidia-gpu-driver-installation"><strong>Nvidia GPU Driver Installation</strong></h2>
<p>The process of installing GPU drivers is straightforward when we have the correct driver for the GPU and the corresponding compatible version. Before starting the installation we need to install a couple of packages: <code>build-essential</code> and <code>libvulkan1</code> . The former is a bundle with a variety of compilation tools required to compile the Nvidia driver. The latter, while not mandatory, is required by Google Chrome. Therefore it's a good idea to install it beforehand to enable support for Vulkan ICD loader for Nvidia, should we require it in the future.</p>
<pre><code class="lang-bash">sudo apt install -y build-essential libvulkan1
</code></pre>
<p>After build tools are installed, we can proceed to download and install the GPU drivers using the following commands:</p>
<pre><code class="lang-bash">DRIVER_URL=<span class="hljs-string">"https://us.download.nvidia.com/tesla/535.104.12/NVIDIA-Linux-x86_64-535.104.12.run"</span>
DRIVER_NAME=<span class="hljs-string">"NVIDIA-Linux-driver.run"</span>
wget -O <span class="hljs-string">"<span class="hljs-variable">$DRIVER_NAME</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$DRIVER_URL</span>"</span>
sudo sh <span class="hljs-string">"<span class="hljs-variable">$DRIVER_NAME</span>"</span> --disable-nouveau --silent
rm <span class="hljs-string">"<span class="hljs-variable">$DRIVER_NAME</span>"</span>
</code></pre>
<p>Now we can run <code>nvidia-smi</code> to confirm the GPU drivers installation. The output will look similar to this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696897364039/4b71b8ea-8b10-4dcc-805b-0416203db533.png" alt="nvidia-smi output" class="image--center mx-auto" /></p>
<h3 id="heading-configuring-the-startup-service"><strong>Configuring the Startup Service</strong></h3>
<p>We learned this the hard way: running <code>nvidia-smi</code> once is needed for the proper initialization of <code>EGL</code> and <code>ANGLE</code>. Google Chrome and Chromium fail to initialize <code>EGL</code> without this preliminary setup. To automate this process, we will create a service that runs <code>nvidia-smi</code> at boot time using following commands:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">'[Unit]
Description=Run nvidia-smi at system startup

[Service]
ExecStart=/usr/bin/nvidia-smi
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target'</span> | sudo tee /etc/systemd/system/nvidia-smi.service
sudo systemctl <span class="hljs-built_in">enable</span> nvidia-smi.service
sudo systemctl start nvidia-smi.service
</code></pre>
<h2 id="heading-testing-the-installation">Testing the Installation</h2>
<p>To test hardware acceleration with Google Chrome or Chromium, we can follow these steps. It's worth noting that Google Chrome has more dependencies, making it an easier choice if we plan to use the Node.js library, Puppeteer.</p>
<p>On the other hand, Chromium is a lightweight option with a smaller footprint of dependencies, but we can still use Puppeteer with Chromium by installing a few extra dependencies.</p>
<h3 id="heading-chromium">Chromium</h3>
<ul>
<li><h4 id="heading-installation">Installation:</h4>
<p>  Installing Chromium is straightforward, as it is readily available with Ubuntu's official software repositories. We can install it using <code>apt</code> with the following command.</p>
</li>
</ul>
<pre><code class="lang-bash">sudo apt install -y chromium-browser
</code></pre>
<ul>
<li><h4 id="heading-testing">Testing:</h4>
<p>  Chromium is fully prepared to handle Hardware Acceleration tasks. We can verify its readiness by launching Chromium with the specified parameters.</p>
</li>
</ul>
<pre><code class="lang-bash">chromium-browser --headless --use-gl=angle \
   --use-angle=gl-egl --use-cmd-decoder=passthrough \
   --print-to-pdf=output.pdf <span class="hljs-string">'chrome://gpu'</span>
</code></pre>
<p>To use Puppeteer with Chromium instead of Google Chrome, there are a few extra dependencies that should be installed.</p>
<pre><code class="lang-bash">sudo apt install ca-certificates fonts-liberation \
    libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 \
    libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \
    libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 \
    libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 \
    libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 \
    libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
    libxtst6 lsb-release wget xdg-utils
</code></pre>
<h3 id="heading-google-chrome">Google Chrome</h3>
<ul>
<li><h4 id="heading-installation-1">Installation:</h4>
<p>  Google Chrome can be installed from multiple options, but we will use the Google Chrome official repository for Debian. We need to add it to Ubuntu's repo list along with the public signing key.</p>
</li>
</ul>
<pre><code class="lang-bash">curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrom-keyring.gpg
<span class="hljs-built_in">echo</span> <span class="hljs-string">"deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrom-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main"</span> | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt update
sudo apt install -y google-chrome-stable
</code></pre>
<ul>
<li><h4 id="heading-testing-1">Testing:</h4>
<p>  Google Chrome is ready for our Hardware Acceleration tasks. We can test it by launching Google Chrome with the following parameters.</p>
</li>
</ul>
<pre><code class="lang-bash">google-chrome-stable --headless --use-gl=angle \
    --use-angle=gl-egl --use-cmd-decoder=passthrough \
    --print-to-pdf=output.pdf <span class="hljs-string">'chrome://gpu'</span>
</code></pre>
<p>The above commands will generate <code>output.pdf</code>, and transfer it to your local machine to check the status of Hardware Acceleration in Google Chrome or Chromium. If the process went smoothly, the resultant <code>PDF</code> will look like this.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696894145838/7a102263-bb0c-4703-a694-98d74172cc1a.png" alt="Chrome GPU status screenshot." class="image--center mx-auto" /></p>
<h2 id="heading-working-with-puppeteer">Working with Puppeteer</h2>
<p>To verify GPU acceleration using the Node.js library Puppeteer, follow these steps:</p>
<ul>
<li>Install Node.js, as this clean Ubuntu AMI does not include any unnecessary packages. Use the following commands:</li>
</ul>
<pre><code class="lang-bash">curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=18
<span class="hljs-built_in">echo</span> <span class="hljs-string">"deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_<span class="hljs-variable">$NODE_MAJOR</span>.x nodistro main"</span> | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt update
sudo apt install nodejs
</code></pre>
<ul>
<li>After installing Node.js, we can install Puppeteer by running <code>npm i puppeteer</code> in our code directory. Here's a sample <code>index.js</code> file for checking hardware acceleration:</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> puppeteer = <span class="hljs-built_in">require</span>(<span class="hljs-string">'puppeteer'</span>);
(<span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">const</span> browser = <span class="hljs-keyword">await</span> puppeteer.launch({
    <span class="hljs-attr">headless</span>: <span class="hljs-literal">true</span>, 
    <span class="hljs-attr">args</span>: [<span class="hljs-string">'--use-gl=angle'</span>, <span class="hljs-string">'--use-angle=gl-egl'</span>], 
  });
  <span class="hljs-keyword">const</span> page = <span class="hljs-keyword">await</span> browser.newPage();
  <span class="hljs-keyword">await</span> page.goto(<span class="hljs-string">'chrome://gpu'</span>);
  <span class="hljs-keyword">await</span> page.waitForTimeout(<span class="hljs-number">2000</span>);
  <span class="hljs-keyword">await</span> page.screenshot({ <span class="hljs-attr">path</span>: <span class="hljs-string">'output.png'</span> });
  <span class="hljs-keyword">await</span> browser.close();
})();
</code></pre>
<ul>
<li>Run the script using <code>node index.js</code>. This will generate an <code>output.png</code> file containing hardware acceleration information.</li>
</ul>
<h2 id="heading-note-from-the-creator">Note from the Creator</h2>
<blockquote>
<p><a target="_blank" href="https://mirzabilal.com">Mirza</a> has been immensely helpful in helping the “<a target="_blank" href="https://remotion.dev">Remotion</a>” community adopt GPU-accelerated rendering.<br />He's researched and written about how to obtain, configure and run EC2 containers and headless Chrome correctly in order to take advantage of graphics acceleration.<br />This area has been especially hard to crack, and without Mirza we would not have been able to unlock huge speed boosts.</p>
<p>We are super grateful for that!</p>
<p>--<br /><a target="_blank" href="https://jonny.io">Jonny Burger</a><br />Creator / <a target="_blank" href="http://Remotion.dev">Remotion.dev</a></p>
</blockquote>
<h2 id="heading-conclusion">Conclusion</h2>
<p>With hardware acceleration now readily available in headless mode, we can harness the power of GPUs for faster and more complex rendering tasks. Our next steps involve creating a custom AMI from this instance and streamlining the process using AWS Image Builder Pipelines for efficiency. Additionally, we plan to extend hardware capabilities to Docker containers, further extending our options.</p>
<h2 id="heading-resources">Resources</h2>
<ul>
<li><p><strong>Remotion - Make videos programmatically:</strong></p>
<p>  <a target="_blank" href="https://remotion.dev">https://remotion.dev</a></p>
</li>
<li><p><strong>Remotion - Using the GPU in the cloud:</strong></p>
<p>  <a target="_blank" href="https://www.remotion.dev/docs/miscellaneous/cloud-gpu">https://www.remotion.dev/docs/miscellaneous/cloud-gpu</a></p>
</li>
<li><p><strong>Cannot enable GPU acceleration:</strong></p>
<p>  <a target="_blank" href="https://github.com/puppeteer/puppeteer/issues/3637"><em>https://github.com/puppeteer/puppeteer/issues/3637</em></a></p>
</li>
<li><p><strong>Recommend a workflow for using the GPU on a AWS instance</strong>:</p>
<p>  <a target="_blank" href="https://github.com/remotion-dev/remotion/issues/2889">https://github.com/remotion-dev/remotion/issues/2889</a></p>
</li>
<li><p><strong>Getting Started with Headless Chrome:</strong></p>
<p>  <a target="_blank" href="https://developer.chrome.com/blog/headless-chrome/"><em>https://developer.chrome.com/blog/headless-chrome/</em></a></p>
</li>
<li><p><strong>Why Your AWS Deep Learning AMI is Holding You Back and How to Fix:</strong></p>
<p>  <a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix"><em>https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix</em></a></p>
</li>
<li><p><strong>Deep Learning with “AWS Graviton2 + NVIDIA Tensor T4G” for as low as free* with CUDA 12.2:</strong></p>
<p>  <a target="_blank" href="https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d"><em>https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d</em></a></p>
</li>
<li><p><strong>How to install FFmpeg with Harware Accelaration on AWS:</strong></p>
<p>  <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws"><em>https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws</em></a></p>
</li>
<li><p><strong>CPU vs GPU for Video Transcoding - Challenging the Cost-Speed Myth:</strong></p>
<p>  <a target="_blank" href="https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth">https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[CPU vs GPU for Video Transcoding: Challenging the Cost-Speed Myth]]></title><description><![CDATA[Introduction
When evaluating computational power, especially in terms of CPUs and GPUs, there’s a prevailing narrative. A general belief is, that CPUs may take longer to process, but they're cost-effective, whereas GPUs might be faster but operate at...]]></description><link>https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth</link><guid isPermaLink="true">https://mirzabilal.com/cpu-vs-gpu-for-video-transcoding-challenging-the-cost-speed-myth</guid><category><![CDATA[FFmpeg]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Linux]]></category><category><![CDATA[Benchmark]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Wed, 11 Oct 2023 19:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755457757753/095c7458-c973-4fbb-a7f0-7ab0cf336a91.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>When evaluating computational power, especially in terms of CPUs and GPUs, there’s a prevailing narrative. A general belief is, that CPUs may take longer to process, but they're cost-effective, whereas GPUs might be faster but operate at a higher cost.</p>
<p><strong>How true is this widely accepted notion?</strong></p>
<p>To challenge this belief, we conducted a tangible, real-world assessment using AWS instances and FFmpeg for video transcoding benchmarks. And sought to determine the most cost-and-time-efficient option for transcoding videos and audio, hence enabling us to save on our AWS bills.</p>
<h3 id="heading-the-selection-of-instances"><strong>The Selection of Instances</strong></h3>
<p>In our tests, we compared various AWS instance types, covering both GPU and CPU across Intel and AWS's Silicon-based Graviton2 instances. On the GPU side, we picked instances featuring Nvidia Tesla T4 and T4G. Whereas for CPUs, we looked at three instances, two from the same generation and size an Intel-based <code>c7i.2xlarge</code>, and Graviton2-powered <code>c7g.2xlarge</code>. The third CPU-based instance we chose was <code>c6g.4xlarge</code>, to assess the impact of more vCPU on transcoding.</p>
<ol>
<li><strong>GPU Instances:</strong></li>
</ol>
<ul>
<li><p><code>g4dn.xlarge</code></p>
</li>
<li><p><code>g5g.xlarge</code></p>
</li>
</ul>
<ol>
<li><strong>CPU Instances:</strong></li>
</ol>
<ul>
<li><p><code>c7g.2xlarge</code></p>
</li>
<li><p><code>c7i.2xlarge</code></p>
</li>
<li><p><code>c6g.4xlarge</code></p>
</li>
</ul>
<p>We made thoughtful selections for each of these instances. We aimed to choose those with similar costs to ensure a fair cost-to-performance comparison. Additionally, to explore the performance implications of doubling the CPU count, we extended our benchmarks to the <code>c6g.4xlarge</code> instance.</p>
<h3 id="heading-the-process"><strong>The Process</strong></h3>
<p>Before analyzing the results, it's important to discuss and understand the types of tests that were conducted.</p>
<ol>
<li><p><strong>Downscale to 480p:</strong></p>
<p> Downscaling is the process when the video is squeezed smaller than its original size. It's useful for platforms or devices that cannot support high-resolution videos or when smaller file sizes are needed. For this test, we downscale the input video to 480p (640 pixels x 480 pixels).</p>
</li>
<li><p><strong>Resample at 720p:</strong></p>
<p> Resampling does not change the video's resolution but may alter the underlying pixel values. It can be beneficial for modifying encoding settings or applying specific filters. In this case, we resampled the video at its original resolution of 720p (1280 pixels × 720 pixels).</p>
</li>
<li><p><strong>Upscale to 1080p:</strong></p>
<p> Upscaling is the opposite of downscaling and is used to convert the video to higher resolution. Upscaling generally produces better results than playing or rendering a smaller video and stretching at playtime. In this test, we upscale the video to a higher resolution of 1080p (1920 pixels × 1080 pixels).</p>
</li>
<li><p><strong>No Scaling:</strong></p>
<p> All the above tests were conducted using a scale filter of FFmpeg but for this test, we did not provide any filter for scaling instead we simply re-encoded the video.</p>
</li>
</ol>
<h3 id="heading-benchmark-details"><strong>Benchmark Details</strong></h3>
<p>To ensure objectivity, we use the same video file for benchmarking, the input video details are as follows:</p>
<ul>
<li><p><strong>Container Format:</strong> <code>mp4</code></p>
</li>
<li><p><strong>Duration:</strong> <code>01:34:40.38</code></p>
</li>
<li><p><strong>Bitrate:</strong> <code>1579 kb/s</code></p>
</li>
<li><p><strong>Video Codec:</strong> <code>h264 (High)</code>,</p>
</li>
<li><p><strong>Video Resolution:</strong> <code>1280x720</code> @ <code>23.98 fps</code></p>
</li>
<li><p><strong>Audio:</strong> <code>aac (LC)</code>, Sample Rate: <code>48000 Hz, 5.1</code></p>
</li>
</ul>
<p>We utilized <a target="_blank" href="https://ffmpeg.org">FFmpeg</a>, a leading open-source software for multimedia processing, to devise our benchmark script. The script contains tests for both CPU and GPU-powered machines, first, it checks whether GPU is available or not. Depending on the result, it executes the appropriate command for video processing.</p>
<p>To execute our transcoding tasks, we used the following benchmark script:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

<span class="hljs-keyword">if</span> lspci | grep -i <span class="hljs-string">"NVIDIA Corporation"</span> &gt;/dev/null; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"System has a GPU"</span>
commands=(
    <span class="hljs-string">'ffmpeg -y -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i input.mp4  -vf "scale_cuda=720:480"   -c:a copy -c:v h264_nvenc output.mp4 -benchmark'</span>
    <span class="hljs-string">'ffmpeg -y -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i input.mp4  -vf "scale_cuda=1280:720"  -c:a copy -c:v h264_nvenc output.mp4 -benchmark'</span>
    <span class="hljs-string">'ffmpeg -y -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i input.mp4  -vf "scale_cuda=1920:1080" -c:a copy -c:v h264_nvenc output.mp4 -benchmark'</span>
    <span class="hljs-string">'ffmpeg -y -hide_banner -hwaccel cuda -hwaccel_output_format cuda -i input.mp4                             -c:a copy -c:v h264_nvenc output.mp4 -benchmark'</span>
)
<span class="hljs-keyword">else</span> 
commands=(
    <span class="hljs-string">'ffmpeg -y -hide_banner -i input.mp4 -vf "scale=720:480"   -c:a copy -c:v libx264 output.mp4 -benchmark'</span>
    <span class="hljs-string">'ffmpeg -y -hide_banner -i input.mp4 -vf "scale=1280:720"  -c:a copy -c:v libx264 output.mp4 -benchmark'</span>
    <span class="hljs-string">'ffmpeg -y -hide_banner -i input.mp4 -vf "scale=1920:1080" -c:a copy -c:v libx264 output.mp4 -benchmark'</span>
    <span class="hljs-string">'ffmpeg -y -hide_banner -i input.mp4                       -c:a copy -c:v libx264 output.mp4 -benchmark'</span>
)
<span class="hljs-keyword">fi</span>

<span class="hljs-keyword">for</span> cmd <span class="hljs-keyword">in</span> <span class="hljs-string">"<span class="hljs-variable">${commands[@]}</span>"</span>; <span class="hljs-keyword">do</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"--------------------------------------------------------------------------------"</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Executing: <span class="hljs-variable">$cmd</span>"</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"--------------------------------------------------------------------------------"</span>
    <span class="hljs-comment"># Use the time command to measure how long it takes to run the command</span>
    { time <span class="hljs-built_in">eval</span> <span class="hljs-string">"<span class="hljs-variable">$cmd</span>"</span>; } 2&gt;&amp;1
    rm output.mp4
<span class="hljs-keyword">done</span> | tee output_results.txt
</code></pre>
<h3 id="heading-the-findings"><strong>The Findings</strong></h3>
<p>The data from our AWS benchmarks after executing 20 different tests over five different AWS Instances, painted a compelling narrative. The results showed clear differences in the cost-efficiency and performance dynamics among these instances. The data extracted and processed from benchmark results can be listed as:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755457950669/815feec1-285a-4ab1-9889-cf30d5795d6a.webp" alt class="image--center mx-auto" /></p>
<p>The GPU instances, notably AWS Graviton2 <code>g5g.xlarge</code>, were not only faster but also more cost-effective across the various transcoding operations, compared to the CPU-centric instances like <code>c7g.2xlarge</code>. The introduction of the <code>c6g.4xlarge</code>, with its doubled vCPUs, provided insights into how increasing computational power influences performance and cost. Interestingly, even with the added CPUs, despite it being more expensive than GPU-powered instances, it performed significantly worse and GPU instances continue to offer a better balance between speed and cost. Furthermore, it is important to mention here that, the FFmpeg was built to run on multiple cores and was utilizing all CPU cores as can be seen in <code>htop</code> screenshot during a transcoding task</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755458157959/0eb41fe7-08fd-4980-9b1d-2be3f3d04102.webp" alt class="image--center mx-auto" /></p>
<p>.</p>
<p>Let's create a visualization of benchmark results to compare the time taken and cost when running on different EC2 instances</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755458185291/2f185020-1788-4dd6-93c1-5a4121293000.webp" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755458222001/2376bbf5-e4a7-41cf-9023-70fba2aea4b4.webp" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-winner">The Winner?</h2>
<p>From the previous charts, it's evident that the AWS Graviton2-based <code>G5g.xlarge</code> emerges as the most efficient choice. Not only does it excel in efficiency, but it also appears to be more cost-effective. To further illustrate its cost advantage, let's juxtapose it with various AWS instances to discern just how economical it truly is.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755458244155/6a95641a-0207-400c-9d52-41a9a90da6ae.webp" alt class="image--center mx-auto" /></p>
<p>The bar chart offers a vivid representation of how <code>G5g.xlarge</code> stacks up against other AWS EC2 instances in terms of cost. When downscaling to 480p, the <code>G5g.xlarge</code> is significantly more cost-effective, with the <code>c6g.4xlarge</code>, which is the most expensive across different transcoding tasks, which is a whopping 370.9% more expensive than <code>G5g.xlarge</code> for downscaling operations. For the resampling at 720p, the disparity grows even more evident, with the <code>c6g.4xlarge</code> being 445% pricier than the <code>G5g.xlarge</code>. Similarly, when upscaling to 1080p, the cost associated with <code>c6g.4xlarge</code> is 438.9% more than our winner. Finally, for the 'No Scaling' operation, <code>c6g.4xlarge</code> proves to be 446.1% more expensive.</p>
<p>In stark contrast, the <code>g4dn.xlarge</code>, although being one of the GPU-based instances, presents minimal cost differences when compared with <code>G5g.xlarge</code>. Its costs are just around 24.8% to 27% for the various operations, showcasing that while GPUs might be fast, their cost benefits, especially in this case, aren't always as pronounced.</p>
<p>These findings underline the impressive cost efficiency of the AWS Graviton2 <code>G5g.xlarge</code> featuring Nvidia Tesla T4G, when placed against other popular AWS instances.</p>
<h3 id="heading-in-conclusion"><strong>In Conclusion</strong></h3>
<p>The ever-evolving realm of technology often holds narratives based on past truths, which may not hold relevance today. Our experiment underscores a crucial fact: in video transcoding, modern GPU instances aren't just faster; they also offer a more economical choice. When choosing between a CPU or GPU for cloud-based operations, it's essential to consider both performance and cost. And as demonstrated, sometimes the supposedly "faster and pricier" option can also be the most cost-effective.</p>
<hr />
<div class="hn-embed-widget" id="more-from-author"></div>]]></content:encoded></item><item><title><![CDATA[Building a Robust Backend in Just 30 Minutes with Outerbase]]></title><description><![CDATA[Introduction
In the ever-evolving landscape of software development, new tools and technologies consistently emerge. However, every once in a while, something truly groundbreaking makes its mark. Today, we're looking into one such potential innovatio...]]></description><link>https://mirzabilal.com/building-a-robust-backend-in-just-30-minutes-with-outerbase</link><guid isPermaLink="true">https://mirzabilal.com/building-a-robust-backend-in-just-30-minutes-with-outerbase</guid><category><![CDATA[Outerbase]]></category><category><![CDATA[outerbasehackathon]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Mon, 02 Oct 2023 06:03:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755454671824/4f4bf18f-8327-4096-9190-2d20b70ab085.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>In the ever-evolving landscape of software development, new tools and technologies consistently emerge. However, every once in a while, something truly groundbreaking makes its mark. Today, we're looking into one such potential innovation “<a target="_blank" href="https://outerbase.com">Outerbase</a>”, and I promise to be candid, discussing both its strengths and weaknesses.</p>
<p>When the idea for RateMyCraft germinated in my mind, I was both eager and hesitant. My eagerness stemmed from the potential of the project, but my reluctance arose from the anticipated time-consuming backend setup — setting up databases, crafting APIs, and the works. This initial phase usually demands significant time, and frustratingly, often offers little to showcase for all the effort.</p>
<p>Enter Outerbase. A tool that, I believe, has the promise to usher in a transformative shift in how many of us approach backend development. But like all tools, it has its highs and lows, which we'll explore in-depth.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455470056/7cd2cc4a-d99a-4d48-841c-88d710d648bc.webp" alt class="image--center mx-auto" /></p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=m7LMcFRsmxY">https://www.youtube.com/watch?v=m7LMcFRsmxY</a></div>
<p> </p>
<h2 id="heading-what-is-ratemycraft">What is RateMyCraft?</h2>
<p>RateMyCraft offers users a platform to explore, rate, and review various local services, from plumbers and electricians to bakeries. Think of it as a close-knit community where people share their experiences, ensuring others can make informed choices about local services.</p>
<h2 id="heading-unraveling-outerbase-the-future-of-backend-development"><strong>Unraveling Outerbase: The Future of Backend Development</strong></h2>
<p>Before diving into the intricacies of RateMyCraft's functionalities, it's imperative to lay the foundation by understanding Outerbase – the backbone of our backend.</p>
<h3 id="heading-setting-up-a-database-with-outerbase"><strong>Setting Up a Database with Outerbase</strong></h3>
<p>The beauty of Outerbase is that it streamlines the process of initializing and managing databases. Here’s a brief walkthrough:</p>
<ol>
<li><p><strong>Database Creation</strong>: Within the Outerbase environment, you have the flexibility to connect to an existing MySQL, Postgres, or any other supported database. Alternatively, you can create a new SQLite database from scratch with just a few clicks</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455379002/b08a8b64-d561-4c09-9eb6-00cdf13dd783.webp" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>Table Creation and Structure Definition</strong>: Once the database is in place, the next step is to define your tables. With Outerbase, this step is straightforward. Use a simple command like from Outerbase web console:</p>
<pre><code class="lang-sql"> <span class="hljs-comment">-- Table Creation for 'service_providers'</span>
 <span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> service_providers (
     <span class="hljs-keyword">id</span> <span class="hljs-built_in">INTEGER</span> PRIMARY <span class="hljs-keyword">KEY</span>,
     <span class="hljs-keyword">name</span> <span class="hljs-built_in">TEXT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
     services <span class="hljs-built_in">TEXT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
     contact_info <span class="hljs-built_in">TEXT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
     description <span class="hljs-built_in">TEXT</span>,
     city <span class="hljs-built_in">TEXT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>
 );

 <span class="hljs-comment">-- Table Creation for 'reviews'</span>
 <span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> reviews (
     <span class="hljs-keyword">id</span> <span class="hljs-built_in">INTEGER</span> PRIMARY <span class="hljs-keyword">KEY</span>,
     provider_id <span class="hljs-built_in">INTEGER</span>,
     nickname <span class="hljs-built_in">TEXT</span> <span class="hljs-keyword">NOT</span> <span class="hljs-literal">NULL</span>,
     <span class="hljs-keyword">content</span> <span class="hljs-built_in">TEXT</span>,
     rating <span class="hljs-built_in">INTEGER</span> <span class="hljs-keyword">CHECK</span> (rating &gt;= <span class="hljs-number">1</span> <span class="hljs-keyword">AND</span> rating &lt;= <span class="hljs-number">5</span>),
     <span class="hljs-keyword">FOREIGN</span> <span class="hljs-keyword">KEY</span> (provider_id) <span class="hljs-keyword">REFERENCES</span> service_providers(<span class="hljs-keyword">id</span>)
 );
</code></pre>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455670501/4fb0cccd-e8b3-4ddb-9bae-492493f36072.webp" alt class="image--center mx-auto" /></p>
</li>
</ol>
<p><strong>Populating the Tables</strong>: Now that your tables are set up, you can populate them with data either by manual entry or by importing data sets. The latter is especially handy if you’re migrating from another system or have bulk data ready.</p>
<pre><code class="lang-sql"><span class="hljs-comment">-- SQL queries for generating test data can be grabbed from github repo of this project</span>
<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> service_providers (<span class="hljs-keyword">name</span>, services, contact_info, description, city) 
<span class="hljs-keyword">VALUES</span> 
(<span class="hljs-string">'Baker Delight'</span>, <span class="hljs-string">'Bakery'</span>, <span class="hljs-string">'+11234567915 | baker@delight.com'</span>, <span class="hljs-string">'Experience the finest baked delicacies in Chicago.'</span>, <span class="hljs-string">'Chicago'</span>),
(<span class="hljs-string">'Chicago Car Care'</span>, <span class="hljs-string">'Car Mechanic'</span>, <span class="hljs-string">'+11234567896 | care@chicagocar.com'</span>, <span class="hljs-string">'Premium car maintenance services ensuring smooth drives every time.'</span>, <span class="hljs-string">'Chicago'</span>),
(<span class="hljs-string">'CleanSpace NY'</span>, <span class="hljs-string">'Cleaning'</span>, <span class="hljs-string">'+11234567899 | clean@space.com'</span>, <span class="hljs-string">'Revitalize your home with professional cleaning services.'</span>, <span class="hljs-string">'New York'</span>)
<span class="hljs-comment">-- Add as many services as you want</span>

<span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> reviews (provider_id, nickname, <span class="hljs-keyword">content</span>, rating) <span class="hljs-keyword">VALUES</span>
(<span class="hljs-number">1</span>, <span class="hljs-string">'BakingLover'</span>, <span class="hljs-string">'The pastries are to die for!'</span>, <span class="hljs-number">5</span>),
(<span class="hljs-number">2</span>, <span class="hljs-string">'CarFan123'</span>, <span class="hljs-string">'Got my car repaired here. Top-notch service!'</span>, <span class="hljs-number">4</span>),
(<span class="hljs-number">2</span>, <span class="hljs-string">'Jess'</span>, <span class="hljs-string">'Pretty quick service. The price was reasonable.'</span>, <span class="hljs-number">4</span>),
<span class="hljs-comment">-- Add as many reviews as you want</span>
</code></pre>
<p>This whole process will not take more than 5 minutes, but we only have a database with test data, how about the API endpoints let's dive into that and see if we can do the rest in remaining 25 minutes.</p>
<h2 id="heading-the-outerbase-commands-magic-and-api-endpoints">The Outerbase commands magic and API endpoints</h2>
<p>Ever felt that building a backend is like trying to solve a jigsaw puzzle with pieces from different sets? I've been there! But are Outerbase Commands any better or more helpful in this regard? Well, my journey led me to some interesting answers. Let's explore.</p>
<p>Think of it as that friend who always has the right tools for the job. Now, let’s dive into how this nifty tool simplified the often intricate process of creating API endpoints for me. For this project, we need multiple endpoints so we can present and update ratings for different service providers.</p>
<h3 id="heading-1-new-command">1. New Command</h3>
<p>Let's start with creating the commands for <code>/providers</code> endpoint. This endpoint will list all the service providers registered with <strong>RateMyCraft</strong>. To create a command go to<br /><code>+ New</code> -&gt; <code>Commands</code></p>
<p>This will show a popup where you specify the <strong>Name</strong>, <strong>Path</strong> and <strong>Type (Get/Post/Put/Delete)</strong> for the endpoint. The following screenshot demonstrates this process.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455350374/e144e321-59e9-4bbf-9d1f-f2838e628f50.webp" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-javascript-command-node">2. Javascript Command Node</h3>
<p>The <code>/providers</code> endpoint can be invoked with or without <code>city</code> <code>GET</code> parameters. If the city param is not provided then we will list all the service providers, if the <code>city</code> param is provided for example <code>/providers?city=Miami</code>, this will return all the services from that city, in this case <code>Miami</code>.<br />The following javascript code will return the <code>city name</code> or <code>%</code>, depending on city parameters. Let's write a code to read query parameters into a node and call it a "<strong>City Node</strong>".</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">userCode</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> city = {{request.query.city}};
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> city !== <span class="hljs-string">'string'</span> || city.trim() === <span class="hljs-string">''</span>) {
        <span class="hljs-keyword">return</span> <span class="hljs-string">"%"</span>;
    } 
    <span class="hljs-keyword">return</span> city;
}
</code></pre>
<h3 id="heading-3-sql-query-command-node">3. SQL Query Command Node</h3>
<p>Now we will use the city name returned from the javascript node in the SQL query node. The interesting thing here is you can pass on data from one node to the other here we will pass the <code>city</code> from <strong>City Node</strong> to <strong>Query Node</strong>, you can see in the following code we are using <code>{{city-node}}</code>, which is the placeholder for the return value from the previous node.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> 
    s.*, 
    <span class="hljs-keyword">ROUND</span>(<span class="hljs-keyword">AVG</span>(r.rating), <span class="hljs-number">1</span>) <span class="hljs-keyword">AS</span> average_rating, 
    <span class="hljs-keyword">COUNT</span>(r.rating) <span class="hljs-keyword">AS</span> total_ratings 
<span class="hljs-keyword">FROM</span> service_providers <span class="hljs-keyword">AS</span> s 
<span class="hljs-keyword">LEFT</span> <span class="hljs-keyword">JOIN</span> reviews <span class="hljs-keyword">AS</span> r <span class="hljs-keyword">ON</span> s.id = r.provider_id 
<span class="hljs-keyword">WHERE</span> s.city <span class="hljs-keyword">LIKE</span> <span class="hljs-string">'{{city-node}}'</span> 
<span class="hljs-keyword">GROUP</span> <span class="hljs-keyword">BY</span> s.id;
</code></pre>
<p>The command will eventually look like the following screenshot and you know what that it <code>/provider</code> endpoint is finished, you can access that by simply sending a request to <code>https://thoughtless-amber.cmd.outerbase.io/providers</code>. <code>thoughtless-amber</code> is the unique id and will change for each project.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696107163836/516ba3a1-bcd8-463c-979e-52d36d7d44be.png" alt="Providers command" class="image--center mx-auto" /></p>
<h3 id="heading-other-endpoints">Other endpoints</h3>
<p>Since providers was our first node it took us a little longer and was done in 10 minutes, but now we have the basic understanding of Outerbase commands, different options and where to find what. Now all we need to do is focus on the logic and write in Outerbase.</p>
<p>Now we will implement the remaining endpoints</p>
<h4 id="heading-retrieving-reviews">Retrieving Reviews</h4>
<p>This will share the same 2-node structure, the first node will format the data and the second will run the query. Since Outerbase is still in beta the functionality to return in between is yet not available but it has been documented to work like the following where in case of <code>provider_id</code> is not given we will return <code>400</code>. But currently we can not return in between a node. After this feature is released it will give the developers a lot more control and can do a lot of different things.</p>
<ul>
<li><p><strong>Endpoint</strong>: <code>/reviews</code></p>
</li>
<li><p><strong>Nodes</strong>:</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">userCode</span>(<span class="hljs-params"></span>) </span>{
      <span class="hljs-keyword">const</span> provider_id = {{request.query.provider_id}};
      <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> provider_id !== <span class="hljs-string">'string'</span> || provider_id.trim() === <span class="hljs-string">''</span>) {
          <span class="hljs-keyword">return</span> {
              <span class="hljs-attr">status</span>: <span class="hljs-number">400</span>,
              <span class="hljs-attr">error</span>: <span class="hljs-string">"missing first name from request body"</span>
          }
      } 
      <span class="hljs-keyword">return</span> provider_id;
  }
</code></pre>
<pre><code class="lang-sql">  <span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> reviews <span class="hljs-keyword">WHERE</span> provider_id = <span class="hljs-string">'{{provider-node}}'</span>;
</code></pre>
</li>
<li><p><strong>Testing</strong>: After this is done your <code>/reviews</code> endpoint is ready and can be tested using the following example</p>
</li>
</ul>
<pre><code class="lang-bash">curl -X GET <span class="hljs-string">"https://thoughtless-amber.cmd.outerbase.io/reviews?provider_id=2"</span>
</code></pre>
<h4 id="heading-searching-service-providers">Searching Service Providers</h4>
<p>To demonstrate the simplicity and power of Outerbase commands we will only be using a single node with SQL query for search.</p>
<p>Or we can say that "<strong>SQL Query ≈ API Endpoint</strong>" let that sink in. 🤯</p>
<ul>
<li><p><strong>Endpoint</strong>: <code>/search</code></p>
</li>
<li><p><strong>Nodes:</strong></p>
<pre><code class="lang-sql">  <span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> service_providers 
  <span class="hljs-keyword">WHERE</span> 
    <span class="hljs-keyword">name</span> <span class="hljs-keyword">LIKE</span> <span class="hljs-string">'%{{request.query.query}}%'</span> 
    <span class="hljs-keyword">OR</span> services <span class="hljs-keyword">LIKE</span> <span class="hljs-string">'%{{request.query.query}}%'</span>;
</code></pre>
</li>
<li><p><strong>Testing</strong>: After this is done your <code>/search</code> endpoint is ready and can be tested using the following example</p>
</li>
<li><pre><code class="lang-bash">      curl -X GET <span class="hljs-string">"https://thoughtless-amber.cmd.outerbase.io/search?query=Beauty"</span>
</code></pre>
</li>
</ul>
<h4 id="heading-fetching-provider-details">Fetching Provider Details</h4>
<p>For some functions we need to fetch the provider details, for that, we will create the following endpoint.</p>
<ul>
<li><p><strong>Endpoint</strong>: <code>/provider</code></p>
</li>
<li><p><strong>Nodes:</strong></p>
<pre><code class="lang-sql">  <span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> service_providers <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">id</span> = <span class="hljs-string">'{{request.query.id}}'</span>
</code></pre>
</li>
<li><p><strong>Testing</strong>: After this, your <code>/provider</code> endpoint is ready and can be tested using the following example**:**</p>
<pre><code class="lang-bash">  curl -X GET <span class="hljs-string">"https://thoughtless-amber.cmd.outerbase.io/provider?id=1"</span>
</code></pre>
</li>
</ul>
<h4 id="heading-adding-a-review">Adding a Review</h4>
<p>The rating system without the functionality for adding a review is incomplete. Let's create an endpoint for that as well. For this endpoint, we will select <code>POST</code> as command type.</p>
<ul>
<li><p><strong>Endpoint:</strong> <code>/review/add</code></p>
</li>
<li><p><strong>Nodes:</strong></p>
<pre><code class="lang-sql">  <span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> reviews(provider_id, nickname, <span class="hljs-keyword">content</span>, rating) <span class="hljs-keyword">VALUES</span>({{request.body.provider_id}}, {{request.body.nickname}}, {{request.body.content}}, {{request.body.rating}})
</code></pre>
</li>
<li><p><strong>Testing</strong>: Now <code>/review/add</code> endpoint is ready and can be tested using the following example</p>
</li>
</ul>
<pre><code class="lang-bash">curl -X POST <span class="hljs-string">"https://thoughtless-amber.cmd.outerbase.io/review/add"</span> \
-H <span class="hljs-string">"Content-Type: application/json"</span> \
-d <span class="hljs-string">'{"nickname":"Mirza","rating":"5","content":"The best cupcakes in town","provider_id":"1"}'</span>
</code></pre>
<h4 id="heading-adding-a-service-provider">Adding a Service Provider</h4>
<p>New service providers can also register themselves or users can simply add the last service provider they used themselves in RateMyCraft.</p>
<ul>
<li><p><strong>Endpoint</strong>: <code>/provider/add</code></p>
</li>
<li><p><strong>Nodes:</strong></p>
<pre><code class="lang-sql">  <span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> service_providers (<span class="hljs-keyword">name</span>, services, contact_info, description, city) <span class="hljs-keyword">VALUES</span> ({{request.body.name}}, {{request.body.services}},{{request.body.contact_info}},{{request.body.description}}, {{request.body.city}});
</code></pre>
</li>
<li><p><strong>Testing</strong>: Now <code>/provider/add</code> endpoint is ready and you can add the provider using the following template.</p>
<pre><code class="lang-bash">  curl -X POST <span class="hljs-string">"https://thoughtless-amber.cmd.outerbase.io/provider/add"</span> \
  -d <span class="hljs-string">'{"name":"Mirza",
  "contact_info":"mirza@example.com | +1234232232",
  "city":"New York",
  "description": "We provide all kind of Electronics repairs",
  "services":"Electronics Repair"
  }'</span>
</code></pre>
</li>
</ul>
<h4 id="heading-update-service-provider">Update Service Provider</h4>
<p>Users or admins also need the functionality to update any field of service provider for that we will create our first <code>PUT</code> request. Due to the current limitation with Outerbase, we will first fetch the current values for the provider and then replace only the ones that the client has requested to update and use the rest as it is.</p>
<ul>
<li><strong>Endpoint</strong>: <code>/provider/update</code></li>
</ul>
<p><strong>Command:</strong></p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> service_providers <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">id</span> = {{request.body.id}};
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">userCode</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> requestBody = {
        <span class="hljs-attr">id</span>: {{request.body.id}},
        <span class="hljs-attr">name</span>: {{request.body.name}},
        <span class="hljs-attr">services</span>: {{request.body.services}},
        <span class="hljs-attr">city</span>: {{request.body.city}},
        <span class="hljs-attr">contact_info</span>: {{request.body.contact_info}},
        <span class="hljs-attr">description</span>: {{request.body.description}}
    };

    <span class="hljs-keyword">const</span> current_values = <span class="hljs-built_in">JSON</span>.parse({{data-node}});
    <span class="hljs-keyword">const</span> items = current_values?.response?.items;

    <span class="hljs-keyword">if</span> (!items || !<span class="hljs-built_in">Array</span>.isArray(items) || items.length === <span class="hljs-number">0</span>) {
        <span class="hljs-keyword">return</span> <span class="hljs-string">"No items available"</span>;
    }
    <span class="hljs-keyword">let</span> item = items[<span class="hljs-number">0</span>];
    <span class="hljs-comment">// Update item properties if the corresponding request body values are valid</span>
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> key <span class="hljs-keyword">in</span> requestBody) {
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> requestBody[key] === <span class="hljs-string">'string'</span> &amp;&amp; requestBody[key].trim() !== <span class="hljs-string">''</span>) {
            item[key] = requestBody[key];
        }
    }
    <span class="hljs-keyword">return</span> item;
}
</code></pre>
<pre><code class="lang-sql"><span class="hljs-keyword">UPDATE</span> service_providers 
<span class="hljs-keyword">SET</span> 
    <span class="hljs-keyword">name</span> = {{params-node.name}},
    services = {{params-node.services}},
    contact_info = {{params-node.contact_info}},
    description = {{params-node.description}},
    city = {{params-node.city}}
<span class="hljs-keyword">WHERE</span> 
    <span class="hljs-keyword">id</span> = {{params-node.id}};
</code></pre>
<h4 id="heading-deleting-a-service-provider">Deleting a Service Provider</h4>
<p>To remove a service provider we will use <code>DELETE</code> request.</p>
<ul>
<li><p><strong>Endpoint</strong>: <code>/provider/delete</code></p>
</li>
<li><p><strong>Command:</strong></p>
</li>
</ul>
<pre><code class="lang-sql"><span class="hljs-keyword">DELETE</span> <span class="hljs-keyword">FROM</span> service_providers <span class="hljs-keyword">WHERE</span> <span class="hljs-keyword">id</span> = {{request.body.id}};
</code></pre>
<p>Did you see how fast creating these Outerbase commands was? Oh, rather these API Endpoints 😊, and these last 7 endpoints hardly took 15 mins. The only thing that could hinder your progress or could consume more time is the current beta state, the Outerbase team has a lot of ground to make, but the idea is worth waiting for.</p>
<p>APIs which are the backbone for <strong>RateMyCraft</strong> are ready and deployed in barely 30 minutes, The disclaimer here is, that I have spent quite some time with Outerbase and knew what would work out of the box and, what would require workarounds. It might take you longer for the first time but once you are familiar with it, and you understand your problem you can do it even for less.</p>
<h2 id="heading-where-is-the-dashboard">Where is the Dashboard?</h2>
<p>In applications like RateMyCraft, a dashboard isn't just an accessory—it's the nerve center. It's where you'd typically view data summaries, gain insights, and make decisions. Now, traditionally, creating an intuitive dashboard involves layers of design, development, and countless hours of tweaking. But what if there was a shortcut? Another functionality of Outerbase is the <strong>integration of EZQL</strong>.</p>
<p>With Outerbase's EZQL, the very platform can serve as your dashboard! This isn't about cutting corners; it's about optimizing processes. Instead of toggling between multiple tools, you can query directly and get real-time insights, all within Outerbase.</p>
<p>For instance, need to know the top-rated car mechanics in Chicago? All you need to do is ask the Outerbase magician</p>
<blockquote>
<p>Get the best mechanic from Chicago based on average ratings</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455300221/8cf0dce9-8007-4308-a060-1cb67179e77a.webp" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455272027/02aec9fc-9c8c-40e6-8d1e-e5c0065afad6.webp" alt class="image--center mx-auto" /></p>
<p>Isn't it magic? 🪄 You can do so many things with Outerbase, not only you, but your non-technical co-founder can access everything without any technical know-how or without waiting for developers to finish the dashboard and add the specific data he need. It's that simple! With EZQL, you're not just building an application; you're crafting an experience—both for your users and yourself as a developer.</p>
<h2 id="heading-the-final-product">The Final Product</h2>
<p>After harnessing the powerful capabilities of Outerbase and weaving them into the backend of RateMyCraft, the outcome is nothing short of spectacular. But as they say, a picture is worth a thousand words. So, let me show you!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455242704/70bc751a-a7b2-4e04-a901-763647b81e0a.webp" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455080481/6921247a-a6e9-4d92-b8aa-8ea38d6c29d1.webp" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755455012893/7b24b4ba-f697-4fc5-8133-f8fb31780cb4.webp" alt class="image--center mx-auto" /></p>
<p>As for the aesthetic and user-friendly frontend, I utilized Vuetify—a fantastic framework for Vue.js. It played a pivotal role in giving life to the visuals and interactivity of RateMyCraft. However, getting deep into the intricacies of Vuetify is beyond the scope of this article. Today, our spotlight remains firmly on the magic and efficiency that Outerbase brought to the table. But if you are interested you can check the code in <a target="_blank" href="https://github.com/bilalmughal/rate-my-craft">GitHub repo</a> for this project.</p>
<p>The fusion of Outerbase's backend prowess with a polished frontend showcases what modern tools can achieve when used innovatively.</p>
<h2 id="heading-the-pros-and-cons-of-outerbase"><strong>The Pros and Cons of Outerbase</strong></h2>
<p>When navigating the seas of software development, it's essential to have a balanced view of the tools we use. Outerbase, despite its groundbreaking capabilities, is no exception. It's worth noting that Outerbase is currently in beta, which means some bumps in the road are to be expected. That said, let's weigh the advantages against the challenges.</p>
<h3 id="heading-pros">Pros:</h3>
<ol>
<li><p><strong>Responsive Team that Listens</strong>: There's immense value in having a team behind a product that's not just technically adept but is also receptive to feedback. This means issues get addressed, and user suggestions often shape the tool's evolution.</p>
</li>
<li><p><strong>Growing Community on Discord</strong>: A robust community is a sign of a product's potential. With discussions, troubleshooting, and shared experiences, new users find a supportive ecosystem ready to assist.</p>
</li>
<li><p><strong>Intuitive UI</strong>: Outerbase's user interface stands out for its clean design and user-centric approach. Even those without a solid technical background find it easy to navigate and understand.</p>
</li>
<li><p><strong>Flexibility of Commands</strong>: The ability to craft commands using multiple programming languages provides developers with a versatile toolkit, ensuring they can tackle diverse challenges head-on.</p>
</li>
</ol>
<h3 id="heading-cons">Cons:</h3>
<ol>
<li><p><strong>Incomplete Documentation</strong>: As with many beta products, the documentation isn't exhaustive. While foundational topics are covered, some nuanced or advanced features lack comprehensive guides or no documentation at all.</p>
</li>
<li><p><strong>Broken Features</strong>: Being in beta means not everything is polished to perfection. Users might stumble upon features that don't work as expected. However, with the responsive team behind Outerbase, these issues are often addressed swiftly.</p>
</li>
<li><p><strong>Absence of an Inbuilt Authentication System</strong>: Security is paramount, especially in backend operations. The lack of a built-in authentication system means developers might need to integrate third-party solutions or build custom ones, which can be time-consuming.</p>
</li>
</ol>
<h2 id="heading-the-future">The Future?</h2>
<p>Outerbase has nailed down many things exceptionally well, but as with any evolving product, there's always room for enhancements. As a staunch fan of <strong>OpenAPI specifications</strong>, I'd relish the option to import them, translating directly into Outerbase commands. Each endpoint from the specification could manifest as an Outerbase command, with distinct steps or nodes defined through specialized '<strong>vendor-specific extensions</strong>'. For comparison, AWS employs <code>x-amazon-apigateway-integration</code>. In a similar vein, Outerbase could introduce its proprietary extension. I believe this concept harmonizes perfectly with Outerbase's vision of rapid backend development. Implementing such a feature would mark a significant leap towards realizing the effortless backend platform that Outerbase aspires to become.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>This is surely the future for backend development, and some product is going to rule this space, will it be Outerbase? Everything depends on the Outerbase team if they can deliver on their promises.</p>
<p>Like any tool, Outerbase has its strengths and areas for improvement. However, its potential shines through, and as it matures out of beta, many of the current challenges are likely to be ironed out.</p>
<p>Outerbase, with its revolutionary approach to backend operations, enabled the creation of a robust backend in just 30 minutes. For fellow developers out there, this is a testament to the capabilities of modern-day tools. Embrace them, and the sky's the limit!</p>
<h2 id="heading-resources">Resources</h2>
<ul>
<li><p><strong>Outerbase:</strong> <a target="_blank" href="https://outerbase.com">https://outerbase.com</a></p>
</li>
<li><p><strong>Documentation:</strong> <a target="_blank" href="https://docs.outerbase.com">https://docs.outerbase.com</a></p>
</li>
<li><p><strong>Source Code:</strong> <a target="_blank" href="https://github.com/bilalmughal/rate-my-craft">github.com/bilalmughal/rate-my-craft</a></p>
</li>
<li><p><strong>Live Demo:</strong> <a target="_blank" href="https://ratemycraft.mirzabilal.com">ratemycraft.mirzabilal.com</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to install FFmpeg with Hardware Accelaration on AWS]]></title><description><![CDATA[Introduction
Video is not just a story; it is the storyteller. It weaves narratives, captures moments, and connects us in ways words alone cannot. The ever-increasing demand for video content in marketing, streaming and OTT platforms, social media, a...]]></description><link>https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws</link><guid isPermaLink="true">https://mirzabilal.com/how-to-install-ffmpeg-with-harware-accelaration-on-aws</guid><category><![CDATA[nvenc]]></category><category><![CDATA[hardware-encoding]]></category><category><![CDATA[FFmpeg]]></category><category><![CDATA[video streaming]]></category><category><![CDATA[Linux]]></category><category><![CDATA[amazon-linux-2023]]></category><category><![CDATA[#howtos]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Mon, 25 Sep 2023 10:09:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755446632894/6bae6fb1-df31-41fa-a479-454f142391a0.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction"><strong>Introduction</strong></h2>
<p>Video is not just a story; it is the storyteller. It weaves narratives, captures moments, and connects us in ways words alone cannot. The ever-increasing demand for video content in marketing, streaming and OTT platforms, social media, and mobile video consumption has increased the demand for bandwidth and server capacity. Cloud media processing has revolutionized the media industry, enhancing accessibility to video content beyond previous boundaries. The continuously increasing appetite for multimedia content and the growing prominence of deep learning have driven industry leaders like Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform to offer GPU-enabled instances tailored for parallel processing excellence.</p>
<p>FFmpeg is an indispensable multimedia innovation champion, consistently delivering eminence in audio-video processing and transcoding. If you are new to FFmpeg or need to setup FFmpeg for optimal performance on CPU, you can refer to the first article of this series, <a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source">How to install FFmpeg on Linux from Source</a> where we discussed about FFmpeg and provided a step-by-step guide to make the most out of FFmpeg on CPU.</p>
<p>Now we will take a step further and look into how FFmpeg can leverage the power of hardware acceleration, which can significantly reduce processing time and help deliver content to users faster than ever before. This How-to guide will show you how to set up FFmpeg for multimedia transcoding and other multimedia task with hardware acceleration.</p>
<h2 id="heading-problem"><strong>Problem</strong></h2>
<p>Traditional CPU-based video processing on cloud servers can be time-consuming and inefficient. As videos increase in resolution and size, the processing demand grows exponentially. Even with multi-core CPU configurations, the computational overhead can cause extended processing times, leading to delays in workflows and increased costs. Given cloud infrastructure providers charge per instance-hour, the longer your server runs, the more expensive your bill becomes. Failing to embrace GPU-powered machines means underutilizing their potential, especially since GPUs are specifically designed for parallel computational tasks. Thus, there is a pressing need to harness the GPU's power to optimize FFmpeg's performance and make the most out of it.</p>
<h2 id="heading-the-remedy">The Remedy</h2>
<h3 id="heading-know-your-hardware">Know your Hardware</h3>
<p>The first step is to figure out the GPU for your required architecture. For the scope of this guide, we will focus on <strong>Nvidia Tesla T4</strong> and <strong>Nvidia Tesla T4G</strong> available with AWS Graviton2 <code>G4g</code> and Intel-based <code>G4dn</code> instances on AWS, but you can follow this guide for any Nvidia GPU by installing the desired driver yourself or by following <a target="_blank" href="https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d#heading-install-nvidia-gpu-driver">this guide</a> and getting the appropriate driver from the <a target="_blank" href="https://www.nvidia.com/Download/Find.aspx">Nvidia driver download center</a>.</p>
<h3 id="heading-update-and-install-system-utilities">Update and Install System Utilities</h3>
<p>The following snippet updates your existing libraries and other utilities. It uses some variables that are defined in the final script.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"Installing utilities..."</span>
dnf -y update
dnf -y groupinstall <span class="hljs-string">"Development Tools"</span>
dnf install -y openssl-devel cmake3 amazon-efs-utils htop iotop yasm nasm jq
</code></pre>
<h3 id="heading-setup-nvidia-gpu-cuda-and-cudnn">Setup Nvidia GPU, CUDA, and CUDNN</h3>
<p>As the scope of this article is to demonstrate a working GPU-powered FFmpeg on AWS, the following will check whether this is the Graviton2-powered <code>G4g</code> instance which is based on <code>ARM/AARCH64</code> architecture or an Intel-based <code>G4dn</code> instance. Once selected, script will install the appropriate drivers for the architecture.</p>
<pre><code class="lang-bash"><span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-subst">$(uname -m)</span>"</span> = <span class="hljs-string">"aarch64"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"System is running on ARM / AArch64"</span>
    DRIVE_URL=<span class="hljs-string">"https://us.download.nvidia.com/tesla/535.104.05/NVIDIA-Linux-aarch64-535.104.05.run"</span>
    CUDA_SDK_URL=<span class="hljs-string">"https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux_sbsa.run"</span>
    CUDNN_ARCHIVE_URL=<span class="hljs-string">"https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-8.9.5.29_cuda12-archive.tar.xz"</span>
<span class="hljs-keyword">else</span>
    DRIVE_URL=<span class="hljs-string">"https://us.download.nvidia.com/tesla/535.104.05/NVIDIA-Linux-x86_64-535.104.05.run"</span>
    CUDA_SDK_URL=<span class="hljs-string">"https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run"</span>
    CUDNN_ARCHIVE_URL=<span class="hljs-string">"https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-8.9.5.29_cuda12-archive.tar.xz"</span>
<span class="hljs-keyword">fi</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Setting up GPU..."</span>
DRIVER_NAME=<span class="hljs-string">"NVIDIA-Linux-driver.run"</span>
wget -O <span class="hljs-string">"<span class="hljs-variable">$DRIVER_NAME</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$DRIVE_URL</span>"</span>
TMPDIR=<span class="hljs-variable">$LOCAL_TMP</span> sh <span class="hljs-string">"<span class="hljs-variable">$DRIVER_NAME</span>"</span> --disable-nouveau --silent

CUDA_SDK=<span class="hljs-string">"cuda-linux.run"</span>
wget -O <span class="hljs-string">"<span class="hljs-variable">$CUDA_SDK</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$CUDA_SDK_URL</span>"</span>
TMPDIR=<span class="hljs-variable">$LOCAL_TMP</span> sh <span class="hljs-string">"<span class="hljs-variable">$CUDA_SDK</span>"</span> --silent --override --toolkit --samples --toolkitpath=<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/cuda-12.2 --samplespath=<span class="hljs-variable">$CUDA_HOME</span> --no-opengl-libs

CUDNN_ARCHIVE=<span class="hljs-string">"cudnn-linux.tar.xz"</span>
EXTRACT_PATH=<span class="hljs-string">"<span class="hljs-variable">$SRC_DIR</span>/cudnn-extracted"</span>
mkdir -p <span class="hljs-string">"<span class="hljs-variable">$EXTRACT_PATH</span>"</span>

wget -O <span class="hljs-string">"<span class="hljs-variable">$CUDNN_ARCHIVE</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$CUDNN_ARCHIVE_URL</span>"</span>
tar -xJf <span class="hljs-string">"<span class="hljs-variable">$CUDNN_ARCHIVE</span>"</span> -C <span class="hljs-string">"<span class="hljs-variable">$EXTRACT_PATH</span>"</span>
CUDNN_INCLUDE=$(find <span class="hljs-string">"<span class="hljs-variable">$EXTRACT_PATH</span>"</span> -<span class="hljs-built_in">type</span> d -name <span class="hljs-string">"include"</span> -<span class="hljs-built_in">print</span> -quit)
CUDNN_LIB=$(find <span class="hljs-string">"<span class="hljs-variable">$EXTRACT_PATH</span>"</span> -<span class="hljs-built_in">type</span> d -name <span class="hljs-string">"lib"</span> -<span class="hljs-built_in">print</span> -quit)
cp -P <span class="hljs-string">"<span class="hljs-variable">$CUDNN_INCLUDE</span>"</span>/* <span class="hljs-variable">$CUDA_HOME</span>/include/
cp -P <span class="hljs-string">"<span class="hljs-variable">$CUDNN_LIB</span>"</span>/* <span class="hljs-variable">$CUDA_HOME</span>/lib64/
chmod a+r <span class="hljs-variable">$CUDA_HOME</span>/lib64/*
ldconfig
</code></pre>
<p>By now, you should have a working system with an Nvidia device driver which can be checked by running <code>nvidia-smi</code> in the terminal.</p>
<h3 id="heading-install-ffmpeg-prerequisites"><strong>Install FFmpeg Prerequisites</strong></h3>
<p>Before diving into FFmpeg's installation, it's crucial to understand and set up its dependencies, so FFmpeg can process most general process tasks for different formats and get an understanding of how to expand or limit the scope of FFmpeg for your multimedia task.</p>
<h4 id="heading-system-dependencies">System Dependencies</h4>
<p>FFmpeg is a great tool for text processing and text rendering in videos as well. To enable this feature, we will need to install libraries, that are used for text manipulation, embedding subtitles and other fancy operations like embedding the watermark of your brand in the video. These are essential system libraries that FFmpeg requires.</p>
<pre><code class="lang-bash">dnf install -y freetype-devel fribidi-devel harfbuzz-devel fontconfig-devel bzip2-devel
</code></pre>
<h4 id="heading-installing-audio-amp-video-codecs">Installing Audio &amp; Video Codecs</h4>
<p>At its core, FFmpeg functions like a versatile framework, ready to be extended with various plugins and modules. One of the primary ways this extensibility shines is through its support for many audio and video codecs. These codecs are the building blocks that allow FFmpeg to decode and encode media in various formats.</p>
<p>Now we will install different codecs, FFmpeg is like a template that is built in a way anyone can write a plugin like a video codec and that can be used with FFmpeg</p>
<ol>
<li><p><strong>ffnvcodec</strong>: Since the target instance is powered with GPU, <code>ffnvcodec</code> codec enables FFmpeg to leverage NVIDIA GPU acceleration, significantly speeding up video processing tasks for <strong>av1, H.264</strong> and <strong>HEVC</strong>/<strong>H.265</strong></p>
</li>
<li><p><strong>LIBASS</strong>: FFmpeg can use <code>LIBASS</code> for subtitle renderer to handle subtitles in various video formats.</p>
</li>
<li><p><strong>LIBAOM (AV1 Codec Library)</strong>: FFmpeg uses LIBAOM to decode and encode <code>AV1</code> videos, if you want to use software transcoding for <code>AV1</code>.</p>
</li>
<li><p><strong>Other Codecs</strong>: These include libraries for various audio and video formats (e.g., <code>libmp3lame</code> for MP3 audio, <code>opus</code> for the Opus audio codec, and <code>libogg</code> for the Ogg container). In this build we will also enable software encoding of <code>H.264</code> and <code>HEVC/H.265</code> using <code>x264</code> and <code>x265</code> libraries .</p>
</li>
</ol>
<p>By ensuring all these prerequisites are installed and correctly set up, FFmpeg can provide its robust set of features, and users can harness the desired power out of this great utility.</p>
<h3 id="heading-installing-ffmpeg">Installing FFmpeg</h3>
<p>Finally, we will compile GPU-accelerated FFmpeg from the source, with enabled support of all the codecs and libraries we have compiled or installed in previous steps.</p>
<pre><code class="lang-bash">wget https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 &amp;&amp;
tar -jxf ffmpeg-snapshot.tar.bz2 &amp;&amp;
<span class="hljs-built_in">pushd</span> ffmpeg &amp;&amp;
PKG_CONFIG_PATH=<span class="hljs-string">"<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/lib/pkgconfig"</span> \
    ./configure \
    --prefix=<span class="hljs-string">"<span class="hljs-variable">$USR_LOCAL_PREFIX</span>"</span> --disable-static --enable-shared \
    --extra-cflags=<span class="hljs-string">"-I<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/include <span class="hljs-variable">$NVIDIA_CFLAGS</span>"</span> \
    --extra-ldflags=<span class="hljs-string">"-L<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/lib <span class="hljs-variable">$NVIDIA_LDFLAGS</span>"</span> \
    --extra-libs=<span class="hljs-string">'-lpthread -lm'</span> --bindir=<span class="hljs-string">"<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/bin"</span> \
    --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac \
    --enable-libfreetype --enable-libmp3lame --enable-libopus \
    --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 \
    --enable-nonfree --enable-openssl <span class="hljs-variable">$NVIDIA_FFMPEG_OPTS</span> &amp;&amp;
make -j <span class="hljs-variable">$CPUS</span> &amp;&amp;
make install
</code></pre>
<h3 id="heading-verifying-gpu-acceleration-support-in-ffmpeg">Verifying GPU Acceleration Support in FFmpeg</h3>
<p>Once you've set up FFmpeg with GPU acceleration capabilities, it's a good idea to ensure that it recognizes and can utilize the GPU for tasks like video encoding and decoding. The command below checks for the presence of NVIDIA's NVENC (NVIDIA Video Encoder) in the list of supported codecs within FFmpeg:</p>
<pre><code class="lang-bash">ffmpeg -hide_banner -codecs | grep nvenc
</code></pre>
<p>If you see the output codecs with the <code>nvenc</code> label (e.g., <code>h264_nvenc</code>, <code>hevc_nvenc</code>, <code>av1_nvenc</code>), it indicates that FFmpeg has been correctly configured to support GPU-accelerated encoding for those specific codecs using NVIDIA's hardware.</p>
<h2 id="heading-the-complete-script">The Complete Script</h2>
<p>Building upon the various segments we've discussed, here's the consolidated FFmpeg installation script along with the Nvidia GPU installation. This script has been thoroughly tested on <strong>Amazon Linux 2023</strong> and <strong>Ubuntu 22.04</strong> running on AWS <code>G5g</code> instances. It's not just limited to those; its flexibility is its strength. Whether you're on Debian, Red Hat, CentOS, Fedora, openSUSE, or even the sleek Alpine, this script is crafted to serve both <strong>ARM/aarch64</strong> and <strong>x86_64</strong> architectures seamlessly. Dive in and experience the universality of our FFmpeg installation script, bringing the power of multimedia to every corner of the Linux world.</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="cb89936bc947fa727a8ec66e3ddf768a"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/bilalmughal/cb89936bc947fa727a8ec66e3ddf768a" class="embed-card">https://gist.github.com/bilalmughal/cb89936bc947fa727a8ec66e3ddf768a</a></div><p> </p>
<h2 id="heading-hands-on-converting-h264-to-h265-with-gpu-acceleration">Hands-On: Converting H.264 to H.265 with GPU Acceleration</h2>
<p>In this section, we'll take a hands-on approach to show you how to convert an H.264 encoded video to H.265 using the power of NVIDIA's GPU acceleration. This way we can test the installation and experience the power of GPU acceleration in action. To perform this conversion, use the following command:</p>
<pre><code class="lang-bash">ffmpeg -y -hide_banner -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -vf <span class="hljs-string">"scale_cuda=720:480"</span> -c:v hevc_nvenc output.mp4
</code></pre>
<p>In this command:</p>
<ul>
<li><p><code>-hwaccel cuvid</code> and <code>-c:v h264_cuvid</code> uses GPU-based decoding of the H.264 video.</p>
</li>
<li><p><code>-vf "scale_cuda=1920:1080"</code> scales the video using GPU acceleration.</p>
</li>
<li><p><code>-c:v hevc_nvenc</code> instructs FFmpeg to encode the output video using the H.265 codec with NVIDIA's GPU acceleration.</p>
</li>
</ul>
<p>After executing the command, you'll get <code>output.mp4</code> an <strong>H.265</strong> <code>1080p</code> encoded video.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By integrating FFmpeg with GPU hardware acceleration on AWS or any other infra-provider or architecture, you can optimize costs and reduce processing times, but it also future-proofs your workflow for higher-resolution media processing tasks down the line. By compiling from the source we are also addressing the outdated libraries and generalized package issues, which are not fully optimized for your architecture, as discussed in "<a target="_blank" href="https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source">How to install FFmpeg on Linux from source</a>" and some aspects are also discussed in the article <a target="_blank" href="https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix">"Why your AWS Deep learning AMI is Holding you back and how to fix</a> as well. The evolution of multimedia is ceaseless, but with tools like FFmpeg combined with AWS's GPU prowess and cost-effectiveness, you are well-equipped to handle whatever challenges come next. Whether you're a media company looking to scale or a hobbyist aiming for maximum efficiency, GPU-accelerated FFmpeg on AWS is a game-changer.</p>
<div class="hn-embed-widget" id="resources"></div>]]></content:encoded></item><item><title><![CDATA[Bridging Dreams and Reality: How “Builders” Transform Teams]]></title><description><![CDATA[Introduction
In the previous discussion,"Beyond Rockstars: Crafting the Team for Sustainable Success", we established the significance of Rockstars, who drive innovation, and Doers, who ensure steady execution. However, an essential ingredient to bui...]]></description><link>https://mirzabilal.com/bridging-dreams-and-reality-how-builders-transform-teams</link><guid isPermaLink="true">https://mirzabilal.com/bridging-dreams-and-reality-how-builders-transform-teams</guid><category><![CDATA[teambuilding]]></category><category><![CDATA[Rockstar]]></category><category><![CDATA[Product Management]]></category><category><![CDATA[success]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Tue, 19 Sep 2023 08:00:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694896178670/1dc322ef-d309-4a68-8405-b8791c106267.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>In the previous discussion,<a target="_blank" href="https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success">"Beyond Rockstars: Crafting the Team for Sustainable Success"</a>, we established the significance of Rockstars, who drive innovation, and Doers, who ensure steady execution. However, an essential ingredient to building a truly resilient, adaptive, and high-performing team is often overlooked - the "Builder." As promised in my last post, we shall dive deep into understanding this integral role and its transformative impact on team dynamics.</p>
<h2 id="heading-bridging-the-gap-the-builders-role">Bridging the Gap: The Builder's Role</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694906167783/4f7426e6-2174-459c-8949-40b2ac413327.jpeg" alt class="image--center mx-auto" /></p>
<p>Imagine a construction site: The architects are like rockstars, envisioning skyscrapers. Doers are the laborers who lay brick after brick, but who ensures that the architect's dream is realized without overwhelming the workforce? That's the "Builder". A Builder doesn't just construct; they understand, adapt, and create pathways. They fill the gap between the high-level ideas of Rockstars and the pragmatic approach of Doers, ensuring seamless communication and collaboration.</p>
<h2 id="heading-the-unique-qualities-of-a-builder">The Unique Qualities of a Builder</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694908931658/7654ce3b-4e92-4e38-b252-6cce83740b09.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-adaptive-vision">Adaptive Vision</h3>
<p>Builders may not have the creative spark of Rockstars, but they can visualize the bigger picture and break it into actionable steps for doers to execute effectively. The builder can see the project's visionary and practical aspects and lay out a plan for that. This roadmap aligns with the broader vision and is meticulously structured to guide Doers in their execution.</p>
<blockquote>
<p>"You don't have to be a chef to spot a great steak."</p>
</blockquote>
<h3 id="heading-hands-on-approach">Hands-On Approach</h3>
<p>Builders aren't just strategic thinkers but possess a pragmatic touch; they are involved in the ground realities of a project. Their strength lies in their ability to focus on specifics, although not to the same extent as Doers. This hands-on involvement ensures they comprehend the intricacies and challenges firsthand, enabling them to guide both Rockstars and Doers. They ensure that Rockstar's vision is achievable and that Doers have a clear, efficient path to realize it. To put it succinctly:</p>
<blockquote>
<p>"They may not create the complete piece, but they know all the tools and methods very well."</p>
</blockquote>
<h3 id="heading-the-communicator">The Communicator</h3>
<p>Imagine two individuals from the same town, living just next door to each other, but they speak entirely different languages. They might have so much in common, so much to share, yet they're worlds apart simply because they can't communicate.</p>
<p>In the world of team dynamics, this is where a Builder shines. A Builder can speak the languages of both Rockstars and Doers, bridging that communicative divide. They ensure that the lofty ideas of Rockstars and the grounded approach of Doers are not just two parallel lines, but intersecting paths towards a common goal. Their unique position allows them to interpret, refine, and convey messages seamlessly across the team spectrum, ensuring that nothing is "lost in translation" and that all members are truly in sync.</p>
<h2 id="heading-identifying-the-builder-in-your-team">Identifying the Builder in Your Team</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694906358097/4efafef0-b089-40e5-a975-5229d31c78a6.jpeg" alt class="image--center mx-auto" /></p>
<p>Often, the Builder might not be overtly obvious, overshadowed by the aura of Rockstars or the diligent presence of Doers. However, recognizing and fostering this role can be the cornerstone to a project's success. Here are some signs and characteristics to help identify the Builder in your team:</p>
<ol>
<li><p><strong>Mediator in Discussions:</strong> They often mediate during team disagreements, ensuring a middle ground is found.</p>
</li>
<li><p><strong>Clarity in Vision:</strong> While they may not be the source of every idea, they can understand and clarify the big picture, breaking it down into actionable steps.</p>
</li>
<li><p><strong>Hands-on Yet Strategic:</strong> They aren't just about strategy or execution alone. They are often involved in ground-level tasks but can swiftly shift to a bird's eye view when required.</p>
</li>
<li><p><strong>Versatile Skills:</strong> While they might not be the king in any single domain, they possess a broad range of skills and can understand the nuances of multiple disciplines.</p>
</li>
<li><p><strong>People's person:</strong> They resonate with the concerns of both Rockstars and Doers, acting as a bridge for communication and understanding.</p>
</li>
</ol>
<p>Recognizing the Builder is essential. Once identified, their skills can be honed, and their presence can significantly enhance your team's synergy.</p>
<h2 id="heading-the-builders-blueprint">The Builder's Blueprint</h2>
<p>Builders hold a pivotal role in modern team dynamics. Their presence streamlines the workflow, ensuring the entire team operates efficiently. They possess the unique ability to anticipate issues from both Rockstars and Doers, addressing them preemptively and preventing them from becoming more serious ones. This proactive approach cultivates a harmonious environment, fostering a culture of collaboration and mutual respect.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694909149868/1630125d-220d-40df-98f9-d68e793a3eca.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-maximizing-utilization-of-builders">Maximizing Utilization of Builders</h2>
<p>For teams to truly harness the strengths of Builders, a few strategies can be employed.</p>
<h3 id="heading-empowerment">Empowerment</h3>
<p>Empower the builders with the authority to make decisions. This autonomy not only garners respect from other team members but also positions them as effective mediators.</p>
<h3 id="heading-in-the-loop">In the loop</h3>
<p>It's also crucial to maintain frequent check-ins with them. By doing so, teams can ensure that Builders remain aligned with the visionary aspirations of Rockstars while staying grounded to the practical challenges Doers face.</p>
<h3 id="heading-evolution">Evolution</h3>
<p>In an ever-evolving industry landscape, continuous learning is paramount. Keeping Builders updated with industry trends ensures they remain effective bridges between ideation and execution.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By understanding and implementing these strategies, teams can optimize the contributions of Builders, resulting in a cohesive, efficient, and innovative work environment.<br />An orchestra, no matter how talented, is incomplete without its conductor. Similarly, a team, no matter how balanced with Rockstars and Doers, is enhanced with the presence of Builders. They ensure that the melody of innovation and rhythm of execution synchronize in harmony.<br />Do you see a Builder within your team, or may be you recognize some of these traits within yourself? How has their presence (or absence) shaped the dynamics and efficiency of your projects? I'd lover to hear about your experiences.</p>
<h2 id="heading-look-forward-to-the-future">Look Forward to the Future</h2>
<p>Our exploration into team dynamics doesn't end here. In the coming article, we'll discuss optimizing team interactions, nurturing the growth of each role, and the challenges that lie ahead. As always, thank you for your support and engagement. The best teams are yet to be built, and together, we'll discover the blueprint. Stay tuned!</p>
]]></content:encoded></item><item><title><![CDATA[How to install FFmpeg on Linux from Source]]></title><description><![CDATA[Introduction
It was probably 2006 when I first heard about FFmpeg, and I was amazed by its capabilities. FFmpeg is a go-to solution for transcoding, and video manipulation, from trimming to burning the subtitles, adding a watermark, and more. Since F...]]></description><link>https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source</link><guid isPermaLink="true">https://mirzabilal.com/how-to-install-ffmpeg-on-linux-from-source</guid><category><![CDATA[FFmpeg]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Linux]]></category><category><![CDATA[#howtos]]></category><category><![CDATA[how-to]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Mon, 18 Sep 2023 22:00:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755443460317/2dd86c8a-b238-43ca-83f1-a60e25cf195c.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction"><strong>Introduction</strong></h3>
<p>It was probably 2006 when I first heard about FFmpeg, and I was amazed by its capabilities. FFmpeg is a go-to solution for transcoding, and video manipulation, from trimming to burning the subtitles, adding a watermark, and more. Since FFmpeg was first launched, it has come a long way and has become the industry leader for multimedia workload for desktop apps, web, and especially on the backend.
In this article, we will discuss, Why you need to customize FFmpeg to match your requirements? and How you can compile FFmpeg from source along with various essential libraries and codes needed for video processing on different Linux distributions, from Ubuntu to Redhat based systems.</p>
<h3 id="heading-problem">Problem</h3>
<p>Installing FFmpeg directly from a Linux distribution's default repositories may seem like a no-brainer, but this method is filled with potential drawbacks. For one, these repositories might not offer the most recent versions of FFmpeg and essential codecs or libraries, possibly exposing users to security risks and preventing them from accessing the latest features. Moreover, these default builds can be burdened with unnecessary codecs and libraries that many users may never use, or you might stranded in a scenario where the package has everything but does not come with the library you need.
But the challenges don't stop here; in today's diverse device ecosystem, which spans across ARM and x86_64 architectures, a one-size-fits-all build from the repository might not be optimized for a specific device with a specific instruction set. This is especially concerning for multimedia tasks that demand real-time processing, and you want to make the most out of the hardware you have.
Furthermore, for young developers or those new to the Linux landscape, crafting a custom FFmpeg build tailored to their requirements can be a daunting experience. The sea of options, configurations, and dependencies can be overwhelming, leading them to settle for suboptimal, generic builds rather than extracting the true potential of FFmpeg.</p>
<h3 id="heading-why-compile-from-source">Why Compile from Source?</h3>
<p>To overcome discussed problems for newbies to experts, the importance of comprehensive guides and resources to bridge the knowledge gap and empower the next generation of developers to confidently customize their multimedia tools. Following are the notable advantages of using source code as the starting point.</p>
<ol>
<li><p><strong>Customization</strong>: By compiling from the source, you can choose the exact features and codecs you want, leading to a personalized FFmpeg build tailored to your needs.</p>
</li>
<li><p><strong>Smaller Footprint</strong>: When you include only the components you need, the resultant build will often be leaner and require less disk space.</p>
</li>
<li><p><strong>Access to the Latest Code</strong>: Official channels might not always have the latest version of FFmpeg. Compiling from source ensures you're working with the most recent codebase.</p>
</li>
<li><p><strong>Performance Optimizations</strong>: Building from source code can enable certain optimizations specific to your machine's architecture and instruction set, potentially enhancing performance.</p>
</li>
<li><p><strong>Greater Learning Opportunity</strong>: Compiling software from a source provides a deeper understanding of the software and its dependencies.</p>
</li>
</ol>
<h3 id="heading-installing-dependencies">Installing Dependencies</h3>
<p>Before we jump into the installation process, it's essential to set up our system with the necessary dependencies.</p>
<h4 id="heading-on-ubuntu">On Ubuntu:</h4>
<pre><code class="lang-bash">sudo apt update
sudo apt install -y build-essential yasm cmake libtool libc6 libc6-dev unzip wget
</code></pre>
<h4 id="heading-on-redhat-based-distributions">On RedHat-based distributions:</h4>
<pre><code class="lang-bash">sudo yum groupinstall <span class="hljs-string">"Development Tools"</span>
sudo yum install -y yasm cmake libtool unzip wget
</code></pre>
<h3 id="heading-installing-dependencies-and-codes">Installing dependencies and codes:</h3>
<p>Once your build environment is set up, the next critical step is to install the various codecs and libraries that FFmpeg relies upon or that you wish to utilize for specific multimedia tasks. Remember, one of the key benefits of building from source is the ability to customize your FFmpeg installation, ensuring it's streamlined to your needs; here you can pick and drop or even add codecs or libraries that you wish to use.</p>
<p>In the final script, we have provided a comprehensive list of dependencies and libraries, ensuring that you have a broad spectrum of multimedia capabilities at your fingertips.</p>
<h3 id="heading-installing-ffmpeg">Installing FFmpeg</h3>
<p>You can obtain the latest source code from FFmpeg's official website or use <code>git</code>:</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://git.ffmpeg.org/ffmpeg.git ffmpeg
<span class="hljs-built_in">cd</span> ffmpeg
</code></pre>
<h3 id="heading-configuration">Configuration</h3>
<p>This step is crucial. The <code>./configure</code> script allows you to select which features and codecs to include. For a basic setup, you can run:</p>
<pre><code class="lang-bash">./configure \
            --prefix=<span class="hljs-string">"<span class="hljs-variable">$USR_LOCAL_PREFIX</span>"</span> \
            --disable-static --enable-shared \
            --extra-cflags=<span class="hljs-string">"-I<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/include <span class="hljs-variable">$NVIDIA_CFLAGS</span>"</span> \
            --extra-ldflags=<span class="hljs-string">"-L<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/lib <span class="hljs-variable">$NVIDIA_LDFLAGS</span>"</span> \
            --extra-libs=<span class="hljs-string">'-lpthread -lm'</span> \
            --bindir=<span class="hljs-string">"<span class="hljs-variable">$USR_LOCAL_PREFIX</span>/bin"</span> \
            --enable-gpl --enable-libaom --enable-libass \
            --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
            --enable-libopus --enable-libvorbis --enable-libvpx \
            --enable-libx264 --enable-libx265 --enable-nonfree \
            --enable-openssl
</code></pre>
<p>However, for a more customized setup, use flags like <code>--enable-codec</code>, <code>--disable-codec</code>, <code>--enable-libx264</code>, etc. Check <code>./configure --help</code> for a full list of options.</p>
<h3 id="heading-compilation-amp-installation">Compilation &amp; Installation</h3>
<p>Once configured, compile and install FFmpeg here:</p>
<pre><code class="lang-bash">make -j$(nproc)
sudo make install
</code></pre>
<p>This will use all your CPU cores for the compilation (<code>-j$(nproc)</code>) and then install the software.</p>
<h3 id="heading-verification">Verification</h3>
<p>To verify your FFmpeg installation:</p>
<pre><code class="lang-bash">ffmpeg -version
</code></pre>
<h3 id="heading-wrap-up-amp-the-magic-script">Wrap up &amp; the magic script:</h3>
<p>By now, you should have a basic understanding of how to customize FFmpeg. If so, that was our goal. If you have any confusion, leave a comment and I'll be happy to discuss. To streamline everything and every step mentioned here, there's a script for you to simply run, and it will handle the entire process.</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="83de56f470bf5b91a7c4424cce4071ac"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/bilalmughal/83de56f470bf5b91a7c4424cce4071ac" class="embed-card">https://gist.github.com/bilalmughal/83de56f470bf5b91a7c4424cce4071ac</a></div><p> </p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Now that we've gone through the process, I'm curious: Where do you plan to use your custom-tailored FFmpeg? Are you working on an innovative multimedia project, developing a web application, or just experimenting with video processing for personal use? FFmpeg's versatility excels in a multitude of applications, from large-scale video platforms to hobbyist projects. Share your plans or current FFmpeg projects in the comments below. Let's learn from one another and discover even more unique use cases for this powerful tool. Remember, the world of multimedia is vast, and with FFmpeg, the possibilities are endless.</p>
]]></content:encoded></item><item><title><![CDATA[The Dark Side of High-Tech Success:  Addressing Mental Well-being in Tech]]></title><description><![CDATA[Introduction
In an era of rapid technological advancement, Software engineers and other IT professionals are in high demand. They might be earning good salaries but these lucrative financial opportunities do not come for free, and a hidden cost often...]]></description><link>https://mirzabilal.com/the-dark-side-of-high-tech-success-addressing-mental-well-being-in-tech</link><guid isPermaLink="true">https://mirzabilal.com/the-dark-side-of-high-tech-success-addressing-mental-well-being-in-tech</guid><category><![CDATA[Mental Health]]></category><category><![CDATA[wellness]]></category><category><![CDATA[leadership]]></category><category><![CDATA[industry]]></category><category><![CDATA[mentalhealth]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Wed, 13 Sep 2023 10:00:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694277504230/16d7c0e1-29c7-4590-a02e-62b65ca433ff.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>In an era of rapid technological advancement, Software engineers and other IT professionals are in high demand. They might be earning good salaries but these lucrative financial opportunities do not come for free, and a hidden cost often goes unnoticed - the toll on their mental health. IT Professionals are facing mental health issues because of the intense work stress in this ever-demanding industry. In this article, we will build a case around the responsibilities and importance of the role of industry leaders and organizational leadership in addressing concerns related to the so-far neglected human side of the industry.</p>
<h2 id="heading-the-wealth-well-being-paradox">The Wealth-Well-being Paradox</h2>
<p>The software developers and IT professionals are currently amongst the highly compensated in the job market. However, the seemingly attractive salaries can often obscure the challenging work environment, characterized by stress, long days and looming deadlines. This paradoxical situation raises significant concerns about the mental well-being of those working in this industry.</p>
<h2 id="heading-mental-health-issues-in-the-tech-industry">Mental Health Issues in the Tech Industry</h2>
<p>The tech industry is notorious for its work culture that promotes continuous productivity and sacrifices personal well-being for the sake of meeting unrealistic targets at times. As a result, software developers and IT experts face a host of mental health challenges:</p>
<ol>
<li><p><strong>Burnout:</strong> This physical and emotional exhaustion due to a demanding work environment leads to burnout. Which affects an individual's productivity, feelings of detachment, and diminished sense of personal achievement.</p>
</li>
<li><p><strong>Isolation:</strong> Long hours and remote work arrangements can lead to feelings of isolation, which can aggravate mental health concerns due to the lack of social interaction and result in loneliness and deteriorating mental health.</p>
</li>
<li><p><strong>Anxiety and Depression:</strong> The constant desire to perform at their best and the fear of being surpassed by peers weighed heavily on their minds. The stigma of being perceived as weak or incapable prevents employees from seeking assistance, exacerbating the condition.</p>
</li>
<li><p><strong>Imposter Syndrome:</strong> A lot of tech professionals feel like they're not good enough or are under-achieving, even when they succeed. This feeling of "can do more", increase anxiety and negatively impact self-esteem.</p>
</li>
</ol>
<h2 id="heading-the-role-of-industry-leaders">The Role of Industry Leaders</h2>
<p>Industry leaders and organizational leadership have a crucial role to play in addressing the mental health crisis amongst their subordinate and set an example for the industry to follow:</p>
<ol>
<li><p><strong>Championing Work-Life Balance:</strong> It's essential for leaders to emphasize and devise a balanced work-life routine. By motivating staff to take regular breaks, use their holidays, and establish clear boundaries between work and personal time, they can significantly alleviate stress amongst the team.</p>
</li>
<li><p><strong>Work-Life Boundaries in Remote Settings:</strong> While offering flexible work arrangements like remote work and adaptable hours can help ease stress amongst professionals from tech sector, it's vital to recognize and address the blurred lines between work and personal time that often come with remote work. Leaders should emphasis the importance of identifying and drawing clear boundaries to maintain a healthy work-life balance even when working from home.</p>
</li>
<li><p><strong>De-stigmatize Mental Health:</strong> Industry leaders should actively work to de-stigmatize mental health issues. Creating an open and supportive environment where employees feel comfortable discussing their struggles and seeking help is essential, and talking about mental health should not be considered a taboo.</p>
</li>
<li><p><strong>Mandatory Mental Health Sessions:</strong> Organizations should prioritize and invest in mental health support programs. Offering counseling services, stress management workshops, and other mental health resources is crucial. Employees should be required and even rewarded to attend these sessions to ensure they're equipped to handle the pressures of their roles.</p>
</li>
<li><p><strong>Manage Workload:</strong> Leadership should assess and manage workloads to prevent burnout and avoid setting unrealistic goals and targets. Distributing tasks evenly, setting realistic deadlines, and avoiding excessive overtime can contribute to a healthier work environment.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion:</h2>
<p>The software development and IT sectors are lucrative, but they're also tough on mental well-being. We can't ignore the growing mental health strain that professionals in these areas are grappling with. It's essential that industry bigwigs and company leaders genuinely listen and act. They need to foster a caring work environment, offer solid mental health support, and tear down the stigma around discussing mental challenges. Recognizing and acting on these issues is the only way to make sure our tech gurus aren't just well-paid, but also mentally healthy and happy. After all, true success in the tech world should strike a balance between a good paycheck and peace of mind.</p>
<hr />
<blockquote>
<p>"Almost everything will work again if you unplug it for a few minutes, including you." <strong>- Anne Lamott</strong></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Beyond Rockstars: Crafting the Team for Sustainable Success]]></title><description><![CDATA[Introduction
If you possess prior experience working in industries such as technology or any other field, it is probable that you have encountered certain colloquialisms, such as "Ninjas," "Wizards," or "Rockstars." These terms are used to identify e...]]></description><link>https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success</link><guid isPermaLink="true">https://mirzabilal.com/beyond-rockstars-crafting-the-team-for-sustainable-success</guid><category><![CDATA[teamwork]]></category><category><![CDATA[teambuilding]]></category><category><![CDATA[team]]></category><category><![CDATA[work]]></category><category><![CDATA[leadership]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Mon, 11 Sep 2023 08:00:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694425312741/578bfc0c-fb43-4648-a83c-84dc5c1d5169.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>If you possess prior experience working in industries such as technology or any other field, it is probable that you have encountered certain colloquialisms, such as "Ninjas," "Wizards," or "Rockstars." These terms are used to identify exceptionalism. While having a team of such talented individuals can offer significant advantages and sound great on paper, building a team entirely of "Rockstars" in the real world may be counterproductive. I have worked for around 18 years, occupying various roles from Junior Software Developer to VP of Engineering. Based on my good and bad experiences, I will explore why an ideal team isn't made solely of Rockstars or just Doers but goes beyond individual members' technical abilities. An efficient team requires a balanced mix of precisely calibrated and functioning components, much like a well-tuned automobile engine.</p>
<h2 id="heading-the-rockstars-team-high-octane-but-unstable">The Rockstars Team: High-Octane But Unstable</h2>
<p>Imagine a car with a combustion engine made entirely of the most potent combustion cylinders. The concept sounds spectacular on paper - each cylinder, a Rockstar in its own right, promises to deliver unparalleled performance. However, in actuality, this engine would soon turn into a nightmare. The extreme power generated would be too much for any vehicle to handle, leading to an unstable, inefficient, and ultimately unworkable machine. A team full of such remarkably capable individuals may generate many brilliant ideas. Still, the risk of conflicting egos, misaligned objectives, and lack of focus on routine but necessary tasks could derail the team's success.</p>
<h3 id="heading-drawbacks-of-a-rockstar-only-team">Drawbacks of a Rockstar-Only Team</h3>
<ol>
<li><p><strong>Conflicting Ideas:</strong> When everyone is a visionary, aligning the team to a common goal becomes challenging.</p>
</li>
<li><p><strong>Ego Clashes:</strong> Rockstars are accustomed to being in the spotlight, and having multiple such personalities in a team can lead to conflicts.</p>
</li>
<li><p><strong>Neglected Fundamentals:</strong> While everyone pursues the next big thing, routine but essential tasks that keep the project moving may be overlooked.</p>
</li>
</ol>
<h2 id="heading-the-doers-team-stable-but-stagnant">The Doers Team: Stable But Stagnant</h2>
<p>Let's consider a car whose wheels are its only components. While wheels are essential for any vehicle to move, a car made only of wheels won't have the power or functionality to go anywhere fast or effectively. Likewise, a team of Doers might excel in day-to-day tasks and bring stability to a project. Yet, it may lack the creative spark and drive to innovate and evolve, which is essential for taking the next step in product growth.</p>
<h3 id="heading-drawbacks-of-a-doer-only-team">Drawbacks of a Doer-Only Team</h3>
<ol>
<li><p><strong>Lack of Innovation:</strong> Doers are excellent at following instructions but have little to no will or capacity to innovate.</p>
</li>
<li><p><strong>Dependency on Guidance:</strong> This type of team tends to be passive and waits for instructions instead of taking the initiative to solve problems independently.</p>
</li>
<li><p><strong>Resistance to Change:</strong> Such teams can resist adopting new methods or technologies, ultimately hindering progress.</p>
</li>
</ol>
<h2 id="heading-the-perfect-recipe-mixing-rockstars-and-doers">The Perfect Recipe - Mixing Rockstars and Doers</h2>
<p>A balanced team comprises diverse skill sets, talents, and personalities. A perfectly designed car needs cylinders for power and wheels for movement. The perfect team needs both exceptional performers and diligent workers to function effectively.</p>
<h3 id="heading-components-of-a-mixed-team">Components of a Mixed Team</h3>
<ol>
<li><p><strong>Domain-specific Rockstars:</strong> Depending on the size and nature of your organization, find a Rockstar or two for each crucial domain - be it front-end development, back-end architecture, or data science.</p>
</li>
<li><p><strong>Reliable Doers:</strong> Populate the rest of the team with Doers who excel in execution. They will be the ones to implement the vision set forth by the Rockstars.</p>
</li>
<li><p><strong>Interdisciplinary Understanding:</strong> Encourage mutual respect and understanding. Rockstars should appreciate the execution skills of Doers, and Doers should respect the vision of Rockstars.</p>
</li>
</ol>
<h2 id="heading-managing-the-mix-the-role-of-leadership">Managing the Mix - The Role of Leadership</h2>
<p>As a leader, your role is to assemble this balanced team and ensure its components work harmoniously. Just like a car's engine and wheels need a skilled driver at the helm, a mixed team needs strong leadership to steer it towards its objectives.</p>
<ol>
<li><p><strong>Setting Expectations:</strong> Define roles and responsibilities and ensure everyone understands their specific and collective goals.</p>
</li>
<li><p><strong>Encouraging Collaboration:</strong> Facilitate open communication between Rockstars and Doers. Promote an environment where each can learn from the other.</p>
</li>
<li><p><strong>Monitoring and Tuning:</strong> Periodically review team performance. If the team is leaning too much toward innovation and venturing into impractical or unrealistic ideas at the expense of execution, or vice versa, recalibrate.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In the quest for building a high-performing team, it's easy to be seduced by the allure of stacking your team with exceptional individuals. While the potential for innovation and high performance is tempting, it's crucial to remember that too much of a good thing can be harmful. Conversely, a team comprising executors may get the job done but could struggle with stagnation. Therefore, like a well-engineered car, a balanced mix of Rockstars for driving innovation and Doers for steady execution is often the most effective route to long-term success.</p>
<h2 id="heading-whats-next">What's Next?</h2>
<p>So far, we've discussed the essential roles of Rockstars and Doers in a successful team. But what if there was another element - one that could make all the difference? Is your team truly complete? In our upcoming discussion, we will delve deeper into the composition of an ideal team and the importance of another element that will redefine how you approach team building.</p>
<hr />
<p>Thank you for taking the time to read this article. Your interest and support are highly appreciated. I am eager to share more insights with you in the future. Please stay tuned for more updates.</p>
]]></content:encoded></item><item><title><![CDATA[Why Your AWS Deep Learning AMI is Holding You Back and How to Fix]]></title><description><![CDATA[If you're exploring your options for Deep Learning on AWS, you've likely considered using Deep Learning AMIs (Amazon Machine Images) to simplify your setup. Although pre-configured environments can be a good starting point and look like a no-brainer,...]]></description><link>https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix</link><guid isPermaLink="true">https://mirzabilal.com/why-your-aws-deep-learning-ami-is-holding-you-back-and-how-to-fix</guid><category><![CDATA[AWS]]></category><category><![CDATA[Deep Learning]]></category><category><![CDATA[NVIDIA]]></category><category><![CDATA[cuda]]></category><category><![CDATA[ec2]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Sat, 09 Sep 2023 16:37:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694277041524/172e7510-80c9-418d-9bb7-b46429d9075f.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're exploring your options for Deep Learning on AWS, you've likely considered using Deep Learning AMIs (Amazon Machine Images) to simplify your setup. Although pre-configured environments can be a good starting point and look like a no-brainer, but they have several limitations that will haunt you in the long run.</p>
<h2 id="heading-the-bloatware-problem">The Bloatware Problem</h2>
<p>Deep Learning Amazon Machine Images (DLAMI) comes pre-installed with a plethora of applications, frameworks, and libraries. You will not need many of them in your production environment and sometimes not even in development.</p>
<h2 id="heading-outdated-drivers-and-toolkits">Outdated Drivers and Toolkits</h2>
<p>Your favorite deep learning framework released a new version that offers a valuable addition to your application. You are eager to start using it but unfortunately discover that your toolkit and drivers are outdated, dampening your enthusiasm. Now you're locked into using older drivers, toolkits, and older framework and misses out on your favorite new feature of Deep Learning, which you were so excited about.</p>
<h2 id="heading-dependency-hell">Dependency Hell</h2>
<p>Installing required modules or libraries for your application can be challenging with these DLAMIs. You may encounter an issue where the module you are attempting to install requires version 2 of <code>XYZ</code>, but you only have version <code>1.5</code> installed. This issue should be resolved by simply updating <code>XYZ</code>. However, upon attempting that, you may find that another application <code>ABC</code> or library requires <code>XYZ</code>. When you try to remove <code>ABC</code>, which your application does not neet, but to your surprise, yet another application is dependent on it, and this chain of dependencies seems never-ending.</p>
<h2 id="heading-limited-architecture-support">Limited Architecture Support</h2>
<p>Suppose you want to leverage cost-effective instances like <code>g5g.xlarge</code> for deep learning inferences. In that case, you're out of luck because no Deep Learning AMIs support them, or the only solution available has an older OS or outdated build tools. Especially for ARM-based instances, your choices are minimal. For Example, the only DLAMI available for the mentioned instance family is NVIDIA DLAMI, built on top of older version of Ubuntu 20.04.</p>
<h2 id="heading-solution">Solution</h2>
<p>Frustrated with these limitations ourselves, We've developed an automated, customizable script that can set up a high-performing deep learning environment on AWS EC2. This script downloads the latest Nvidia Drivers, CUDA 12.2, and cuDNN library. It uses the latest <strong>Amazon Linux 2023</strong> as its base AMI. It offers several advantages, including support for the latest Linux Kernel 6 and more recent versions of GCC and other build tools and utilities. This script clones PyTorch and compiles it from the source to ensure you have the latest CUDA device support.</p>
<h2 id="heading-performance-and-cost-benefits">Performance and Cost Benefits</h2>
<p>The customization allows for a lean, performance-optimized setup with a minimal footprint.  As in this script, PyTorch is compiled from source after cloning it from the official repository. It offers advantages like hardware-specific optimization and the use of up-to-date code. Hence resulting in better performance and security as compared to pre-built Pytorch module. And if your compute tasks can tolerate interruptions or you can design your application with failover tolerance in mind, you can take advantage of spot instances, which are incredibly cost-effective at as low as <code>$0.152</code> per hour these days.</p>
<h2 id="heading-want-the-full-step-by-step-guide-dive-in-here">Want the Full Step-By-Step Guide? Dive In Here!</h2>
<p>For a comprehensive guide addressing these problems and access to this game-changing script, check out our complete guide at <a target="_blank" href="https://jumpshare.com/blog/deep-learning-on-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2/">Deep Learning on AWS Graviton2, NVIDIA Tensor T4G for as Low as Free with CUDA 12.2</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Deep Learning with “AWS Graviton2 + NVIDIA Tensor T4G” for as low as free* with CUDA 12.2]]></title><description><![CDATA[* The “as low as free” tagline is based on *g5g.xlarge* spot instance rates, which have been as low as $0.1519/hr.

Introduction
The world we live in today heavily relies on artificial intelligence. From vacuum bots to sales support, from self-drivin...]]></description><link>https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d</link><guid isPermaLink="true">https://mirzabilal.com/deep-learning-with-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2-56d8457a6f6d</guid><category><![CDATA[AWS]]></category><category><![CDATA[Deep Learning]]></category><category><![CDATA[cuda]]></category><category><![CDATA[NVIDIA]]></category><category><![CDATA[Cloud Computing]]></category><dc:creator><![CDATA[Mirza Bilal]]></dc:creator><pubDate>Mon, 04 Sep 2023 08:02:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281107265/f8995248-8f13-4cfc-9910-0a5f52b188e9.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>* The “as low as free” tagline is based on <code>*g5g.xlarge*</code> spot instance rates, which have been as low as $0.1519/hr.</p>
</blockquote>
<h1 id="heading-introduction">Introduction</h1>
<p>The world we live in today heavily relies on artificial intelligence. From vacuum bots to sales support, from self-driving cars to disease detection, from finding the content you want to consume to translating from a foreign language to your native one. AI is behind every great product out there, and the need for an efficient, cost-effective, and scalable deep learning architecture has never been more critical.</p>
<p>The G5g instances powered by Amazon’s own Graviton2 processor and also feature NVIDIA T4G Tensor Core GPUs are a cost-effective alternative to Intel’s and AMD’s powered instances for deploying deep learning applications.</p>
<h1 id="heading-the-dilemma">The Dilemma</h1>
<p>AWS offers robust, powerful, cost-effective architecture for running artificial intelligence and deep learning tasks. One of the advantages is the option to use spot instances, which are far more cost-effective at times and up to 70% cheaper than on-demand instances.</p>
<p>For example, the spot pricing history for the <code>g5g.xlarge</code> instance in various “us-east” zones ranged from <strong>$0.1720</strong> to <strong>$0.1519</strong> per hour for the past three months. These rates are tempting, but at the time of writing, no official <strong>Amazon Linux 2023</strong> Deep learning AMI is available for the Amazon <strong>G5g</strong> instances family. Setting up the environment can be cumbersome: finding drivers, the correct dev toolchain, and a pre-compiled PyTorch module supporting the latest DL toolkit.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281084800/54ba784f-cd64-4e6c-b843-b0c0132ed617.png" alt /></p>
<p>Spot price history for g5g.xlarge for the last three months.</p>
<h1 id="heading-navigating-the-challenge-a-how-to-guide">Navigating the Challenge — A How-To Guide</h1>
<p>This aims to bridge the gap by offering comprehensive step-by-step instructions suitable for newcomers and seasoned data scientists. The goal is to enable you to leverage these state-of-the-art technologies at a meager cost without the hassle of finding the right driver and packages for the G5g family. Eventually, we will compile all the individual steps into a single script that will further streamline the process.</p>
<h2 id="heading-1-launching-an-instance">1. Launching an Instance</h2>
<p>For setting up an instance, we’ll use <code>g5g.4xlarge</code> instance. The idea behind using a more powerful instance is to accelerate compilation time. We will launch the build instance with the AWS Command Line Interface (aws cli).</p>
<p>First, set the following environment variables:</p>
<ul>
<li><p><code>REGION</code>: Specifies the AWS region, e.g., ‘us-east-1’.</p>
</li>
<li><p><code>SECURITY_GROUPS</code>: Your security group ID(s).</p>
</li>
<li><p><code>KEY_PAIR</code>: The name of your SSH key pair.</p>
</li>
<li><p><code>SUBNET</code>: The ID of your subnet.</p>
</li>
</ul>
<p>If you have any confusion about these variables. You can refer to the <a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/security-groups.html">security group,</a> <a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html">keypair,</a> and <a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html">subnets</a> documentation.</p>
<p>Once you have these values, you can set these variables like this.</p>
<p>export REGION='us-east-1'<br />export SECURITY_GROUPS='YourFirstSecurityGroupIdsHere'<br />export KEY_PAIR='YourSSHKeyNameHere'<br />export SUBNET='YourSubnetHere'</p>
<p>Next, we need to find the latest <strong>Amazon Linux 2023 AMI ID</strong> so you will get the latest AMI every time you run this script. The following command will fetch the AMI ID and store it as <code>AMI_ID</code>.</p>
<p>Let’s launch the instance using the AMI ID we retrieved earlier by executing:</p>
<pre><code class="lang-bash">aws ec2 run-instances \
--image-id <span class="hljs-variable">$AMI_ID</span> \
--instance-type g5g.4xlarge \
--key-name <span class="hljs-variable">$KEY_PAIR</span> \
--subnet-id <span class="hljs-variable">$SUBNET</span> \
--security-group-ids <span class="hljs-variable">$SECURITY_GROUPS</span> \
--region <span class="hljs-variable">$REGION</span> \
--block-device-mappings <span class="hljs-string">'[{"DeviceName":"/dev/xvda","Ebs":{"VolumeSize":20,"VolumeType":"gp3"}}]'</span> \
--tag-specifications <span class="hljs-string">'ResourceType=instance,Tags=[{Key=Name,Value=AMI-Builder}]'</span>
</code></pre>
<p>This command initiates a <code>g5g.4xlarge</code> instance with the Latest Amazon Linux 2023 AMI ID. It also configures the instance to use the specified security groups, key pair, and subnet we provided in environment variables. We’ve also attached 20 GB of storage to the root device for downloading different libraries and PyTorch compilation.</p>
<h2 id="heading-2-installing-system-updates-and-required-packages">2. Installing System Updates and Required Packages</h2>
<p>Setting up any machine, be it local or in the cloud, it is always a good practice to keep it updated. This part will install all the updates and tools used in compilation or running AI tasks.<br />But before going to Gung Ho, We recommend taking an overview of the guide first and checking the complete script at the end of this tutorial, which should save you from lots of trouble.</p>
<p>First, let’s define some essential environment variables.</p>
<pre><code class="lang-bash">CUDA_HOME=/usr/<span class="hljs-built_in">local</span>/cuda
HOME_DIR=/home/ec2-user
</code></pre>
<p>Now, we’ll create a function called <code>install_utils</code> that carries out a series of tasks.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">install_utils</span></span>() {
    <span class="hljs-comment"># Update all system packages to their latest versions</span>
    dnf -y update

    <span class="hljs-comment"># Install development tools, which include compilers and other utilities</span>
    dnf -y groupinstall <span class="hljs-string">"Development Tools"</span>

    <span class="hljs-comment"># Install the packages that are specifically required for our setup</span>
    dnf install -y openssl-devel cmake3 rust cargo
    dnf install -y amazon-efs-utils htop iotop yasm nasm jq python3-pip python-devel cronie cronie-anacron

    <span class="hljs-comment"># Add necessary paths to the .bashrc file</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"PATH=<span class="hljs-variable">$CUDA_HOME</span>/bin:\$PATH"</span> | sudo tee -a <span class="hljs-variable">$HOME_DIR</span>/.bashrc
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"LD_LIBRARY_PATH=<span class="hljs-variable">$CUDA_HOME</span>/lib64:\$LD_LIBRARY_PATH"</span> | sudo tee -a <span class="hljs-variable">$HOME_DIR</span>/.bashrc

    <span class="hljs-comment"># Configure shared libraries</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"/usr/local/lib"</span> | sudo tee /etc/ld.so.conf.d/usr-local-lib.conf
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"/usr/local/lib64"</span> | sudo tee -a /etc/ld.so.conf.d/usr-local-lib.conf
}
</code></pre>
<p>By running this <code>install_utils</code> function, you will have an updated OS and development tools needed in later steps.</p>
<h2 id="heading-3-install-latest-nvidia-drivers-cuda-122-toolkit-and-cuda-deep-neural-network-library">3. Install Latest NVIDIA Drivers, CUDA 12.2 Toolkit, and Cuda Deep Neural Network library:</h2>
<p>In this step, we will install the NVIDIA GPU driver, Latest CUDA 12.2 toolkit, and CUDA Deep Neural Network (CuDNN) libraries. This part uses the latest driver and toolkit released on August 29, 2023. If you read it later, you can update the URLs for the latest driver and libraries; everything else will be the same. Steps to find the latest driver, toolkit, and library are also mentioned below.</p>
<h3 id="heading-install-nvidia-gpu-driver"><strong>Install NVIDIA GPU Driver</strong></h3>
<p>To download and install the NVIDIA Tesla T4G driver, execute</p>
<p>wget https://us.download.nvidia.com/tesla/535.104.05/NVIDIA-Linux-aarch64-535.104.05.run<br />sh NVIDIA-Linux-aarch64-535.104.05.run --disable-nouveau --silent</p>
<p>If everything goes smooth; you should have a working NVIDIA driver by now, which can be checked by running the NVIDIA system management interface command <code>nvidia-smi</code> in the terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281087225/b5efeedd-4b91-4ca0-ae70-07ae6d56be7f.png" alt class="image--center mx-auto" /></p>
<p>nvidia-smi — NVIDIA System Management Interface</p>
<p>The latest drivers for NVIDIA Tesla T4G can be found <a target="_blank" href="https://www.nvidia.com/Download/Find.aspx">here</a> by selecting the following options.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281089558/36dc8212-9ca8-4b4c-be1e-0c855c6ff610.png" alt /></p>
<p>For guidance on selecting the correct driver, refer to the options above.</p>
<h3 id="heading-install-cuda-toolkit">Install CUDA Toolkit</h3>
<p>The next step involves downloading and installing the CUDA 12.2 toolkit. which can be done by running following bash commands</p>
<pre><code class="lang-bash">wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux_sbsa.run
sh cuda_12.2.2_535.104.05_linux_sbsa.run --silent --override \
--toolkit --samples --toolkitpath=/usr/<span class="hljs-built_in">local</span>/cuda-12.2 \
--samplespath=<span class="hljs-variable">$CUDA_HOME</span> --no-opengl-libs
</code></pre>
<p>To find the latest version, visit <a target="_blank" href="https://developer.nvidia.com/cuda-toolkit">NVIDIA’s developer page</a> and use the following selection.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281091521/2d354046-5d71-422d-96fa-68c5e3c2c922.png" alt /></p>
<p>Follow the options above to choose the right CUDA Toolkit for your setup.</p>
<h3 id="heading-install-nvidia-cudar-deep-neural-network-library-cudnn">Install NVIDIA CUDA® Deep Neural Network library (cuDNN):</h3>
<p>Lastly, we’ll install the CuDNN library for “Server Base System Architecture (SBSA)”.</p>
<pre><code class="lang-bash">wget https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-8.9.4.25_cuda12-archive.tar.xz
tar -xf cudnn-linux-sbsa-8.9.4.25_cuda12-archive.tar.xz
cp -P cudnn-linux-sbsa-8.9.4.25_cuda12-archive/include/* <span class="hljs-variable">$CUDA_HOME</span>/include/
cp -P cudnn-linux-sbsa-8.9.4.25_cuda12-archive/lib/* <span class="hljs-variable">$CUDA_HOME</span>/lib64/
chmod a+r <span class="hljs-variable">$CUDA_HOME</span>/lib64/*
</code></pre>
<p>Latest cuDNN can be downloaded from <a target="_blank" href="https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/">here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281093543/e6a6e90a-40d7-46ab-bb79-4ef56f7a3ed6.png" alt /></p>
<p>List of available cuDNN sbsa libraries for CUDA 11 and CUDA 12.</p>
<p>By combining all three, we will have the following function, which we will use in the final script as well.</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">setup_gpu</span></span>() {
    wget https://us.download.nvidia.com/tesla/535.104.05/NVIDIA-Linux-aarch64-535.104.05.run
    sh NVIDIA-Linux-aarch64-535.104.05.run --disable-nouveau --silent

    wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux_sbsa.run
    sh cuda_12.2.2_535.104.05_linux_sbsa.run --silent --override --toolkit --samples --toolkitpath=/usr/<span class="hljs-built_in">local</span>/cuda-12.2 --samplespath=<span class="hljs-variable">$CUDA_HOME</span> --no-opengl-libs

    wget https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-8.9.4.25_cuda12-archive.tar.xz
    tar -xf cudnn-linux-sbsa-8.9.4.25_cuda12-archive.tar.xz
    cp -P cudnn-linux-sbsa-8.9.4.25_cuda12-archive/include/* <span class="hljs-variable">$CUDA_HOME</span>/include/
    cp -P cudnn-linux-sbsa-8.9.4.25_cuda12-archive/lib/* <span class="hljs-variable">$CUDA_HOME</span>/lib64/
    chmod a+r <span class="hljs-variable">$CUDA_HOME</span>/lib64/*
    ldconfig
}
</code></pre>
<h2 id="heading-4-compiling-and-installing-cuda-122-enabled-pytorch">4. Compiling and Installing CUDA 12.2 enabled PyTorch</h2>
<p>Next we will compile and install PyTotch from source with the latest CUDA support for ARM-based ec2 instances, along with all the necessary Python packages.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Download and install ccache for faster compilation</span>
wget https://github.com/ccache/ccache/releases/download/v4.8.3/ccache-4.8.3.tar.xz
tar -xf ccache-4.8.3.tar.xz
<span class="hljs-built_in">pushd</span> ccache-4.8.3
cmake .
make -j <span class="hljs-variable">$CPUS</span>
make install
<span class="hljs-built_in">popd</span>
<span class="hljs-comment"># Install NumPy, a dependency for PyTorch</span>
dnf install -y numpy
<span class="hljs-comment"># Install Python typing extensions for better type-checking</span>
sudo -u ec2-user pip3 install typing-extensions
<span class="hljs-comment"># Clone PyTorch repository and install from source</span>
git <span class="hljs-built_in">clone</span> --recursive https://github.com/pytorch/pytorch.git
<span class="hljs-built_in">pushd</span> pytorch
python3 setup.py install
<span class="hljs-built_in">popd</span>
<span class="hljs-comment"># Refresh the dynamic linker run-time bindings</span>
ldconfig
<span class="hljs-comment"># Install additional Python libraries for PyTorch</span>
sudo -u ec2-user pip3 install sympy filelock fsspec networkx
</code></pre>
<h2 id="heading-5-test-your-installation">5. Test Your Installation</h2>
<p>After you’ve gone through the installation process, you’ll want to ensure that PyTorch and CUDA are working as expected. Run the following command to test the setup.</p>
<pre><code class="lang-bash">python3 -c <span class="hljs-string">"import torch; print('Using device: ', torch.device('cuda' if torch.cuda.is_available() else 'cpu'))"</span>;
</code></pre>
<p>If the device returns ‘cuda,’ then congratulations, you’ve successfully installed PyTorch with latest CUDA support!</p>
<h1 id="heading-complete-script-for-effortless-setup">Complete script for effortless Setup 🪄</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281095562/c1aea5d5-7033-478a-bb8a-afb63a6f0a4c.png" alt /></p>
<p>Ready for some magic? Before getting started, ensure that your AWS CLI is properly configured. If you haven’t done this, refer to the <a target="_blank" href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html">AWS documentation</a> to get up to speed. You will also need to gather the IDs for your <a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/security-groups.html">security group</a> and <a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html">subnet</a> and the name of your <a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html">key pair</a>.</p>
<p>Once you have completed the necessary preparations, run the provided script. This will launch a g5g.4xlarge instance pre-loaded with user data, which initiates the installation process upon launch. The entire setup process should take approximately an hour to complete. However, you can monitor the progress as it goes. To begin, SSH into your newly launched instance.</p>
<pre><code class="lang-bash">ssh -i <span class="hljs-string">"your-key-pair.pem"</span> ec2-user@your-instance-ip
</code></pre>
<p>Then, run the following command to monitor the installation in real-time:</p>
<pre><code class="lang-bash">tail -f /home/ec2-user/install.log
</code></pre>
<p>Complete script can be downloaded from <a target="_blank" href="https://gist.github.com/bilalmughal/0500f27454a508bd3552fcf03e3adadb">Github</a> and goes as follows.</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="0500f27454a508bd3552fcf03e3adadb"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/bilalmughal/0500f27454a508bd3552fcf03e3adadb" class="embed-card">https://gist.github.com/bilalmughal/0500f27454a508bd3552fcf03e3adadb</a></div><p> </p>
<p>After everything is done you should get the following greetings.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281097983/c86a4cf2-3889-421f-a6b0-de82401bdb69.png" alt /></p>
<h2 id="heading-using-aws-management-console">Using AWS Management Console</h2>
<p>You can also use AWS Management console for this process as well. All you need to to do is “Launch an instance” from ec2 console and then select the right AMI, Architecture and instance type, along with other networking and security configurations you will do for launching any other instance. Don’t forget to increase the volume size to 20 GB as well.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281100543/dbc15d5a-6099-46d6-aa28-9839bf1bcce7.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281101996/e83cfb1d-7f5b-447b-aeed-1273c1e0a140.png" alt /></p>
<p>After selecting the right AMI, architecture, instance type, storage and other options, configure your instance’s User Data by adding custom setup commands that will run during launch.<br />To add User Data, go to the ‘Advanced Details’ section during the ‘Configure Instance’ stage, input the desired text or file, and paste the script from the GitHub repository between the ‘EOF’ markers into the User Data text area.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281103445/470696bd-58d1-4059-acf7-c99c98898ab2.png" alt /></p>
<p>Remember, this User Data script is what automates your deep learning setup, so don’t skip this step!</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>And there you have it! A one-stop solution to make your deep learning setup on an Amazon EC2 Graviton2 ARM-based instance much easier. After following these steps, you can create an AMI (Amazon Machine Image) and use it for deep-learning tasks. You should also try out spot instances for your interruptible artificial intelligence inferences, as it could save you a lot on operational costs!<br />With this guide, we made configuration and setup hassle-free so you can dive straight into the work that matters most to you. If you find this script as helpful as we do, we would love to hear about the exciting projects it’s helping you accomplish. Feel free to share your success stories and any ingenious modifications you’ve made. Happy coding!</p>
<h3 id="heading-pro-tip-max-power-min-price-the-g5g-magic-equation">💡 Pro Tip: Max Power, Min Price — The G5G Magic Equation!</h3>
<p>Did you know the <code>g5g.xlarge</code>, <code>g5g.2xlarge</code>, <code>g5g.4xlarge</code> and <code>g5g.8xlarge</code> have the same GPU power? If increasing the CPU power or adding more memory doesn’t significantly improve performance for your application, you can stick with the <code>g5g.xlarge</code> to save some money!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694281105312/4ce4e239-9288-4620-8838-279ccadf749f.png" alt /></p>
<p>G5g Instance specification details.</p>
<h2 id="heading-about-the-author-and-our-journey-at-jumpshare">About the Author and Our Journey at Jumpshare</h2>
<p>I have been the part of tech industry for 18 years, serving different roles and devising different engineering solutions throughout. The ever-changing landscape of tech world and challenges it bring excites me, specially in the area of cloud computing and machine learning.</p>
<p>At <a target="_blank" href="https://jumpshare.com"><strong>Jumpshare</strong></a><strong>,</strong> where I hold the position of VP of Engineering, we have successfully turned these challenges into opportunities. We’re passionate about implementing the techniques like this to make our machine learning inference tasks more cost-effective. By leveraging the power of AWS Graviton2 and NVIDIA Tensor T4G instances, we’ve been able to drastically reduce operational costs without compromising performance.</p>
<p>This guide is yet another effort to express our commitment of sharing our experience and insights with the community as we strongly believe in democratizing technology and saving costs on infrastructure can unlock doors to innovation.</p>
<p>We’re always open to hearing about your own experiences and improvements on the journey towards cost-effective, high-performance deep learning.</p>
<p><em>This article was originally published on</em> <a target="_blank" href="https://jumpshare.com/blog/deep-learning-on-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2/"><em>Jumpshare.com</em></a></p>
<h2 id="heading-resources">Resources</h2>
<p><a target="_blank" href="https://jumpshare.com/blog/deep-learning-on-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2/">https://jumpshare.com/blog/deep-learning-on-aws-graviton2-nvidia-tensor-t4g-for-as-low-as-free-with-cuda-12-2/</a><a target="_blank" href="https://www.nvidia.com/Download/Find.aspx"><br />https://www.nvidia.com/Download/Find.aspx</a><br /><a target="_blank" href="https://developer.nvidia.com/cuda-toolkit">https://developer.nvidia.com/cuda-toolkit</a><br /><a target="_blank" href="https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/">https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/</a><br /><a target="_blank" href="https://instances.vantage.sh/?selected=g5g..x%7Cg5g.x">https://instances.vantage.sh/?selected=g5g..x|g5g.x</a><br /><a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/security-groups.html">https://docs.aws.amazon.com/vpc/latest/userguide/security-groups.html</a><br /><a target="_blank" href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html">https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html</a><br /><a target="_blank" href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html">https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html</a><br /><a target="_blank" href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html">https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html</a></p>
]]></content:encoded></item></channel></rss>