<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gpu on AIBussin — AI applications, systems and books</title><link>https://aibussin.com/tags/gpu/</link><description>Recent content in Gpu on AIBussin — AI applications, systems and books</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 10 Aug 2026 20:54:00 +0100</lastBuildDate><atom:link href="https://aibussin.com/tags/gpu/index.xml" rel="self" type="application/rss+xml"/><item><title>Run Cellular Automata on the GPU</title><link>https://aibussin.com/books/cellular-automata-from-first-principles/52-chapter/</link><pubDate>Mon, 10 Aug 2026 20:54:00 +0100</pubDate><guid>https://aibussin.com/books/cellular-automata-from-first-principles/52-chapter/</guid><description>&lt;p&gt;Once the update is expressed as tensor operations, moving to a GPU becomes straightforward.&lt;/p&gt;&#10;&lt;p&gt;But a GPU is not automatically faster.&lt;/p&gt;&#10;&lt;p&gt;It wins when there is enough parallel work to amortize transfer and launch overhead.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;h2 id="a-tensor-implementation-of-life"&gt;A tensor implementation of Life&lt;/h2&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; torch&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; torch.nn.functional &lt;span style="color:#66d9ef"&gt;as&lt;/span&gt; F&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;LIFE_KERNEL &lt;span style="color:#f92672"&gt;=&lt;/span&gt; torch&lt;span style="color:#f92672"&gt;.&lt;/span&gt;tensor(&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;0.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;],&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;]]&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;view(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;life_step&lt;/span&gt;(x):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; padded &lt;span style="color:#f92672"&gt;=&lt;/span&gt; F&lt;span style="color:#f92672"&gt;.&lt;/span&gt;pad(x, (&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;), mode&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;circular&amp;#34;&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; neighbors &lt;span style="color:#f92672"&gt;=&lt;/span&gt; F&lt;span style="color:#f92672"&gt;.&lt;/span&gt;conv2d(padded, LIFE_KERNEL&lt;span style="color:#f92672"&gt;.&lt;/span&gt;to(x&lt;span style="color:#f92672"&gt;.&lt;/span&gt;device))&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; alive &lt;span style="color:#f92672"&gt;=&lt;/span&gt; x &lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0.5&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; born &lt;span style="color:#f92672"&gt;=&lt;/span&gt; neighbors &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; survive &lt;span style="color:#f92672"&gt;=&lt;/span&gt; alive &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt; (neighbors &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; (born &lt;span style="color:#f92672"&gt;|&lt;/span&gt; survive)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;float()&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Two things matter here beyond the convolution. First, this is the third &lt;code&gt;life_step&lt;/code&gt; in the book (after Chapters 6 and 51) — same B3/S23 rule, new backend, bridged explicitly rather than silently redefined. Second, the padding mode is load-bearing: plain &lt;code&gt;padding=1&lt;/code&gt; zero-pads, which silently changes periodic boundaries into dead ones. Circular padding preserves the torus semantics every roll-based helper in this book assumes — verified bit-identical against the NumPy version on 20 random grids, where the zero-padded variant mismatched all 20 at the edges.&lt;/p&gt;</description></item><item><title>PyTorch Performance Debugging: CUDA OOM, Slow Training, GPU Utilization and torch.compile</title><link>https://aibussin.com/post/pytorch-zero-to-hero-09/</link><pubDate>Sat, 08 Aug 2026 13:56:00 +0100</pubDate><guid>https://aibussin.com/post/pytorch-zero-to-hero-09/</guid><description>&lt;h2 id="pytorch-zero-to-hero--step-09"&gt;PyTorch: Zero to Hero — Step 09&lt;/h2&gt;&#10;&lt;p&gt;At this point in the series, the model runs.&lt;/p&gt;&#10;&lt;p&gt;That does not mean it runs well.&lt;/p&gt;&#10;&lt;p&gt;A training loop can be correct and still waste most of the machine.&lt;/p&gt;&#10;&lt;p&gt;A model can fit in memory and still spend half its time waiting on synchronization.&lt;/p&gt;&#10;&lt;p&gt;A &lt;code&gt;torch.compile&lt;/code&gt; call can make code faster, slower, or simply move the bottleneck somewhere else.&lt;/p&gt;&#10;&lt;p&gt;A CUDA out-of-memory error can be caused by the model, the optimizer, activations, fragmentation, a leaked reference, a larger batch, a longer sequence, or an innocent-looking tensor that was kept alive by Python.&lt;/p&gt;</description></item><item><title>PyTorch DataLoader Performance: num_workers, pin_memory, Prefetching and Why Your GPU Is Waiting</title><link>https://aibussin.com/post/pytorch-zero-to-hero-05/</link><pubDate>Sat, 08 Aug 2026 13:21:00 +0100</pubDate><guid>https://aibussin.com/post/pytorch-zero-to-hero-05/</guid><description>&lt;h2 id="pytorch-zero-to-hero--step-05"&gt;PyTorch: Zero to Hero — Step 05&lt;/h2&gt;&#10;&lt;p&gt;A fast model with a slow input pipeline is still a slow training system.&lt;/p&gt;&#10;&lt;p&gt;One of the most common PyTorch performance failures looks like this:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GPU utilization: 20% → 95% → 10% → 90% → 15%&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The model is not necessarily slow.&lt;/p&gt;&#10;&lt;p&gt;The GPU may simply be waiting for the next batch.&lt;/p&gt;&#10;&lt;p&gt;This article is about finding out &lt;strong&gt;where the wait is happening&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>