<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Umar on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Umar on Medium]]></description>
        <link>https://medium.com/@mumarbakht?source=rss-fbdc36504e72------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rlHYAAS_mOoFqMTimSMr4Q@2x.jpeg</url>
            <title>Stories by Muhammad Umar on Medium</title>
            <link>https://medium.com/@mumarbakht?source=rss-fbdc36504e72------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:07:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mumarbakht/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Running PyTorch model on PYNQ-Z1: Comprehensive Walkthrough]]></title>
            <link>https://medium.com/@mumarbakht/running-pytorch-model-on-pynq-z1-comprehensive-walkthrough-8d9b8252e2a4?source=rss-fbdc36504e72------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d9b8252e2a4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fpga]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[pynq]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Muhammad Umar]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 14:40:25 GMT</pubDate>
            <atom:updated>2023-08-18T14:40:25.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*99dONqP53RDqXkefMjfGYw.jpeg" /></figure><p>In this guide, we will explore how to run PyTorch models on the PYNQ-Z1 board, a versatile FPGA-based platform. Whether you’re new to PyTorch or FPGA development, this step-by-step tutorial will help you get started with deploying your PyTorch models on real hardware.</p><h4>Prerequisites:</h4><ol><li>PYNQ-Z1 board</li><li>Computer with SSH capability</li><li>Basic knowledge of PyTorch and FPGA</li></ol><h4>Step 1: Set Up Your PYNQ-Z1 Board:</h4><p>Before we dive into running PyTorch models, let’s ensure that your setup is seamless and connected. Follow these steps to get your PYNQ-Z1 board ready:</p><ol><li><strong>Network Connection:</strong> Make sure your laptop is connected to the internet, and your PYNQ-Z1 board is connected to the same network through your router.</li><li><strong>Access via SSH: </strong>Open a Windows terminal on your laptop. Type the following command to establish an SSH connection to your PYNQ-Z1 board.</li></ol><pre>ssh xilinx@pynq</pre><p>If prompted for a password, it indicates successful connectivity between your PYNQ board and the network.</p><p>With your PYNQ-Z1 board set up and connected, you’re now ready to explore the exciting world of running PyTorch models on FPGA hardware. Let’s continue with the next steps in our journey.</p><h4>Create a Virtual Environment:</h4><ol><li>Once logged into the board, with venv installed and your PYNQ-Z1 board connected then you’ve to create a virtual environment and all necessary dependencies should be installed there:</li></ol><pre>python3 -m venv venv<br>source venv/bin/activate</pre><h4>Installing Dependencies in Virtual Environment:</h4><p>To streamline the process, I’ve taken care of the heavy lifting by gathering and organizing all the necessary dependencies for running a PyTorch model on an FPGA. Follow these simple steps to get everything you need:</p><ol><li>Installed Dependencies: I’ve diligently installed all the required dependencies within a Python virtual environment. This ensures that your environment remains clean and isolated, preventing any conflicts.</li><li>Requirements File: I’ve compiled all the dependencies into a convenient <a href="https://drive.google.com/file/d/1pIhNEg_7Mb2O5AyEc2q1jKpqWDbUwawJ/view?usp=sharing">requirements.txt</a> file. This file contains a list of packages along with their versions that are essential for our PyTorch-FPGA setup.</li><li>Effortless Installation: To make your life easier, you can install all the dependencies with a single command. Just execute the following command within your virtual environment:</li></ol><pre>pip install -r requirements.txt</pre><p>By running the aforementioned command it automatically installs all the necessary packages, ensuring that your PYNQ-Z1 board is equipped with everything it needs to seamlessly run PyTorch models on the FPGA.</p><p>By following these steps, you’ll have a fully prepared environment with all the dependencies ready to go. Now, let’s dive into the exciting part — running your PyTorch model on the PYNQ-Z1 FPGA board!</p><h4>Transfer Your Model to the Board:</h4><p>Before we can run our PyTorch model, let’s transfer the necessary files to the PYNQ-Z1 board:</p><ol><li>Using <a href="https://winscp.net/eng/download.php">WinSCP</a> or a similar tool, transfer your PyTorch <strong><em>model</em></strong> and <strong><em>detect</em></strong> file (e.g., <strong><em>model.pt, detect.py</em></strong>) to the board&#39;s home directory.</li><li>Now that we have our PYNQ-Z1 board set up and all the dependencies installed, it’s time to put your PyTorch model to the test using the <strong><em>detect.py</em></strong> script. This script allows us to evaluate the performance of your model and see its results in action.</li><li>If you’re enable to find the <strong><em>detect.py</em></strong> file then you can also write you own inference file for the trained PyTorch model evaluation.</li><li>Navigate to Your Project Directory Open a terminal and navigate to the directory where your PyTorch project is located. This is where your <strong><em>detect.py</em></strong> script should reside.</li><li>Now In the terminal, run the inference script.</li><li>Navigate to the directory containing your <strong><em>detect.py</em></strong> script.</li><li>Run the script with following command.</li></ol><pre>python detect.py # if you want to evaluate a model using detect.py file<br>python inference.py # if you want to evaluate a model using inference.py file</pre><h4>Conclusion:</h4><p>Congratulations! You’ve successfully deployed a PyTorch model on the PYNQ-Z1 board. This guide covered the essential steps, from setting up the board to running your inference script. By following these steps, you’ve gained a foundational understanding of how to run PyTorch models on FPGA hardware. As you become more comfortable with PyTorch and FPGA development, you can further explore optimization techniques and experiment with more complex models. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9b8252e2a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>