<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ml on Cheat Sheet</title><link>/tags/ml/</link><description>Recent content in Ml on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/ml/index.xml" rel="self" type="application/rss+xml"/><item><title>Driver and Runtime</title><link>/ai-ml/gpu/driver-and-runtime/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/ai-ml/gpu/driver-and-runtime/</guid><description>&lt;h1 id="driver-and-runtime"&gt;Driver and Runtime&lt;a class="anchor" href="#driver-and-runtime"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;How the 3-layer NVIDIA GPU driver stack operates in containers and how &lt;code&gt;gVisor&lt;/code&gt; and &lt;code&gt;Kata Containers&lt;/code&gt; expose GPUs to sandboxed workloads. See &lt;a href="../../cloud-devops/kubernetes/dra/"&gt;DRA&lt;/a&gt; for how Kubernetes discovers node GPUs and allocates them to containers.&lt;/p&gt;
&lt;h2 id="3-layer-cuda-stack"&gt;3-Layer CUDA Stack&lt;a class="anchor" href="#3-layer-cuda-stack"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Running a GPU workload inside a container involves two User Space libraries and one Kernel Space module.&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th style="text-align: left"&gt;Layer&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Binary&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Location&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Required&lt;/th&gt;
 &lt;th style="text-align: left"&gt;Role&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;CUDA Runtime&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;libcudart.so&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;User Space (bundled in container image)&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Optional&lt;/td&gt;
 &lt;td style="text-align: left"&gt;High-level convenience APIs (&lt;code&gt;cudaMalloc&lt;/code&gt;, &lt;code&gt;cudaLaunchKernel&lt;/code&gt;) delegating to &lt;code&gt;libcuda.so&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;CUDA Driver&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;libcuda.so&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;User Space (mounted from host via CDI)&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Required&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Command packet assembly, PTX JIT, stream/pool management, and MMIO writes (&lt;code&gt;HAMi-core&lt;/code&gt; hook target)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;Kernel Module&lt;/td&gt;
 &lt;td style="text-align: left"&gt;&lt;code&gt;nvidia.ko&lt;/code&gt;, &lt;code&gt;nvidia-uvm.ko&lt;/code&gt;&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Kernel Space (&lt;code&gt;/dev/nvidia*&lt;/code&gt;)&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Required&lt;/td&gt;
 &lt;td style="text-align: left"&gt;Physical VRAM allocation, GPU MMU page tables, PCIe BAR/MMIO &lt;code&gt;mmap&lt;/code&gt;, and interrupt handling&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;ul&gt;
&lt;li&gt;GPU workloads can invoke &lt;code&gt;libcuda.so&lt;/code&gt; directly without linking &lt;code&gt;libcudart.so&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;libcuda.so&lt;/code&gt; and &lt;code&gt;nvidia.ko&lt;/code&gt; must match the exact same driver version.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="division-of-labor-between-nvidiako-and-libcudaso"&gt;Division of Labor Between &lt;code&gt;nvidia.ko&lt;/code&gt; and &lt;code&gt;libcuda.so&lt;/code&gt;&lt;a class="anchor" href="#division-of-labor-between-nvidiako-and-libcudaso"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;nvidia.ko&lt;/code&gt; does not sit in the middle of every command and data transfer between CPU/RAM and GPU cores/VRAM. &lt;code&gt;nvidia.ko&lt;/code&gt; establishes the initial memory mappings, after which &lt;code&gt;libcuda.so&lt;/code&gt; drives execution directly via Kernel Bypass.&lt;/p&gt;</description></item><item><title>Serving</title><link>/ai-ml/serving/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/ai-ml/serving/</guid><description>&lt;h1 id="serving"&gt;Serving&lt;a class="anchor" href="#serving"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;AI model serving can be divided into two main components: the &lt;strong&gt;Serving Engine&lt;/strong&gt; (the core execution unit) and the &lt;strong&gt;Serving Stack&lt;/strong&gt; (the orchestration and management layer).&lt;/p&gt;
&lt;h2 id="serving-engine"&gt;Serving Engine&lt;a class="anchor" href="#serving-engine"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The serving engine focuses on maximizing &lt;strong&gt;accelerator utilization&lt;/strong&gt; (GPU/TPU) within a &lt;strong&gt;single Pod or VM instance&lt;/strong&gt;. It is responsible for the actual execution of the model and manages low-level inference logic.&lt;/p&gt;
&lt;h3 id="vllm"&gt;vLLM&lt;a class="anchor" href="#vllm"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://github.com/vllm-project/vllm"&gt;vLLM&lt;/a&gt; is a high-throughput and memory-efficient serving engine for LLMs.&lt;/p&gt;</description></item></channel></rss>