{"id":848,"date":"2026-10-06T17:04:57","date_gmt":"2026-10-06T09:04:57","guid":{"rendered":"https:\/\/cqiot.cc\/?p=848"},"modified":"2026-10-06T17:12:05","modified_gmt":"2026-10-06T09:12:05","slug":"ollama-pve-gpu-passthrough-vram","status":"publish","type":"post","link":"https:\/\/cqiot.cc\/index.php\/2026\/10\/06\/ollama-pve-gpu-passthrough-vram\/","title":{"rendered":"\u7528 Ollama \u5728 PVE \u865a\u62df\u673a\u91cc\u8dd1\u672c\u5730\u5927\u6a21\u578b\uff1a\u663e\u5361\u76f4\u901a\u4e0e\u663e\u5b58\u89c4\u5212"},"content":{"rendered":"<p><!-- cqiot:aigc explicit=visible implicit=metadata regulation=\u300a\u4eba\u5de5\u667a\u80fd\u751f\u6210\u5408\u6210\u5185\u5bb9\u6807\u8bc6\u529e\u6cd5\u300b2025-09-01 generator=ComfyUI --><\/p>\n<div class=\"cqiot-aigc-notice\" data-aigc=\"explicit\">\n<p><strong>\u5185\u5bb9\u6807\u8bc6\uff1a<\/strong>\u672c\u6587\u4e3a AI \u8f85\u52a9\u751f\u6210\u5185\u5bb9\u3002\u4f9d\u636e \u300a\u4eba\u5de5\u667a\u80fd\u751f\u6210\u5408\u6210\u5185\u5bb9\u6807\u8bc6\u529e\u6cd5\u300b2025-09-01\uff0c\u5df2\u6dfb\u52a0\u663e\u5f0f\u6807\u8bc6\uff08\u672c\u58f0\u660e\uff09\u4e0e\u9690\u5f0f\u6807\u8bc6\uff08\u6587\u4ef6\u5143\u6570\u636e \/ \u56fe\u7247 ComfyUI \u5143\u4fe1\u606f\uff09\u3002\u6587\u4e2d\u6280\u672f\u7ec6\u8282\u4e0e\u7ed3\u8bba\u5747\u7531\u4f5c\u8005\u590d\u6838\u786e\u8ba4\u3002<\/p>\n<\/div>\n<p>\u5bb6\u91cc\u6216\u673a\u623f\u91cc\u90a3\u53f0\u8dd1\u7740 PVE\uff08Proxmox VE\uff09\u7684\u670d\u52a1\u5668\uff0c\u5f80\u5f80\u8fd8\u63d2\u7740\u4e00\u5757\u5403\u7070\u7684\u663e\u5361\u3002\u4e0e\u5176\u518d\u5355\u72ec\u4e70\u4e00\u53f0 AI \u4e3b\u673a\uff0c\u4e0d\u5982\u628a\u8fd9\u5757\u5361\u76f4\u901a\u7ed9\u4e00\u53f0\u865a\u62df\u673a\uff0c\u7528 Ollama \u8dd1\u672c\u5730\u5927\u6a21\u578b\uff1a\u6570\u636e\u4e0d\u51fa\u5185\u7f51\u3001\u6a21\u578b\u968f\u6362\u968f\u7528\uff0c\u8fd8\u80fd\u548c NAS\u3001\u76d1\u63a7\u7b49\u5176\u5b83\u865a\u673a\u5171\u7528\u540c\u4e00\u53f0\u5bbf\u4e3b\u673a\u3002\u672c\u6587\u6309\u300c\u5bbf\u4e3b\u673a\u76f4\u901a \u2192 \u865a\u673a\u9a71\u52a8 \u2192 \u663e\u5b58\u89c4\u5212 \u2192 \u8dd1\u6a21\u9a8c\u6536\u300d\u56db\u6b65\u8d70\u5b8c\u6574\u4e2a\u6d41\u7a0b\uff0c\u5e76\u6807\u51fa\u6bcf\u4e2a\u5bb9\u6613\u8e29\u5751\u7684\u7248\u672c\u7ec6\u8282\u3002\u672c\u7ad9\u66f4\u591a\u672c\u5730\u5316\u90e8\u7f72\u5b9e\u8df5\u89c1 <a href=\"https:\/\/cqiot.cc\/\">cqiot.cc<\/a>\u3002<\/p>\n<p><!-- VERIFY: \u5185\u94fe\u5efa\u8bae\u66ff\u6362\u4e3a\u672c\u7ad9\u5df2\u53d1\u5e03\u7684\u76f8\u5173\u6587\u7ae0\u5177\u4f53 URL\uff0c\u800c\u975e\u9996\u9875 --><\/p>\n<h2>\u4e00\u3001\u5bbf\u4e3b\u673a\uff1a\u5f00\u542f IOMMU \u5e76\u628a\u663e\u5361\u7ed1\u7ed9 vfio<\/h2>\n<p>\u7b2c\u4e00\u6b65\u662f\u8ba9\u5bbf\u4e3b\u673a\u7684\u5185\u6838\u628a\u663e\u5361\u300c\u8ba9\u51fa\u6765\u300d\u3002\u7f16\u8f91 GRUB \u914d\u7f6e\u5f00\u542f IOMMU\uff1a<\/p>\n<pre><code class=\"language-bash\"># Intel \u5e73\u53f0\nGRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet intel_iommu=on iommu=pt&quot;\n# AMD \u5e73\u53f0\u6539\u4e3a amd_iommu=on iommu=pt<\/code><\/pre>\n<p><!-- VERIFY: \u9700\u6309\u5b9e\u9645 CPU \u5e73\u53f0\u4e8c\u9009\u4e00\uff1bPVE \u7248\u672c\u4e0d\u540c\uff0ciommu=pt \u662f\u5426\u4e3a\u9ed8\u8ba4\u5efa\u8bae\u503c\u8bf7\u4ee5\u5f53\u524d PVE \u5b98\u65b9\u6587\u6863\u4e3a\u51c6 --><\/p>\n<p>\u6539\u5b8c\u540e\u5237\u65b0\u5f15\u5bfc\u914d\u7f6e\u3002\u6ce8\u610f PVE \u6709\u4e24\u79cd\u5f15\u5bfc\u65b9\u5f0f\uff0c\u547d\u4ee4\u4e0d\u540c\uff1a<\/p>\n<pre><code class=\"language-bash\">update-grub                 # \u4f20\u7edf GRUB \u5f15\u5bfc\nproxmox-boot-tool refresh   # systemd-boot\uff08EFI\uff09\u5f15\u5bfc\u7528\u8fd9\u4e2a<\/code><\/pre>\n<p><!-- VERIFY: \u4e24\u6761\u547d\u4ee4\u4e8c\u9009\u4e00\uff0c\u53d6\u51b3\u4e8e\u8be5 PVE \u5b89\u88c5\u65f6\u7684\u5f15\u5bfc\u65b9\u5f0f\uff0c\u6267\u884c\u524d\u5148\u7528 ls \/sys\/firmware\/efi \u786e\u8ba4 --><\/p>\n<p>\u63a5\u7740\u52a0\u8f7d vfio \u76f8\u5173\u6a21\u5757\uff0c\u628a\u663e\u5361\u7684 PCI \u5730\u5740\u7ed1\u5b9a\u5230 vfio-pci\uff0c\u5e76\u5c4f\u853d\u5bbf\u4e3b\u673a\u81ea\u5df1\u7684\u663e\u5361\u9a71\u52a8\uff1a<\/p>\n<pre><code class=\"language-bash\">cat &gt;&gt; \/etc\/modules &lt;&lt;EOF\nvfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd\nEOF\n\nlspci -nn | grep -i vga     # \u8bb0\u4e0b\u663e\u5361\u5730\u5740\u4e0e\u5382\u5546:\u8bbe\u5907 ID\uff0c\u4f8b\u5982 01:00.0 [10de:1b80]\necho &quot;options vfio-pci ids=10de:1b80,10de:10f0&quot; &gt; \/etc\/modprobe.d\/vfio.conf\necho &quot;blacklist nouveau&quot;    &gt; \/etc\/modprobe.d\/blacklist-nouveau.conf\nupdate-initramfs -u -k all\nreboot<\/code><\/pre>\n<p><!-- VERIFY: PCI \u5730\u5740 01:00.0 \u4e0e\u8bbe\u5907 ID 10de:1b80\/10de:10f0 \u662f\u793a\u4f8b\uff0c\u5fc5\u987b\u6309 lspci \u5b9e\u6d4b\u503c\u66ff\u6362\uff1b\u663e\u5361\u901a\u5e38\u542b\u89c6\u9891+\u97f3\u9891\u4e24\u4e2a\u529f\u80fd\uff0c\u4e24\u4e2a ID \u90fd\u8981\u5199 --><\/p>\n<p>\u6700\u540e\u628a\u8bbe\u5907\u6302\u7ed9\u865a\u673a\uff08\u5efa\u8bae\u7528 q35 \u673a\u578b + host CPU\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\">qm set 100 --hostpci0 01:00,pcie=1<\/code><\/pre>\n<p><!-- VERIFY: 100 \u4e3a\u793a\u4f8b VMID\uff0cpcie=1 \u5728\u90e8\u5206\u8001\u7248\u672c PVE \u4e0a\u7684\u53ef\u7528\u6027\u9700\u786e\u8ba4\uff1b\u4e2a\u522b N \u5361\u8fd8\u9700\u914d romfile \u6216\u9690\u85cf\u865a\u62df\u5316\u6807\u5fd7 --><\/p>\n<h2>\u4e8c\u3001\u865a\u62df\u673a\u5185\uff1a\u9a71\u52a8\u7248\u672c\u662f\u6700\u5927\u7684\u5751<\/h2>\n<p>\u76f4\u901a\u6210\u529f\u540e\uff0c\u865a\u673a\u91cc\u7684 <code>lspci<\/code> \u5c31\u80fd\u770b\u5230\u663e\u5361\u4e86\u3002\u88c5\u9a71\u52a8\u524d\u5148\u786e\u8ba4\u4e00\u4ef6\u4e8b\uff1a<strong>\u4f60\u7684\u5361\u8fd8\u53d7\u54ea\u4e2a\u9a71\u52a8\u5206\u652f\u652f\u6301<\/strong>\u3002NVIDIA \u7684 590\/595 \u7cfb\u5217\u9a71\u52a8\u5df2\u79fb\u9664 Maxwell\/Pascal\/Volta \u67b6\u6784\uff0c\u8fd9\u610f\u5473\u7740 Tesla P4\/P40\/P100\u3001GTX 10 \u7cfb\u8fd9\u7c7b\u8001\u5361\u5fc5\u987b\u9501\u5b9a R580 \u5206\u652f\uff1a<\/p>\n<pre><code class=\"language-bash\">apt-get install -y nvidia-driver-580-server<\/code><\/pre>\n<p><!-- VERIFY: \u300cR580 \u662f\u6700\u540e\u652f\u6301 Pascal \u7684\u5206\u652f\u300d\u4ee5 NVIDIA \u5b98\u65b9 CUDA Toolkit\/Driver \u67b6\u6784\u77e9\u9635\u9875\u4e3a\u51c6\uff0c\u65b0\u578b\u53f7\u663e\u5361\u5e94\u76f4\u63a5\u88c5\u6700\u65b0\u5206\u652f\uff1b580-server \u5305\u540d\u6309\u6240\u7528 Ubuntu \u7248\u672c\u7684\u4ed3\u5e93\u5b9e\u9645\u63d0\u4f9b\u60c5\u51b5\u786e\u8ba4 --><\/p>\n<p>\u88c5\u5b8c\u91cd\u542f\u540e\u56db\u9879\u9a8c\u8bc1\u7f3a\u4e00\u4e0d\u53ef\uff1a\u80fd\u770b\u5230 <code>nvidia-smi<\/code> \u8f93\u51fa\u5361\u540d\u548c\u663e\u5b58\u3001<code>lsmod | grep nouveau<\/code> \u4e3a\u7a7a\u3001<code>ls \/dev\/nvidia*<\/code> \u5b58\u5728\u8bbe\u5907\u8282\u70b9\u3001\u4e14\u540e\u7eed <code>apt upgrade<\/code> \u4e0d\u4f1a\u628a\u9a71\u52a8\u5077\u5077\u5347\u5230 590\u3002\u6700\u540e\u4e00\u9879\u5efa\u8bae\u7528 apt pin \u628a 59x \u7cfb\u5217\u5305\u8bbe\u4e3a\u4e0d\u53ef\u5b89\u88c5\uff0c\u8fd9\u662f\u8001\u5361\u673a\u5668\u6700\u5bb9\u6613\u88ab\u5ffd\u89c6\u3001\u4e5f\u6700\u5bb9\u6613\u300c\u8fc7\u4e24\u4e2a\u6708\u7a81\u7136\u6302\u6389\u300d\u7684\u9690\u60a3\u3002<\/p>\n<h2>\u4e09\u3001\u663e\u5b58\u89c4\u5212\uff1a\u5148\u7b97\u8d26\uff0c\u518d\u4e0b\u6a21\u578b<\/h2>\n<p>Ollama \u52a0\u8f7d\u7684\u662f\u91cf\u5316\u6a21\u578b\uff0c\u663e\u5b58\u5360\u7528 \u2248 \u6743\u91cd\u4f53\u79ef + KV cache + \u5c11\u91cf\u8fd0\u884c\u65f6\u5f00\u9500\u3002\u6309 Q4 \u91cf\u5316\u7684\u7ecf\u9a8c\u503c\u7c97\u7b97\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6a21\u578b\u89c4\u6a21<\/th>\n<th>\u6743\u91cd\u5927\u7ea6\u5360\u7528<\/th>\n<th>8 GB \u5361<\/th>\n<th>16 GB \u5361<\/th>\n<th>24 GB \u5361<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>7B~8B<\/td>\n<td>4.5~5.5 GB<\/td>\n<td>\u5bbd\u88d5<\/td>\n<td>\u5bbd\u88d5<\/td>\n<td>\u5bbd\u88d5<\/td>\n<\/tr>\n<tr>\n<td>13B~14B<\/td>\n<td>8~9.5 GB<\/td>\n<td>\u52c9\u5f3a\/\u4e0d\u591f<\/td>\n<td>\u5bbd\u88d5<\/td>\n<td>\u5bbd\u88d5<\/td>\n<\/tr>\n<tr>\n<td>32B<\/td>\n<td>18~20 GB<\/td>\n<td>\u4e0d\u591f<\/td>\n<td>\u4e0d\u591f<\/td>\n<td>\u53ef\u4ee5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!-- VERIFY: \u8868\u4e2d\u4e3a Q4_K_M \u91cf\u7ea7\u7684\u7ecf\u9a8c\u4f30\u7b97\uff0c\u5177\u4f53\u5230\u67d0\u4e2a\u6a21\u578b\u7684\u771f\u5b9e\u4f53\u79ef\u5e94\u5728\u4e0b\u8f7d\u524d\u7528 Range \u8bf7\u6c42\u8bfb\u53d6 Content-Range \u6838\u5b9e\uff0c\u4e0d\u8981\u51ed\u4f30\u7b97\u4e0b\u5355 --><\/p>\n<p>\u4e24\u4e2a\u7acb\u7aff\u89c1\u5f71\u7684\u7701\u663e\u5b58\/\u6269\u5bb9\u6280\u5de7\uff0c\u901a\u8fc7 systemd \u8986\u5199\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-ini\">[Service]\nEnvironment=&quot;OLLAMA_HOST=0.0.0.0:11434&quot;\nEnvironment=&quot;OLLAMA_CONTEXT_LENGTH=8192&quot;\nEnvironment=&quot;OLLAMA_KV_CACHE_TYPE=q8_0&quot;<\/code><\/pre>\n<p><!-- VERIFY: \u4ee5\u4e0a\u73af\u5883\u53d8\u91cf\u540d\u4ee5\u5f53\u524d Ollama \u7248\u672c\u6587\u6863\u4e3a\u51c6\uff1bOLLAMA_HOST=0.0.0.0 \u65e0\u9274\u6743\uff0c\u4ec5\u9650\u5185\u7f51\u4f7f\u7528\uff0c\u516c\u7f51\u73af\u5883\u52a1\u5fc5\u52a0\u53cd\u4ee3\u9274\u6743 --><\/p>\n<p><code>OLLAMA_KV_CACHE_TYPE=q8_0<\/code> \u5b9e\u6d4b\u80fd\u8ba9\u540c\u6837\u663e\u5b58\u4e0b\u7684\u53ef\u7528\u4e0a\u4e0b\u6587\u63a5\u8fd1\u7ffb\u500d\uff08\u4f8b\u5982\u5728 8 GB \u5361\u4e0a\u628a 8B \u6a21\u578b\u4ece 8192 \u4e0a\u4e0b\u6587\u63d0\u5230 16384\uff0c\u53ea\u591a\u5360\u7ea6\u767e MB\uff09\uff0c\u662f\u4f4e\u663e\u5b58\u5361\u4e0a\u6027\u4ef7\u6bd4\u6700\u9ad8\u7684\u5f00\u5173\u3002<\/p>\n<h2>\u56db\u3001\u8dd1\u901a\u5e76\u9a8c\u6536<\/h2>\n<pre><code class=\"language-bash\">curl -fsSL https:\/\/ollama.com\/install.sh | sh\nollama pull qwen3:8b\nollama run qwen3:8b<\/code><\/pre>\n<p><!-- VERIFY: \u5b89\u88c5\u811a\u672c\u5730\u5740\u4ee5 ollama.com \u5b98\u7f51\u5f53\u524d\u6307\u5f15\u4e3a\u51c6\uff1bqwen3:8b \u4ec5\u662f\u793a\u4f8b\u6a21\u578b\uff0c\u53ef\u6309\u7b2c\u4e09\u8282\u7684\u663e\u5b58\u8d26\u6362\u6210\u672c\u673a\u88c5\u5f97\u4e0b\u7684\u578b\u53f7 --><\/p>\n<p>\u9a8c\u6536\u770b\u4e09\u70b9\uff1a<code>ollama ps<\/code> \u7684 PROCESSOR \u5217\u5fc5\u987b\u663e\u793a\u300c100% GPU\u300d\u800c\u4e0d\u662f CPU\uff1b\u63a8\u7406\u65f6 <code>nvidia-smi<\/code> \u80fd\u770b\u5230\u663e\u5b58\u5360\u7528\u4e0e\u7b97\u529b\u5229\u7528\u7387\uff1b\u7528\u4e2d\u82f1\u6587\u5404\u95ee\u4e00\u6b21\uff0c\u786e\u8ba4\u4e2d\u6587\u8f93\u51fa\u4e0d\u4e71\u7801\uff08\u5982\u679c\u4e2d\u6587\u8f93\u51fa\u5f02\u5e38\uff0c\u5148\u6000\u7591\u7ec8\u7aef\u7f16\u7801\uff0c\u800c\u4e0d\u662f\u6a21\u578b\u574f\u4e86\uff09\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u6574\u6761\u94fe\u8def\u5176\u5b9e\u53ea\u6709\u4e09\u4e2a\u771f\u6b63\u7684\u98ce\u9669\u70b9\uff1a\u5bbf\u4e3b\u673a\u7684 IOMMU\/vfio \u7ed1\u5b9a\uff08\u6539\u9519\u5f15\u5bfc\u914d\u7f6e\u4f1a\u8d77\u4e0d\u6765\uff09\u3001\u865a\u673a\u91cc\u7684\u9a71\u52a8\u5206\u652f\u9009\u62e9\uff08\u8001\u5361\u88c5\u65b0\u5206\u652f\u76f4\u63a5\u9ed1\u5c4f\uff09\u3001\u4ee5\u53ca\u663e\u5b58\u89c4\u5212\uff08\u62cd\u8111\u888b\u4e0b\u6a21\u578b\u4f1a\u53cd\u590d\u91cd\u4e0b\uff09\u3002\u628a\u8fd9\u4e09\u5904\u6309\u672c\u6587\u7684\u547d\u4ee4\u9010\u9879\u6838\u5bf9\u3001\u5e76\u6309 <code>VERIFY<\/code> \u6807\u8bb0\u66ff\u6362\u6210\u81ea\u5df1\u673a\u5668\u7684\u5b9e\u6d4b\u503c\uff0c\u4e00\u5757\u5403\u7070\u7684\u663e\u5361\u5c31\u80fd\u53d8\u6210\u5168\u5bb6\u53ef\u7528\u7684\u672c\u5730\u5927\u6a21\u578b\u670d\u52a1\u3002\u4e0b\u4e00\u7bc7\u6211\u4eec\u8bb2\u5982\u4f55\u5728\u8fd9\u53f0\u865a\u673a\u4e0a\u7ed9 Ollama \u5957\u4e00\u5c42 OpenAI \u517c\u5bb9\u7f51\u5173\uff0c\u4f9b\u591a\u4e2a\u5e94\u7528\u5171\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 PVE \u4e0a\u7ed9\u865a\u62df\u673a\u76f4\u901a\u4e00\u5757\u663e\u5361\u7684\u5b8c\u6574\u6d41\u7a0b\uff1aIOMMU \u5f00\u542f\u3001vfio \u7ed1\u5b9a\u3001\u9a71\u52a8\u5206\u652f\u907f\u5751\uff0c\u518d\u6309\u663e\u5b58\u5bb9\u91cf\u89c4\u5212 7B~32B \u91cf\u5316\u6a21\u578b\u4e0e KV cache\uff0c\u6700\u540e\u7528 Ollama \u8dd1\u901a\u9a8c\u6536\u3002<\/p>\n","protected":false},"author":1,"featured_media":931,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[46],"tags":[52,50,51],"class_list":["post-848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-local-ai","tag-ai","tag-ollama","tag-pve"],"_links":{"self":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":2,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":851,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts\/848\/revisions\/851"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/media\/931"}],"wp:attachment":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}