<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ cuda - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ cuda - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 25 May 2026 05:05:53 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/cuda/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ CUDA Programming for NVIDIA H100s ]]>
                </title>
                <description>
                    <![CDATA[ Learn CUDA programming for NVIDIA Hopper GPUs. We just posted a course on the freeCodeCamp.org YouTube channel that will teach you to build efficient WGMMA pipelines and leverage Cutlass optimizations ]]>
                </description>
                <link>https://www.freecodecamp.org/news/cuda-programming-for-nvidia-h100s/</link>
                <guid isPermaLink="false">69d82bc1fa7251682e0ee64c</guid>
                
                    <category>
                        <![CDATA[ cuda ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Thu, 09 Apr 2026 22:44:17 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/uploads/covers/5f68e7df6dfc523d0a894e7c/ea6ca08d-00f6-43c6-88b1-536d7319982f.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Learn CUDA programming for NVIDIA Hopper GPUs.</p>
<p>We just posted a course on the <a href="http://freeCodeCamp.org">freeCodeCamp.org</a> YouTube channel that will teach you to build efficient WGMMA pipelines and leverage Cutlass optimizations to perform the massive matrix multiplications that power modern AI.</p>
<p>Beyond single-chip performance, the curriculum covers multi-GPU scaling and NCCL primitives necessary for training trillion-parameter models. To get the most out of these lessons, you should have a foundational grasp of C++ syntax and linear algebra, particularly how matrices are tiled and multiplied.</p>
<p>Here are all the sections in this massive course:</p>
<ul>
<li><p>Course Introduction</p>
</li>
<li><p>Table of Contents &amp; Course Overview</p>
</li>
<li><p>LESSON 1 — H100 Hopper GPU Architecture</p>
</li>
<li><p>H100 Specifications: HBM3, Bandwidth &amp; Power</p>
</li>
<li><p>Tensor Cores Overview</p>
</li>
<li><p>Tensor Memory Accelerator (TMA)</p>
</li>
<li><p>Transformer Engine</p>
</li>
<li><p>L2 Cache Architecture</p>
</li>
<li><p>GPCs, TPCs &amp; SM Layout</p>
</li>
<li><p>Thread Block Clusters</p>
</li>
<li><p>Distributed Shared Memory</p>
</li>
<li><p>SM Sub-Partitions (SMSPs)</p>
</li>
<li><p>Warp Schedulers &amp; Dispatch Units</p>
</li>
<li><p>Shared Memory &amp; Data Movement</p>
</li>
<li><p>Occupancy</p>
</li>
<li><p>LESSON 2 — Clusters, Data Types, Inline PTX &amp; Pointers</p>
</li>
<li><p>Thread Block Clusters Programming</p>
</li>
<li><p>Configuring Cluster Dimensions</p>
</li>
<li><p>Inline PTX Assembly</p>
</li>
<li><p>State Spaces</p>
</li>
<li><p>Data Types in PTX</p>
</li>
<li><p>Generic Pointers</p>
</li>
<li><p>Address Space Conversion</p>
</li>
<li><p>LESSON 3 — Asynchronicity &amp; Barriers</p>
</li>
<li><p>Introduction to Async Operations</p>
</li>
<li><p>Proxies</p>
</li>
<li><p>Fences &amp; Memory Ordering</p>
</li>
<li><p>Fence Ordering &amp; Visibility</p>
</li>
<li><p>Fence Scopes</p>
</li>
<li><p>Acquire &amp; Release Fences</p>
</li>
<li><p>Expected Count &amp; Thread Arrival</p>
</li>
<li><p>M-Barrier Arrive Operations</p>
</li>
<li><p>M-Barrier PTX Instructions</p>
</li>
<li><p>Barrier Wait Operations</p>
</li>
<li><p>Phase &amp; Parity</p>
</li>
<li><p>Commit Operations</p>
</li>
<li><p>LESSON 4 — CuTensorMap Descriptors</p>
</li>
<li><p>Tensor Shape, Stride &amp; Data Type</p>
</li>
<li><p>Element Stride &amp; Dimensions</p>
</li>
<li><p>Box Dimensions (Tile Size)</p>
</li>
<li><p>Bank Conflicts</p>
</li>
<li><p>Swizzling</p>
</li>
<li><p>Swizzle Formula Deep Dive</p>
</li>
<li><p>Interleave Layouts</p>
</li>
<li><p>Out-of-Bounds Fill (OOB)</p>
</li>
<li><p>LESSON 5 — cp.async.bulk (Async Bulk Copies via TMA)</p>
</li>
<li><p>Bulk Tensor Operations (1D–5D)</p>
</li>
<li><p>Multicast Operations</p>
</li>
<li><p>Prefetch</p>
</li>
<li><p>LESSON 6 — WGMMA Part 1 (Warp Group Matrix Multiply Accumulate)</p>
</li>
<li><p>Warp Groups &amp; Matrix Multiplication</p>
</li>
<li><p>WGMMA Descriptors</p>
</li>
<li><p>Accumulators &amp; Register Reuse</p>
</li>
<li><p>Scale Factors (Scale D, Scale A, Scale B)</p>
</li>
<li><p>Core Matrices &amp; 16×16 Tiles</p>
</li>
<li><p>LESSON 7 — WGMMA Part 2</p>
</li>
<li><p>Commit Groups &amp; Wait Groups</p>
</li>
<li><p>WGMMA with FP8 Data Types</p>
</li>
<li><p>LESSON 8 — Kernel Design</p>
</li>
<li><p>Compute-Bound vs. Memory-Bound Kernels</p>
</li>
<li><p>Warp Specialization</p>
</li>
<li><p>Cooperative vs. Ping-Pong Pipelines</p>
</li>
<li><p>Pipelining Fundamentals</p>
</li>
<li><p>Circular Buffering</p>
</li>
<li><p>Ping-Pong Pipeline Deep Dive</p>
</li>
<li><p>Epilogue Handling in Pipelines</p>
</li>
<li><p>Persistent Scheduling</p>
</li>
<li><p>Split-K &amp; Stream-K Strategies</p>
</li>
<li><p>Data-Parallel Tile Scheduling</p>
</li>
<li><p>Epilogue Fusion (Bias, Activation, Scaling)</p>
</li>
<li><p>Epilogue Operations Overview</p>
</li>
<li><p>CUTLASS SOURCE CODE WALKTHROUGH</p>
</li>
<li><p>Main Loop &amp; Scheduling Policies</p>
</li>
<li><p>Dispatch Policy</p>
</li>
<li><p>SM90 Tile Scheduler</p>
</li>
<li><p>SM90 Epilogue (TMA Warp Specialized)</p>
</li>
<li><p>SM90 Builder</p>
</li>
<li><p>Collective Builder</p>
</li>
<li><p>FAST.CU KERNEL WALKTHROUGH</p>
</li>
<li><p>Main Loop Implementation</p>
</li>
<li><p>Producer Warp Group (Dependence Wall)</p>
</li>
<li><p>Consumer Warp Group</p>
</li>
<li><p>Prologue</p>
</li>
<li><p>MULTI-GPU PROGRAMMING — Part 1</p>
</li>
<li><p>NVSwitch</p>
</li>
<li><p>Topology &amp; System Architecture</p>
</li>
<li><p>NVSwitch, BlueField DPUs &amp; Storage Fabrics</p>
</li>
<li><p>CUDA Peer-to-Peer Communication</p>
</li>
<li><p>MPI (Message Passing Interface)</p>
</li>
<li><p>P2P Limitations &amp; Trade-offs</p>
</li>
<li><p>MULTI-GPU PROGRAMMING — Part 2</p>
</li>
<li><p>SLURM Resource Allocation</p>
</li>
<li><p>PMIx Process Management</p>
</li>
<li><p>NCCL (NVIDIA Collective Communications Library)</p>
</li>
<li><p>NCCL Internals &amp; Ring Algorithm</p>
</li>
<li><p>AllReduce Operations</p>
</li>
<li><p>NCCL Collectives: Broadcast, AllGather, ReduceScatter</p>
</li>
<li><p>Parallelism Strategies: Data, Tensor, Pipeline &amp; Expert Parallelism</p>
</li>
<li><p>Course Conclusion &amp; Next Steps</p>
</li>
</ul>
<p>Watch the course on <a href="https://youtu.be/SqQUQHdYWyc">the freeCodeCamp.org YouTube channel</a> (24-hour watch).</p>
<div class="embed-wrapper"><iframe width="560" height="315" src="https://www.youtube.com/embed/SqQUQHdYWyc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Set Up CUDA and WSL2 for Windows 11 (including PyTorch and TensorFlow GPU) ]]>
                </title>
                <description>
                    <![CDATA[ If you’re working on complex Machine Learning projects, you’ll need a good Graphics Processing Unit (or GPU) to power everything. And Nvidia is a popular option these days, as it has great compatibility and widespread support. If you’re new to Machin... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-set-up-cuda-and-wsl2-for-windows-11-including-pytorch-and-tensorflow-gpu/</link>
                <guid isPermaLink="false">69309b9e8c594b8177306456</guid>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Windows ]]>
                    </category>
                
                    <category>
                        <![CDATA[ WSL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GPU ]]>
                    </category>
                
                    <category>
                        <![CDATA[ cuda ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Deep Learning ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Md. Fahim Bin Amin ]]>
                </dc:creator>
                <pubDate>Wed, 03 Dec 2025 20:20:46 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1764786287487/f0c28401-ce77-4873-b238-59fc6b737ce7.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you’re working on complex Machine Learning projects, you’ll need a good Graphics Processing Unit (or GPU) to power everything. And Nvidia is a popular option these days, as it has great compatibility and widespread support.</p>
<p>If you’re new to Machine Learning and are just getting started, then a free <a target="_blank" href="https://www.kaggle.com/">Kaggle</a> or <a target="_blank" href="https://colab.research.google.com/">Colab</a> might be enough for you. But that won’t be the case when you want to go deeper. You’ll need a GPU, which can get costly if you’re continuously using it on the cloud.</p>
<p>But there’s some good news: you can utilize your computer’s Nvidia GPU (GTX/RTX) quite easily and perform machine learning-related tasks right on your local machine. The cool thing is, it won’t cost you anything other than the electricity it uses!</p>
<p>When you’re running Machine Learning models on your local machines, the most suitable operating system is a Linux-based one, like Ubuntu. But Windows has improved a lot for this purpose. If you’re using the latest Windows 11, you can leverage Windows Subsystem for Linux (WSL) and use your GPU directly for Machine Learning-related workflows.</p>
<p>This process can be quite tricky, though, as can making two popular Machine Learning frameworks, TensorFlow and PyTorch, compatible with your system GPU in Windows 11. That’s why I have written this comprehensive guide to ease your pain.</p>
<p>In it, I’ll help you set up CUDA on Windows Subsystem for Linux 2 (WSL2) so you can leverage your Nvidia GPU for machine learning tasks.</p>
<p>By following these steps, you’ll be able to run ML frameworks like TensorFlow and PyTorch with GPU acceleration on Windows 11.</p>
<p>Keep in mind that this guide assumes you have a compatible Nvidia GPU. Make sure to check <a target="_blank" href="https://developer.nvidia.com/cuda-gpus">Nvidia's official compatibility list</a> before proceeding.</p>
<p>I have also prepared a video for you that’ll help you follow proper guidelines throughout this article.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/qOJ49nkU4rY" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p> </p>
<p>Also, if this tutorial helps you, then don’t forget to add a star to the GitHub repository <a target="_blank" href="https://github.com/FahimFBA/CUDA-WSL2-Ubuntu-v2">CUDA-WSL2-Ubuntu-v2</a>. If you face any issues or have any suggestions/improvements, then please raise an issue in the GitHub repository. Currently, the live website is available at <a target="_blank" href="https://ml-win11-v2.fahimbinamin.com/">ml-win11-v2.fahimbinamin.com</a>.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-windows-terminal">Windows Terminal</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-windows-powershell-latest-amp-greatest">Windows PowerShell (Latest &amp; Greatest)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-configure-windows-terminal">Configure Windows Terminal</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-configuration-of-my-computer">Configuration of my computer</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-cpu-virtualization">CPU Virtualization</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-install-wsl2">Install WSL2</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-install-latest-lts-ubuntu-via-wsl2">Install Latest LTS Ubuntu via WSL2</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-update-amp-upgrade-ubuntu-packages">Update &amp; Upgrade Ubuntu Packages</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-install-and-configure-miniconda">Install and Configure Miniconda</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-install-jupyter-amp-ipykernel">Install Jupyter &amp; Ipykernel</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-nvidia-driver">Nvidia Driver</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-install-cuda-dependencies">Install CUDA dependencies</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-cuda-toolkit">CUDA Toolkit</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-add-path-to-shell-profile-for-cuda">Add Path to Shell Profile for CUDA</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-nvcc-version">nvcc Version</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-cudnn-sdk">cuDNN SDK</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-tensorflow-gpu">TensorFlow GPU</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-check-tensorflow-gpu">Check TensorFlow GPU</a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-pytorch-gpu">PyTorch GPU</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-check-pytorch-gpu">Check PyTorch GPU</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-check-pytorch-amp-tensorflow-gpu-inside-jupyter-notebook">Check PyTorch &amp; TensorFlow GPU inside Jupyter Notebook</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you begin, make sure you have the following requirements met:</p>
<ul>
<li><p>Windows 11 operating system</p>
</li>
<li><p>Nvidia GPU (GTX/RTX series)</p>
</li>
<li><p>Administrator access to your PC</p>
</li>
<li><p>At least 30 GB of free disk space</p>
</li>
<li><p>Internet connection for downloads</p>
</li>
<li><p>Latest Nvidia drivers installed</p>
</li>
</ul>
<h2 id="heading-windows-terminal">Windows Terminal</h2>
<p>First, you’ll need to ensure that you have Windows Terminal installed properly in your operating system. It is the newest terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. You can download it from the <a target="_blank" href="https://apps.microsoft.com/detail/9N0DX20HK701?hl=en-us&amp;gl=BD&amp;ocid=pdpshare">Microsoft Store</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094104150/c73ae561-6888-4eea-9419-186c6659a62f.png" alt="Preview of Windows Terminal on Windows 11" class="image--center mx-auto" width="1133" height="641" loading="lazy"></p>
<p>After ensuring that it’s installed properly, you can proceed to the next steps.</p>
<h2 id="heading-windows-powershell-latest-amp-greatest">Windows PowerShell (Latest &amp; Greatest)</h2>
<p>Windows PowerShell is a modern and updated command-line shell from Microsoft. You can use some Linux specific commands directly on it. It comes with built-in command suggestions. You can download it from the <a target="_blank" href="https://github.com/PowerShell/PowerShell/releases/">official GitHub page</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094138179/78315197-f4f2-4df4-b022-37cb9e74cda2.png" alt="Preview of Windows PowerShell on GitHub" class="image--center mx-auto" width="1519" height="904" loading="lazy"></p>
<p>Download the latest x64 installer and install it. After ensuring that it is installed properly, you can proceed to the next steps.</p>
<h2 id="heading-configure-windows-terminal">Configure Windows Terminal</h2>
<p>Now you’ll need to configure your Windows Terminal to use PowerShell as the default shell. It’s optional and you might skip this step. But I recommend doing it for a better experience.</p>
<p>Open Windows Terminal. Click on the down arrow icon in the title bar and select "Settings".</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094162440/6ea767c8-da3b-4280-84f8-0eb2b0647a46.png" alt="Preview of Windows PowerShell settings window" class="image--center mx-auto" width="1166" height="660" loading="lazy"></p>
<p>In the Settings tab, under "Startup", find the "Default profile" dropdown menu. Select "PowerShell" from the list.</p>
<p>Now for the "Default terminal application", select "Windows Terminal".</p>
<p>By default, Windows PowerShell always shows the version number in the title bar. If you want to disable it, select the "PowerShell" profile from the left sidebar. Click on the "Command Line" field and add an <code>--nologo</code> argument at the end of the command. After this, the line becomes <code>"C:\Program Files\PowerShell\7\pwsh.exe" --nologo</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094185648/3641d5f0-ba34-44b9-8a63-86b53068d02e.png" alt="Preview of Windows PowerShell --nologo setting" class="image--center mx-auto" width="1170" height="654" loading="lazy"></p>
<p>If you don’t use other shells frequently and want to hide them in the dropdown, then you’ll need to select those profiles one by one from the left sidebar. Scroll down to the bottom and find the "Hide profile from dropdown" toggle and enable it. It will hide that specific shell from the dropdown menu.</p>
<p>For example, I am hiding the <strong>Azure Cloud Shell</strong> profile as I don't use it frequently:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094214632/73add1b7-bcdd-4368-86a6-975fa2f72b54.png" alt="Preview of hiding profiles in Windows Terminal" class="image--center mx-auto" width="1151" height="657" loading="lazy"></p>
<p>Now click on the "Save" button at the bottom right corner to apply the changes. Close the Windows Terminal for now.</p>
<h2 id="heading-configuration-of-my-computer">Configuration of My Computer</h2>
<p>I figured it’d be helpful to share my current computer’s configuration so you can have a clear idea of which setup I’m using in this guide. Here are the details:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Component</strong></td><td><strong>Specification</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Processor</strong></td><td>AMD Ryzen 7 7700 8-Core Processor (8 Core 16 Threads)</td></tr>
<tr>
<td><strong>RAM</strong></td><td>64GB DDR5 6000MHz</td></tr>
<tr>
<td><strong>Storage</strong></td><td>1 TB Samsung 980 NVMe SSD, 4 TB HDD, 2 TB SATA SSD</td></tr>
<tr>
<td><strong>GPU</strong></td><td>NVIDIA GeForce RTX 3060 12GB GDDR6</td></tr>
<tr>
<td><strong>Operating System</strong></td><td>Windows 11 Pro Version 25H2</td></tr>
</tbody>
</table>
</div><p>Now that you have an idea about my computer’s configuration, we can proceed to the next steps.</p>
<h2 id="heading-cpu-virtualization">CPU Virtualization</h2>
<p>As we are going to use WSL2, we’ll need to make sure that the CPU virtualization is enabled. To check whether virtualization is enabled or not from Windows, simply open the Windows Task Manager. Go to the Performance tab and select CPU from the left sidebar. In the bottom right corner, you will see the Virtualization status. If it shows "Enabled", then you are good to go. If it shows "Disabled", then you need to enable it from the BIOS.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094252181/29efa40c-ec0a-4d99-adb7-50596348a1aa.png" alt="Preview of Virtualization enabled status in Windows Task Manager" class="image--center mx-auto" width="824" height="760" loading="lazy"></p>
<p>⚠️ You have to ensure that CPU Virtualization is enabled in your BIOS settings. Different manufacturers have different ways to access the BIOS. Usually, you can access the BIOS by pressing the Delete or F2 key during the boot process. Once in BIOS, look for settings related to "Virtualization Technology" or "Intel VT-x"/"AMD-V" and make sure it is enabled. Save the changes and exit the BIOS.</p>
<h2 id="heading-install-wsl2">Install WSL2</h2>
<p>Open the Windows Terminal or Windows PowerShell as an administrator. Run the following command to install WSL2 along with the latest Ubuntu LTS distribution:</p>
<pre><code class="lang-powershell">wsl.exe -<span class="hljs-literal">-install</span>
</code></pre>
<p>It will install Windows Subsystem for Linux 2 (WSL2). After the installation is complete, you will be prompted to restart your computer. Do so to finalize the installation.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094306994/41db30c0-ecb9-4436-a425-8a059b199c42.png" alt="Preview of WSL installation in Windows PowerShell" class="image--center mx-auto" width="1295" height="656" loading="lazy"></p>
<p>⚠️ If you encounter any issues during installation, refer to the <a target="_blank" href="https://learn.microsoft.com/en-us/windows/wsl/troubleshooting">official Microsoft documentation</a> for troubleshooting WSL installation problems.</p>
<h2 id="heading-install-latest-lts-ubuntu-via-wsl2">Install Latest LTS Ubuntu via WSL2</h2>
<p>Open the Windows Terminal or Windows PowerShell again with the administrator privileges. If you want to check the available Linux distributions to install via WSL, run the following command:</p>
<pre><code class="lang-powershell">wsl.exe -<span class="hljs-literal">-list</span> -<span class="hljs-literal">-online</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094455888/8f1f2382-41cc-410f-a7b9-a47d3bb634b6.png" alt="Preview of available WSL distributions in Windows PowerShell" class="image--center mx-auto" width="1291" height="660" loading="lazy"></p>
<p>For installing any specific distribution, run the following command:</p>
<pre><code class="lang-powershell">wsl.exe -<span class="hljs-literal">-install</span> &lt;DistroName&gt;
</code></pre>
<p>We are going to install the latest LTS Ubuntu distribution. As of now, the latest LTS version is Ubuntu 24.04. But I prefer to install the <code>Ubuntu</code> directly as it always points to the latest LTS version. So, run the following command:</p>
<pre><code class="lang-powershell">wsl.exe -<span class="hljs-literal">-install</span> Ubuntu
</code></pre>
<p>You need to give it a default user account name. For me, I am going with <code>fahim</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094505280/9beb24de-54da-4e0c-993d-b15f985867e3.png" alt="Preview of Ubuntu installation in Windows PowerShell" class="image--center mx-auto" width="1666" height="858" loading="lazy"></p>
<p>It also comes with a nice GUI management tool for WSL.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094530944/89073fb9-881f-48bd-b5ef-a0b08f74e4c5.png" alt="Preview of WSL GUI management tool" class="image--center mx-auto" width="1114" height="724" loading="lazy"></p>
<p>You can configure a lot of stuff in it including restricting core, RAM, disk space and a lot of specifications from the settings GUI window.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094551095/66aea1e1-e204-4115-80e0-b3dea2d7a2ac.png" alt="Preview of WSL GUI settings window (Memory &amp; Processor)" class="image--center mx-auto" width="1919" height="1024" loading="lazy"></p>
<h2 id="heading-update-amp-upgrade-ubuntu-packages">Update &amp; Upgrade Ubuntu Packages</h2>
<p>Open your Ubuntu terminal from Windows Terminal. First, we need to update and upgrade the existing packages to their latest versions.</p>
<p>To update the Ubuntu system, simply use the following command:</p>
<pre><code class="lang-bash">sudo apt update -y
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094594281/be41e056-7e55-4139-b84b-6b7921a2d435.png" alt="Preview of apt update command in Ubuntu terminal" class="image--center mx-auto" width="1649" height="888" loading="lazy"></p>
<p>To upgrade all the packages at once, simply use the following command:</p>
<pre><code class="lang-bash">sudo apt upgrade -y
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094627958/b1c17b1c-5290-470b-aafe-5b89bb03bd01.png" alt="Preview of apt upgrade command in Ubuntu terminal" class="image--center mx-auto" width="1659" height="934" loading="lazy"></p>
<p>⚠️ Make sure that you have a stable internet connection during the update and upgrade process to avoid any interruptions.</p>
<h2 id="heading-install-and-configure-miniconda">Install and Configure Miniconda</h2>
<p>In Machine Learning, we need to manage multiple environments with different package versions. Conda is a popular package and environment management system that makes it easy to create and manage isolated environments for different projects. We will install Miniconda, a minimal installer for Conda, to manage our Python environments. But if you prefer Anaconda, you can install it instead.</p>
<p>Go to the official website of Miniconda. Currently the Miniconda installer is inside Anaconda <a target="_blank" href="https://www.anaconda.com/docs/getting-started/miniconda/install">here</a>. If the official website gets updated, you can always search for "Miniconda installer" on Google to find the latest version. Also, you can create an issue in the <a target="_blank" href="https://github.com/FahimFBA/CUDA-WSL2-Ubuntu-v2/issues">official GitHub repository of this project</a> to notify me about it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094667031/7ee2c854-88b6-49ce-8c04-41bf0a052c90.png" alt="Preview of Miniconda official website" class="image--center mx-auto" width="1895" height="935" loading="lazy"></p>
<p>As we are installing it inside WSL, we have to select the macOS/Linux Installation. Then select Linux Terminal Installer and choose Linux x86 for downloading the installer.</p>
<pre><code class="lang-bash">wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
</code></pre>
<p>It will download the installer to your WSL directory. Then use the following command to install it properly:</p>
<pre><code class="lang-bash">bash ~/Miniconda3-latest-Linux-x86_64.sh
</code></pre>
<p>⚠️ Make sure that you are in the correct directory where the installer is downloaded. If you downloaded it to a different location, adjust the path accordingly. Also, replace bash with zsh or sh if you are using a different shell.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094706995/3a317eb9-0340-4a84-8826-45324c93dd2f.png" alt="Preview of Miniconda installation in WSL Ubuntu terminal" class="image--center mx-auto" width="1794" height="922" loading="lazy"></p>
<p>Make sure to choose the initialization option properly. I prefer to keep the conda env active whenever I open a new shell. Therefore, I chose "Yes".</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094727839/f3fc8902-0c37-432c-a912-a92810e89fd1.png" alt="Preview of Miniconda initialization option during installation" class="image--center mx-auto" width="1656" height="924" loading="lazy"></p>
<p>Make sure that the installation succeeds without any errors.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094754454/53dfd998-62c9-4c2a-a71e-0d33e123e027.png" alt="Preview of successful Miniconda installation in WSL Ubuntu terminal" class="image--center mx-auto" width="1652" height="914" loading="lazy"></p>
<p>For the changes to take effect, you can close and reopen the current shell. But you can also do that without closing and reopening the shell by applying the command below.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> ~/.bashrc
</code></pre>
<p>⚠️ If you’re using a different shell like zsh or fish, make sure to source the appropriate configuration file (e.g., ~/.zshrc for zsh).</p>
<h2 id="heading-install-jupyter-amp-ipykernel">Install Jupyter &amp; Ipykernel</h2>
<p>I prefer to use Jupyter Notebook for running my machine learning experiments. It provides an interactive environment for coding and data analysis. We’ll install Jupyter Notebook and Ipykernel to run Jupyter notebooks in our conda environment. We will do that in all conda environments starting with the <strong>base</strong> environment. It also helps us to keep the conda environment kernel inside Jupyter Notebook.</p>
<p>First, make sure that you are in the base conda environment. You will see (base) on the left side of the terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094812122/66ad5de8-7553-42da-b920-78d20c3bdc9a.png" alt="Preview of conda base environment in WSL Ubuntu terminal" class="image--center mx-auto" width="1917" height="1027" loading="lazy"></p>
<p>Now install Jupyter and Ipykernel both by applying the following command:</p>
<pre><code class="lang-bash">conda install jupyter ipykernel -y
</code></pre>
<p>Make sure that you accept the terms of service of Conda.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094839808/90fe3dcf-053d-4bc7-a031-22f81eb706ca.png" alt="Preview of Jupyter and Ipykernel installation in WSL Ubuntu terminal" class="image--center mx-auto" width="1659" height="927" loading="lazy"></p>
<p>Now, I will create a separate conda environment for both TensorFlow and the PyTorch GPU. You can directly install them in the base environment or in any other environment as per your preference. I am not specifying any specific Python version while creating the environment. It will automatically install the latest stable version of Python.</p>
<pre><code class="lang-bash">conda create -name ml -y
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094865498/ac9ef1f1-4494-4221-8376-5e257c4f9243.png" alt="Preview of creating a new conda environment named 'ml' in WSL Ubuntu terminal" class="image--center mx-auto" width="1659" height="925" loading="lazy"></p>
<p>To activate any specific conda environment, you have to use the following command:</p>
<pre><code class="lang-bash">conda activate &lt;conda-env-name&gt;
</code></pre>
<p>For example, if I want to activate my newly created <strong>ml</strong> environment, I will use this command:</p>
<pre><code class="lang-bash">conda activate ml
</code></pre>
<p>If you’re not sure which conda environments are installed in your system, you can check all available and installed conda environments in your system by running the following command:</p>
<pre><code class="lang-bash">conda env list
</code></pre>
<h2 id="heading-nvidia-driver">Nvidia Driver</h2>
<p>Ensure that you have the latest Nvidia drivers installed on Windows. WSL2 uses the Windows driver, so no separate driver installation is needed in Ubuntu. You can download the latest drivers from the <a target="_blank" href="https://www.nvidia.com/Download/index.aspx">official Nvidia website</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764094915617/cd9b0bfc-77a1-45f1-9dab-4349c8f489ef.png" alt="Preview of Nvidia driver download page" class="image--center mx-auto" width="1750" height="916" loading="lazy"></p>
<p>If you are just installing the latest GPU driver, then after installing the drivers, restart your computer to ensure the changes take effect. You can either use the GeForce Game Ready Driver or the NVIDIA Studio Driver. But I recommend using the Studio Driver for better stability with creative and ML applications.</p>
<h2 id="heading-install-cuda-dependencies">Install CUDA Dependencies</h2>
<p>You might face some issues if you do not have the CUDA dependencies installed properly. I recommend that you install the required dependencies before proceeding further:</p>
<pre><code class="lang-bash">sudo apt install gcc g++ build-essential
</code></pre>
<p>After installing the dependencies, you can then verify the CUDA installation if you had any issues earlier.</p>
<h2 id="heading-cuda-toolkit">CUDA Toolkit</h2>
<p>TensorFlow GPU is very picky about the CUDA version. So we need to install a specific version of CUDA Toolkit that is compatible with the TensorFlow version we are going to install.</p>
<p>To understand exactly which CUDA version is compatible with which TensorFlow version, you can check the official TensorFlow GPU support matrix <a target="_blank" href="https://www.tensorflow.org/install/pip">here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095089103/87a44961-9426-4d20-95ac-cde06961b41a.png" alt="Preview of TensorFlow GPU support in official docs" class="image--center mx-auto" width="1879" height="931" loading="lazy"></p>
<p>At the time I’m writing this article, the TensorFlow GPU documentation says that we should have CUDA Toolkit 12.3. So I will ensure that I install exactly that version. You can simply click on that version link in the official docs and it will redirect you to the official Nvidia CUDA Toolkit download page. But if the link gets updated in the future, you can always search for "Nvidia CUDA Toolkit" on Google to find the latest version.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095106589/19689d63-5ebd-4783-8da4-e3dedd277efb.png" alt="Preview of Nvidia CUDA Toolkit official website" class="image--center mx-auto" width="1620" height="925" loading="lazy"></p>
<p>As TensorFlow GPU is asking for exact Version 12.3, I will select version 12.3.0 exactly.</p>
<p>In the CUDA Toolkit download page, make sure to choose the operating system as Linux, Architecture as x86_64, Distribution as WSL-Ubuntu, Version as 2.0 and the Installer type as runfile(local).</p>
<p>⚠️ As we are using Ubuntu in our WSL2, you can also choose Ubuntu as your operating system. But I prefer to choose WSL-Ubuntu for better compatibility.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095151533/b6996611-d4ce-4e07-9c73-30bdc93dbf19.png" alt="Preview of CUDA Toolkit 12.3 download page for WSL-Ubuntu" class="image--center mx-auto" width="1311" height="898" loading="lazy"></p>
<p>After selecting those, it will give you the download commands. You have to apply them sequentially. Make sure that you <strong>don't keep the checkmark in "Kernel Objects" during installing CUDA</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095169368/c2f81594-536f-4788-b765-1aab3b040fa7.png" alt="Preview of CUDA Toolkit 12.3 download commands for WSL-Ubuntu" class="image--center mx-auto" width="1895" height="1001" loading="lazy"></p>
<p>⚠️ Make sure to copy and paste the commands one by one in your WSL Ubuntu terminal to download and install the CUDA Toolkit properly. If you face any issues related to CUDA dependency, then quickly go through the <a class="post-section-overview" href="#heading-install-cuda-dependencies">Install CUDA dependencies</a> section, where I have explained how to install the CUDA dependencies properly.</p>
<h2 id="heading-add-path-to-shell-profile-for-cuda">Add Path to Shell Profile for CUDA</h2>
<p>After installing CUDA Toolkit, we need to add the CUDA binaries to our shell profile for easy access. This will allow us to run CUDA commands from any directory in the terminal.</p>
<p>Note that, depending on the shell you are using (bash, zsh, and so on), you need to add the CUDA path to the appropriate configuration file. Make sure to replace <strong>.bashrc</strong> with <strong>.zshrc</strong> or other configuration files if you are using a different shell.</p>
<p>To add the CUDA binary path, follow the command below:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">'export PATH=/usr/local/cuda-12.3/bin:$PATH'</span> &gt;&gt; ~/.bashrc
</code></pre>
<p>You have to use the updated path where you installed it. Your terminal will show it after installing the CUDA:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095215437/15768563-c956-472e-9633-95b3dd1cb7a3.png" alt="Preview of CUDA installation path in WSL Ubuntu terminal" class="image--center mx-auto" width="1912" height="1011" loading="lazy"></p>
<p>Now, you need to add the path inside the Library path. Just use the exact path where you installed CUDA. Your terminal will list the path properly.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">'export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH'</span> &gt;&gt; ~/.bashrc
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095242744/3c708db4-d267-4043-aa11-d04d890904f9.png" alt="Preview of CUDA library path in WSL Ubuntu terminal" class="image--center mx-auto" width="1284" height="693" loading="lazy"></p>
<p>After adding those paths, you need to source the shell profile for the changes to take effect. You can do that by running the following command:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> ~/.bashrc
</code></pre>
<h2 id="heading-nvcc-version">nvcc Version</h2>
<p>NVCC stands for Nvidia CUDA Compiler. It is basically a compiler driver for the CUDA platform that allows developers to write parallel programs to run on Nvidia GPUs. As we have already installed the CUDA toolkit, we need to see whether the compiler is also properly activated. To check that, we need to verify the version.</p>
<p>Verify that CUDA is properly installed by checking the version:</p>
<pre><code class="lang-bash">nvcc --version
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095277858/2d1ded0a-01ac-4f78-9f6c-ac499d623207.png" alt="Preview of nvcc version check in WSL Ubuntu terminal" class="image--center mx-auto" width="1839" height="946" loading="lazy"></p>
<p>If the output shows the correct CUDA version, then you have successfully installed CUDA Toolkit in your WSL2 Ubuntu environment.</p>
<h2 id="heading-cudnn-sdk">cuDNN SDK</h2>
<p>The cuDNN (CUDA Deep Neural Network) SDK is a <a target="_blank" href="https://developer.nvidia.com/cudnn">GPU accelerated library of primitives for deep neural networks</a>, developed by Nvidia. It provides highly optimized building blocks for common deep learning operations, significantly speeding up the training and inference processes of AI models on Nvidia GPUs.</p>
<p>Note: Even though TensorFlow GPU suggests a specific cuDNN version, it’s often compatible with multiple versions. Because of this, I recommend downloading the latest cuDNN version that is compatible with your installed CUDA version. You can find the cuDNN download page <a target="_blank" href="https://developer.nvidia.com/cudnn-downloads">here</a>.</p>
<p>Select the Operating System as Linux, Architecture as x86_64, Distribution as Ubuntu, Version as 24.04, Installer Type as deb (local), Configuration as FULL. After selecting those, it will give you the download commands. You have to apply them sequentially.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095312370/1fca5959-f492-4160-8027-deec0674863b.png" alt="Preview of cuDNN download commands for Ubuntu 24.04" class="image--center mx-auto" width="1543" height="938" loading="lazy"></p>
<p>⚠️ Make sure to copy and paste the commands one by one in your WSL Ubuntu terminal to download and install the cuDNN SDK properly. If you face any issues related to CUDA dependency, then quickly go through the <a class="post-section-overview" href="#heading-install-cuda-dependencies">Install CUDA dependencies</a> section, where I have explained how to install the CUDA dependencies properly.</p>
<h2 id="heading-tensorflow-gpu">TensorFlow GPU</h2>
<p>Now, we are going to install TensorFlow GPU in our conda environment. Make sure that you have activated the conda environment where you want to install it. I’m going to install it in my previously created <strong>ml</strong> environment. To activate it, I’ll use the following command:</p>
<pre><code class="lang-bash">conda activate ml
</code></pre>
<p>⚠️ Make sure that you have activated the correct conda environment before installing TensorFlow GPU. You will see the environment name in the terminal prompt.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095398777/0c7d8813-eb6c-4e2e-bad9-1fc7d344d7a2.png" alt="Preview of activating 'ml' conda environment in WSL Ubuntu terminal" class="image--center mx-auto" width="1227" height="692" loading="lazy"></p>
<p>I will install ipykernel and jupyter in this new environment.</p>
<pre><code class="lang-bash">conda install jupyter ipykernel -y
</code></pre>
<p>Now, to install TensorFlow GPU, I will simply use the following command:</p>
<pre><code class="lang-bash">pip install tensorflow[and-cuda]
</code></pre>
<p>It might take a couple of minutes depending on the internet speed you have. Just have patience and wait for it to finish the installation.</p>
<h3 id="heading-check-tensorflow-gpu">Check TensorFlow GPU</h3>
<p>After installing TensorFlow GPU, we need to verify that it is working properly with GPU support. Open a Python shell in your Ubuntu terminal and run the following commands:</p>
<pre><code class="lang-bash">python3 -c <span class="hljs-string">"import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"</span>
</code></pre>
<p>If the output shows a list of available GPU devices, then TensorFlow GPU is successfully installed and working properly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095453933/ccda58fc-9ae9-4185-9c78-6196c98d8b7c.png" alt="Preview of TensorFlow GPU check in WSL Ubuntu terminal" width="1903" height="1029" loading="lazy"></p>
<h2 id="heading-pytorch-gpu">PyTorch GPU</h2>
<p>Now, we’re going to install PyTorch GPU in our conda environment. Make sure that you have activated the conda environment where you want to install it. I’m going to install it in my previously created ml environment. To activate it, I will use the following command:</p>
<pre><code class="lang-bash">conda activate ml
</code></pre>
<p>Installing PyTorch GPU is very straightforward. You can use the official PyTorch installation command generator <a target="_blank" href="https://pytorch.org/get-started/locally/">here</a>.</p>
<p>Make sure to select PyTorch Build as the latest Stable one, Your OS as Linux, Package as Pip, Language as Python. For the Compute Platform, select the CUDA version that matches your installed CUDA Toolkit. For me, it is CUDA 12.3. But, if you can not find the exact one then choose the closest. As CUDA 12.3 is not available for me now, I am choosing CUDA 12.6.</p>
<p>After selecting those, it will give you the installation command. You have to apply it in your WSL Ubuntu terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095511862/6f631369-c8db-4681-9d1c-669ad88df69d.png" alt="Preview of PyTorch installation command generator" class="image--center mx-auto" width="1618" height="911" loading="lazy"></p>
<p>It might take a couple of minutes depending on the internet speed you have. Just have patience and wait for it to finish the installation.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095532246/56232263-36ea-4043-9881-df162965c514.png" alt="Preview of PyTorch GPU installation in WSL Ubuntu terminal" class="image--center mx-auto" width="1280" height="689" loading="lazy"></p>
<h3 id="heading-check-pytorch-gpu">Check PyTorch GPU</h3>
<p>After installing PyTorch GPU, verify that it is working properly with GPU support. Open a Python shell in your Ubuntu terminal and run the following commands:</p>
<pre><code class="lang-bash">python3 - &lt;&lt; <span class="hljs-string">'EOF'</span>
import torch
<span class="hljs-built_in">print</span>(torch.cuda.is_available())
<span class="hljs-built_in">print</span>(torch.cuda.device_count())
<span class="hljs-built_in">print</span>(torch.cuda.current_device())
<span class="hljs-built_in">print</span>(torch.cuda.device(0))
<span class="hljs-built_in">print</span>(torch.cuda.get_device_name(0))
EOF
</code></pre>
<p>The output should look similar to the screenshot, showing:</p>
<ul>
<li><p><strong>True</strong>: GPU is available for PyTorch</p>
</li>
<li><p><strong>1</strong>: Number of detected CUDA devices</p>
</li>
<li><p><strong>0</strong>: Index of the current active CUDA device</p>
</li>
<li><p>A device object representation</p>
</li>
<li><p><strong>NVIDIA GeForce RTX 3060</strong> (or your GPU name)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095584921/69269152-7ea6-404b-b1ca-8534b51f2491.png" alt="Preview of PyTorch GPU check in WSL Ubuntu terminal" class="image--center mx-auto" width="1917" height="937" loading="lazy"></p>
<h3 id="heading-check-pytorch-amp-tensorflow-gpu-inside-jupyter-notebook">Check PyTorch &amp; TensorFlow GPU inside Jupyter Notebook</h3>
<p>Now that the environment is fully configured, we will verify GPU support directly inside Jupyter Notebook. This ensures both PyTorch and TensorFlow can successfully detect and use your GPU.</p>
<h4 id="heading-1-test-pytorch-gpu">1. Test PyTorch GPU</h4>
<p>Create a new Jupyter Notebook and run the following commands one by one:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> torch

print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.cuda.current_device())
print(torch.cuda.device(<span class="hljs-number">0</span>))
print(torch.cuda.get_device_name(<span class="hljs-number">0</span>))
</code></pre>
<p>If everything is configured correctly, you will see your GPU (for example <strong>NVIDIA GeForce RTX 3060</strong>) detected properly:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095624229/f94c97a0-2e44-45ad-a2a8-52f40c922482.png" alt="Preview of PyTorch GPU check inside Jupyter Notebook" class="image--center mx-auto" width="1861" height="743" loading="lazy"></p>
<h4 id="heading-2-test-tensorflow-gpu">2. Test TensorFlow GPU</h4>
<p>Next, run the following code to check whether TensorFlow detects your GPU:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

print(tf.config.list_physical_devices(<span class="hljs-string">'GPU'</span>))
</code></pre>
<p>You can also check the number of GPUs detected:</p>
<pre><code class="lang-python">print(<span class="hljs-string">"Num GPUs Available:"</span>, len(tf.config.list_physical_devices(<span class="hljs-string">'GPU'</span>)))
</code></pre>
<p>Finally, run TensorFlow’s built-in GPU validation (warnings are normal):</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-keyword">assert</span> tf.test.is_gpu_available()
<span class="hljs-keyword">assert</span> tf.test.is_built_with_cuda()
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1764095666216/f9017979-b5c9-4b86-9f60-d9aaa2fe8ac1.png" alt="TensorFlow GPU initialization and CUDA validation output" class="image--center mx-auto" width="1638" height="935" loading="lazy"></p>
<p>If TensorFlow logs show your GPU model (such as <strong>RTX 3060</strong>), then TensorFlow GPU is successfully installed and fully working inside Jupyter Notebook.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thank you so much for reading all the way through. I hope you have been able to configure your Windows 11 computer properly for running almost any kind of Machine Learning-based experiments.</p>
<p>To get more content like this, you can follow me on <a target="_blank" href="https://www.linkedin.com/in/fahimfba/">LinkedIn</a> and <a target="_blank" href="https://x.com/Fahim_FBA">X</a>. You can also check <a target="_blank" href="https://www.fahimbinamin.com/">my website</a> and follow me on <a target="_blank" href="https://github.com/FahimFBA">GitHub</a> if you are into open source and development.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn CUDA Programming ]]>
                </title>
                <description>
                    <![CDATA[ CUDA (Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by NVIDIA. It allows developers to use a CUDA-enabled graphics processing unit (GPU) for general-purpose processing,... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-cuda-programming/</link>
                <guid isPermaLink="false">66f2d5fc9b7a6b1298a0437d</guid>
                
                    <category>
                        <![CDATA[ cuda ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Tue, 24 Sep 2024 15:08:44 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1727270335728/ef2e9de3-14e5-4762-93a4-e07efb9e01ce.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>CUDA (Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by NVIDIA. It allows developers to use a CUDA-enabled graphics processing unit (GPU) for general-purpose processing, an approach known as GPGPU (General-Purpose computing on Graphics Processing Units). Learning CUDA opens up a world of possibilities in fields such as scientific computing, data analysis, and machine learning, where performance and speed are critical.</p>
<p>We just posted a 12-hour CUDA course on the freeCodeCamp.org YouTube channel. This comprehensive course, created by Elliot Arledge, is designed to equip you with the skills needed to use the power of GPUs for high-performance computing tasks. Whether you're a beginner or an experienced programmer looking to expand your skill set, this course offers valuable insights into the world of CUDA programming.</p>
<h3 id="heading-course-overview">Course Overview</h3>
<p>The CUDA programming course is structured to guide you through the everything you need to know about GPU computing. Here's a detailed breakdown of what you can expect:</p>
<p><strong>Introduction</strong></p>
<p>The course kicks off with an introduction that sets the stage for what you'll learn. It provides an overview of the importance of GPUs in modern computing and how CUDA can be a game-changer in various applications.</p>
<p><strong>Chapter 1: Deep Learning Ecosystem</strong></p>
<p>Learn about the deep learning ecosystem and understand how GPUs play a crucial role in accelerating deep learning models. This chapter provides a foundational understanding of the tools and frameworks that leverage GPU power.</p>
<p><strong>Chapter 2: CUDA Setup</strong></p>
<p>Learn how to set up your environment for CUDA programming. This chapter covers the installation and configuration of necessary software, ensuring you're ready to start coding.</p>
<p><strong>Chapter 3: C/C++ Review</strong></p>
<p>Refresh your knowledge of C/C++ programming, which is essential for writing CUDA code. This chapter revisits key concepts and syntax to prepare you for GPU programming.</p>
<p><strong>Chapter 4: Introduction to GPUs</strong></p>
<p>Gain a deeper understanding of GPU architecture and how it differs from traditional CPUs. This chapter explains the parallel processing capabilities of GPUs and their advantages in high-performance computing.</p>
<p><strong>Chapter 5: Writing Your First Kernels</strong></p>
<p>Start writing your first CUDA kernels. This chapter introduces you to the basics of CUDA programming, including syntax and structure, enabling you to execute simple parallel tasks on the GPU.</p>
<p><strong>Chapter 6: CUDA API</strong></p>
<p>Explore the CUDA API in detail. Learn how to manage memory, launch kernels, and handle errors effectively. This chapter provides the tools you need to write efficient and robust CUDA programs.</p>
<p><strong>Chapter 7: Faster Matrix Multiplication</strong></p>
<p>Discover how to optimize matrix multiplication using CUDA. This chapter demonstrates techniques to enhance performance, a critical skill for applications in scientific computing and machine learning.</p>
<p><strong>Chapter 8: Triton</strong></p>
<p>Get introduced to Triton, a language and compiler for writing custom deep learning primitives. Learn how Triton can simplify the process of developing high-performance GPU code.</p>
<p><strong>Chapter 9: PyTorch Extensions</strong></p>
<p>Learn how to extend PyTorch with custom CUDA operations. This chapter shows you how to integrate CUDA code with PyTorch, enabling you to create custom layers and operations for deep learning models.</p>
<p><strong>Chapter 10: MNIST Multi-layer Perceptron</strong></p>
<p>Apply your knowledge by building a multi-layer perceptron to classify the MNIST dataset. This hands-on project consolidates your learning and demonstrates the practical application of CUDA in deep learning.</p>
<p><strong>Chapter 11: Next Steps?</strong></p>
<p>Explore potential next steps in your CUDA programming journey. This chapter provides guidance on further resources and projects to continue your learning and development.</p>
<p><strong>Outro</strong></p>
<p>The course concludes with an outro that recaps what you've learned and encourages you to apply your new skills in real-world projects.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Whether you're looking to enhance your career prospects or simply explore the fascinating world of GPU computing, this course is an excellent starting point.</p>
<p>Watch the full course on <a target="_blank" href="https://www.youtube.com/watch?v=86FAWCzIe_4">the freeCodeCamp.org YouTube channel</a> (12-hour watch).</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/86FAWCzIe_4" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
