<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Gvisor on Cheat Sheet</title><link>/tags/gvisor/</link><description>Recent content in Gvisor on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/gvisor/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></channel></rss>