{"id":1293,"date":"2024-08-08T10:47:00","date_gmt":"2024-08-08T02:47:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1293"},"modified":"2024-08-06T13:53:15","modified_gmt":"2024-08-06T05:53:15","slug":"%e5%ae%b6%e7%94%a8%e8%ae%be%e5%a4%87%e8%bd%bb%e6%9d%be%e6%90%ad%e5%bb%ba-ai-%e9%9b%86%e7%be%a4%ef%bc%8c%e7%95%85%e8%b7%91-llama-3-1-405b","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2024\/08\/08\/%e5%ae%b6%e7%94%a8%e8%ae%be%e5%a4%87%e8%bd%bb%e6%9d%be%e6%90%ad%e5%bb%ba-ai-%e9%9b%86%e7%be%a4%ef%bc%8c%e7%95%85%e8%b7%91-llama-3-1-405b\/","title":{"rendered":"\u5bb6\u7528\u8bbe\u5907\u8f7b\u677e\u642d\u5efa AI \u96c6\u7fa4\uff0c\u7545\u8dd1 Llama 3.1 405B"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/1.png\" alt=\"\" class=\"wp-image-1241\" style=\"width:646px;height:auto\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u5982\u4f55\u5728\u5bb6\u7528\u8bbe\u5907\u4e0a\u8fd0\u884c<\/mark>\u5927\u578b\u5f00\u6e90\u8bed\u8a00\u6a21\u578b<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">Llama 3.1 405B<\/mark><\/strong>\uff0c\u9996\u5148\u6211\u4f1a\u89e3\u91ca\u6784\u5efa\u4eba\u5de5\u667a\u80fd\u96c6\u7fa4\u6765\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\u7684\u539f\u7406\uff0c\u968f\u540e\u4f1a\u6f14\u793a\u5982\u4f55\u901a\u8fc7Distributed Llama\u9879\u76ee\u652f\u6301\u5728\u591a\u4e2a\u8bbe\u5907\u4e0a\u8fd0\u884cLLM\u6a21\u578b\uff0c\u5e76\u4f1a\u9488\u5bf9\u540c\u6b65\u6570\u636e\u91cf\u8fdb\u884c\u4f18\u5316\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5728\u5f00\u6e90\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08open LLM models\uff09\u548c\u95ed\u6e90\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08closed LLM models\uff09\u4e4b\u95f4\u7684\u7ade\u8d5b\u4e2d\uff0c\u5f00\u6e90\u6a21\u578b\u7684\u6700\u5927\u4f18\u52bf\u5728\u4e8e\u60a8\u53ef\u4ee5\u5728\u672c\u5730\u8fd0\u884c\u5b83\u4eec\u3002\u60a8\u4e0d\u9700\u8981\u4f9d\u8d56\u5916\u90e8\u63d0\u4f9b\u5546\uff0c\u4e5f\u4e0d\u9700\u8981\u652f\u4ed8\u989d\u5916\u7684\u8d39\u7528\uff0c\u53ea\u9700\u627f\u62c5\u7535\u529b\u548c\u786c\u4ef6\u6210\u672c\u3002\u7136\u800c\uff0c\u968f\u7740\u6a21\u578b\u5927\u5c0f\u7684\u589e\u52a0\uff0c\u8fd9\u4e00\u4f18\u52bf\u5f00\u59cb\u51cf\u5f31\u3002\u8fd0\u884c\u9700\u8981\u5927\u91cf\u5185\u5b58\u7684\u5927\u578b\u6a21\u578b\u5e76\u4e0d\u5bb9\u6613\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u4f7f\u7528\u5f20\u91cf\u5e76\u884c\uff08Tensor Parallism\uff09\u548c\u5206\u5e03\u5f0f\u63a8\u7406\uff08distributed inference\uff09\u53ef\u80fd\u662f\u4e00\u79cd\u53ef\u884c\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001<strong>\u5f20\u91cf\u5e76\u884c\uff08Tensor Parallism\uff09<\/strong><\/h2>\n\n\n\n<p>\u5728\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLMs\uff09\u4e2d\uff0c\u5927\u591a\u6570\u8ba1\u7b97\u6d89\u53ca\u77e9\u9635\u4e58\u6cd5\uff0c\u8fd9\u5927\u7ea6\u5360\u6240\u6709\u8ba1\u7b97\u768497-98%\u3002\u77e9\u9635\u4e58\u6cd5\u5f88\u5bb9\u6613\u5728\u591a\u4e2aCPU\/GPU\u6838\u5fc3\u4e4b\u95f4\u5e76\u884c\u5316\u3002\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728\u591a\u4e2a\u8bbe\u5907\u4e0a\u6267\u884c\u76f8\u540c\u7684\u64cd\u4f5c\u3002\u8bbe\u5907\u53ef\u4ee5\u8fd9\u6837\u5206\u5272\uff0c\u6bcf\u4e2a\u8bbe\u5907\u53ea\u8ba1\u7b97\u77e9\u9635\u4e58\u6cd5\u7684\u4e00\u90e8\u5206\u3002\u5982\u679c\u4e00\u4e2a\u8bbe\u5907\u53ef\u4ee5\u5728n\u79d2\u5185\u5b8c\u6210\u77e9\u9635\u4e58\u6cd5\u8ba1\u7b97\uff0c\u90a3\u4e48\u4e24\u4e2a\u8bbe\u5907\u5e94\u8be5\u5728n\/2\u79d2\u5185\u5b8c\u6210\u8ba1\u7b97\uff01<strong>\u8fd9\u5c31\u662f\u5f20\u91cf\u5e76\u884c<\/strong>\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/2.png\" alt=\"\" class=\"wp-image-1242\"\/><figcaption class=\"wp-element-caption\"><strong>\u5f20\u91cf\u5e76\u884c\u3001\u8ba1\u7b97\u65f6\u95f4<\/strong><\/figcaption><\/figure>\n\n\n\n<p class=\"has-text-align-left\">\u8fd9\u662f\u4e0d\u662f\u542c\u8d77\u6765\u975e\u5e38\u68d2\uff0c\u4f46\u4e3b\u8981\u74f6\u9888\u662f\u540c\u6b65\u3002\u6211\u4eec\u9700\u8981\u52a0\u5feb\u4e58\u6cd5\u8fd0\u7b97\uff0c\u4f46\u5728\u67d0\u4e9b\u65f6\u5019\u9700\u8981\u540c\u6b65\u795e\u7ecf\u7f51\u7edc\u7684\u72b6\u6001\uff0c\u5f80\u5f80\u8fd9\u9700\u8981\u8f83\u957f\u65f6\u95f4\u3002\u4e13\u4e1aAI\u96c6\u7fa4\u4f7f\u7528\u5148\u8fdb\u7684\u94fe\u63a5\uff08\u5982NVLink\uff09\u5728GPU\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\uff0c\u4ee5\u5b9e\u73b0\u975e\u5e38\u9ad8\u7684\u4f20\u8f93\u901f\u5ea6\u3002\u7136\u800c\uff0c\u5bb6\u7528\u8bbe\u5907\u7684\u4ee5\u592a\u7f51\u901f\u5ea6\u8f83\u6162\u3002\u4f46\u4ee4\u4eba\u60ca\u8bb6\u7684\u662f\uff0c\u5982\u679c\u6a21\u578b\u6267\u884c\u5668\u7684\u67b6\u6784\u8bbe\u8ba1\u4e3a\u51cf\u5c11\u4f20\u8f93\u5927\u5c0f\uff0c\u5219\u540c\u6b65LLM\u6240\u9700\u7684\u6570\u636e\u91cf\u53ef\u80fd\u975e\u5e38\u4f4e\u3002\u4f8b\u5982\uff0c\u5982\u679c\u96c6\u7fa4\u75312\u4e2a\u8bbe\u5907\u7ec4\u6210\uff0c\u90a3\u4e48\u5c06Llama 3 8B\u91cf\u5316\u5230Q40\u683c\u5f0f\uff086.3 GB\uff09\u7684\u6a21\u578b\u4ec5\u9700\u8981\u6bcf\u4e2a\u6807\u8bb01 MB\u7684\u6570\u636e\u8fdb\u884c\u540c\u6b65\uff0c\u8fd9\u4e2a\u6570\u636e\u91cf\u5c06\u662f\u975e\u5e38\u3001\u975e\u5e38\u4f4e\u7684\u3002<\/p>\n\n\n\n<p>\u5728\u8fd9\u91cc\uff0c\u5f20\u91cf\u5e76\u884c\u52a0\u901f\u4e86\u63a8\u7406\uff0c\u4f46\u540c\u6b65\u5374\u62d6\u6162\u4e86\u901f\u5ea6\u3002\u8fd9\u4e24\u4e2a\u56e0\u7d20\u7684\u7ec4\u5408\u5c06\u51b3\u5b9a\u6700\u7ec8\u7684\u6027\u80fd\u3002\u5982\u679c\u60a8\u67098\u4e2a\u8bbe\u5907\uff0c\u5e76\u4e14\u53ef\u4ee5\u7528\u5feb\u901f\u94fe\u63a5\u8fde\u63a5\u5b83\u4eec\uff0c\u60a8\u5c06\u89c2\u5bdf\u5230\u663e\u8457\u7684\u52a0\u901f\uff08\u901a\u8fc7USB4\u8fdb\u884c\u540c\u6b65\u5728\u8fd9\u91cc\u770b\u8d77\u6765\u975e\u5e38\u6709\u5e0c\u671b\uff0c\u60a8\u53ef\u4ee5\u8fbe\u523010\u523020 Gbps\u7684\u901f\u5ea6\uff09\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\uff0c\u6211\u4eec\u5982\u4f55\u5728\u5bb6\u4e2d\u8fd0\u884c\u5927\u578b\u6a21\u578b\u5462\uff1f\u60a8\u9700\u8981\u4e00\u4e2a\u5b9e\u73b0\u8fd9\u4e9b\u60f3\u6cd5\u7684\u9879\u76ee\u3002\u8ba9\u6211\u4ecb\u7ecd\u4e00\u4e0b\u5206\u5e03\u5f0fLlama\u9879\u76ee\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u5206\u5e03\u5f0f Llama\uff08Distributed Llama\uff09<\/strong><\/h2>\n\n\n\n<p>\u5206\u5e03\u5f0fLlama\u662f\u4e00\u4e2a\u5141\u8bb8\u60a8\u5728\u591a\u4e2a\u8bbe\u5907\u4e0a\u8fd0\u884cLLM\u6a21\u578b\u7684\u9879\u76ee\u3002\u5b83\u4f7f\u7528\u5f20\u91cf\u5e76\u884c\uff0c\u5e76\u4e3a\u540c\u6b65\u6240\u9700\u7684\u6570\u636e\u91cf\u8fdb\u884c\u4e86\u4f18\u5316\u3002\u5206\u5e03\u5f0fLlama\u533a\u5206\u4e86\u60a8\u53ef\u4ee5\u5728\u5bb6\u7528\u8bbe\u5907\u4e0a\u8fd0\u884c\u7684\u4e24\u79cd\u7c7b\u578b\u7684\u8282\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6839\u8282\u70b9 &#8211; <\/strong>\u4f5c\u4e3a\u96c6\u7fa4\u7684\u6839\u8282\u70b9\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u8d1f\u8d23\u534f\u8c03\u96c6\u7fa4\u3002<\/li>\n\n\n\n<li><strong>\u5de5\u4f5c\u8282\u70b9 &#8211; <\/strong>\u4f5c\u4e3a\u5de5\u4f5c\u8005\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u6267\u884c\u6765\u81ea\u6839\u8282\u70b9\u7684\u6307\u4ee4\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u76ee\u524d\uff0c\u5206\u5e03\u5f0fLlama\u4ec5\u652f\u6301CPU\u63a8\u7406\uff0c\u4f46\u968f\u7740\u540e\u9762\u7684\u5347\u7ea7\u5c06\u4f1a\u652f\u6301\u66f4\u591a\u7684\u65b9\u5f0f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/3.png\" alt=\"\" class=\"wp-image-1244\"\/><figcaption class=\"wp-element-caption\"><br><strong>\u4eba\u5de5\u667a\u80fd\u96c6\u7fa4\u62d3\u6251\u7ed3\u6784\uff0c4 \u53f0\u8bbe\u5907\uff0c\u603b\u5185\u5b58 256 GB<\/strong><\/figcaption><\/figure>\n\n\n\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u7684\u5bb6\u7528\u96c6\u7fa4\u75314\u4e2a\u8bbe\u5907\u7ec4\u6210\uff0c\u60a8\u5e94\u8be5\u5728\u7b2c\u4e00\u4e2a\u8bbe\u5907\u4e0a\u8fd0\u884c\u6839\u8282\u70b9\uff0c\u5728\u5176\u4f59\u8bbe\u5907\u4e0a\u8fd0\u884c3\u4e2a\u5de5\u4f5c\u8282\u70b9\u3002\u5206\u5e03\u5f0fLlama\u5728\u6240\u6709\u8bbe\u5907\u4e4b\u95f4\u5206\u914dRAM\u4f7f\u7528\u91cf\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e00\u4e2aLLM\u6a21\u578b\u9700\u8981230 GB\u7684RAM\uff0c\u90a3\u4e48\u6bcf\u4e2a\u8282\u70b9\u5e94\u8be5\u6709230 GB \/ n \u7684RAM\u3002\u6839\u8282\u70b9\u662f\u4e2a\u4f8b\u5916\uff0c\u56e0\u4e3a\u5b83\u9700\u8981\u5728\u5185\u5b58\u4e2d\u4fdd\u7559\u4e00\u4e9b\u989d\u5916\u7684\u5c42\uff0c\u6240\u4ee5\u9700\u8981\u6bd4230 GB \/ n \u591a\u51e0\u4e2a\u767e\u5206\u70b9\u7684RAM\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/5-896x1024.png\" alt=\"\" class=\"wp-image-1249\" style=\"width:645px;height:auto\"\/><figcaption class=\"wp-element-caption\"><strong>8 x \u6811\u8393\u6d3e4B 8GB<\/strong><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">\u8ba9 Llama 3.1 405B \u8dd1\u8d77\u6765<\/mark><\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/4.png\" alt=\"\" class=\"wp-image-1248\"\/><\/figure>\n\n\n\n<p>\u4e3a\u4e86\u8fd0\u884cLlama 3.1 405B\uff0c\u6211\u4eec\u9700\u8981\u514b\u9686\u5206\u5e03\u5f0fLlama\u5b58\u50a8\u5e93\uff0c\u5e76\u5728\u60a8\u8981\u7528\u4e8e\u63a8\u7406\u7684\u6240\u6709\u8bbe\u5907\u4e0a\u6784\u5efadllama\u5e94\u7528\u7a0b\u5e8f\u3002\u9700\u8981\u4e00\u4e2a\u50cfG++\u8fd9\u6837\u7684\u7f16\u8bd1\u5668\u6216\u7c7b\u4f3c\u7684\u5de5\u5177\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>git clone https:\/\/github.com\/b4rtaz\/distributed-llama.git\nmake dllama<\/code><\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u60a8\u9700\u8981\u5c06\u6240\u6709\u8bbe\u5907\u8fde\u63a5\u5230\u540c\u4e00\u4e2a\u672c\u5730\u7f51\u7edc\u3002\u4e3a\u6b64\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u4ee5\u592a\u7f51\u4ea4\u6362\u673a\u3002\u5982\u524d\u6240\u8ff0\uff0c\u540c\u6b65\u65f6\u95f4\u662f\u4e00\u4e2a\u91cd\u8981\u56e0\u7d20\uff0c\u56e0\u6b64\u60a8\u5e94\u8be5\u4f7f\u7528\u5c3d\u53ef\u80fd\u5feb\u7684\u4ea4\u6362\u673a\u3002\u5343\u5146\u4ee5\u592a\u7f51\u662f\u6700\u4f4e\u8981\u6c42\u3002\u60a8\u8fd8\u53ef\u4ee5\u8003\u8651\u901a\u8fc7USB4\u8fde\u63a5\u8bbe\u5907\uff0c\u5e76\u521b\u5efa\u4e00\u4e2aUSB4\u7f51\u72b6\u7f51\u7edc\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u9700\u8981\u5728\u5de5\u4f5c\u8bbe\u5907\u4e0a\u8fd0\u884c\u5de5\u4f5c\u8282\u70b9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>.\/dllama worker --port 9998 --nthreads 4<\/code><\/code><\/pre>\n\n\n\n<p><strong>&#8211;nthreads <\/strong>\u53c2\u6570\u5b9a\u4e49\u4e86\u5e94\u8be5\u6709\u591a\u5c11\u4e2aCPU\u6838\u5fc3\u7528\u4e8e\u5904\u7406\u3002\u60a8\u5e94\u8be5\u5c06\u6b64\u53c2\u6570\u8bbe\u7f6e\u4e3a\u8bbe\u5907\u4e2d\u7684CPU\u6838\u5fc3\u6570\u91cf\u3002\u5982\u60a8\u6240\u89c1\uff0c\u5de5\u4f5c\u8282\u70b9\u4e0d\u9700\u8981\u6a21\u578b\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u4ec5\u5bf9\u6839\u8282\u70b9\u662f\u5fc5\u9700\u7684\u3002\u4e00\u5f00\u59cb\uff0c\u6839\u8282\u70b9\u4f1a\u5c06\u6a21\u578b\u7684\u6240\u6709\u5207\u7247\u5206\u53d1\u7ed9\u5de5\u4f5c\u8282\u70b9\u3002<\/p>\n\n\n\n<p>\u5728\u8fd0\u884c\u6839\u8282\u70b9\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5c06Llama 3 405B\u6a21\u578b\u4e0b\u8f7d\u5230\u6839\u8bbe\u5907\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5206\u5e03\u5f0fLlama\u683c\u5f0f\uff0c\u60a8\u8fd8\u9700\u8981\u51c6\u5907\u4e00\u4e9b\u5b58\u50a8\u7a7a\u95f4\u6765\u5904\u7406\u6b64\u64cd\u4f5c\uff08\u5927\u7ea6\u9700\u89811.1 TB\u7684\u53ef\u7528\u7a7a\u95f4\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>git lfs install\ngit clone https:\/\/huggingface.co\/meta-llama\/Meta-Llama-3.1-405B-Instruct<\/code><\/code><\/pre>\n\n\n\n<p>\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u8f6c\u6362\u6a21\u578b\u4e86\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u628a\u6a21\u578b\u91cf\u5316\u4e3a Q40 \u683c\u5f0f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>cd distribured-llama\/converter\npython convert-hf.py path\/to\/Meta-Llama-3.1-405B-Instruct q40 meta-llama-3-405b<\/code><\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u8f6c\u6362\u6a21\u578b\u7684\u8fc7\u7a0b\u5927\u6982\u9700\u8981\u51e0\u4e2a\u5c0f\u65f6\u65f6\u95f4\uff0c\u5efa\u8bae\u60a8\u5728\u7761\u89c9\u524d\u6216\u8005\u4e0a\u73ed\u524d\u6267\u884c\u8fd9\u4e2a\u64cd\u4f5c\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u9700\u8981\u4e0b\u8f7d\u4e2a\u5df2\u8f6c\u6362\u7684\u6807\u8bb0\u5668\u3002\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>wget https:\/\/huggingface.co\/b4rtaz\/Llama-3_1-8B-Q40-Instruct-Distributed-Llama\/resolve\/main\/dllama_tokenizer_llama_3_1.t?download=true<\/code><\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u8fc7\u7a0b\u5b8c\u6210\u540e\uff0c\u60a8\u5f88\u5feb\u5c31\u53ef\u4ee5\u4e0b\u8f7d\u8f6c\u6362\u6210\u5206\u5e03\u5f0f Llama \u683c\u5f0f\u7684\u6a21\u578b\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/08\/6-1024x665.png\" alt=\"\" class=\"wp-image-1250\"\/><figcaption class=\"wp-element-caption\"><strong>Distributed Llama running Llama 2 70B Q40 on 8 Raspberry Pi 4B devices<\/strong><\/figcaption><\/figure>\n\n\n\n<p><strong>\u73b0\u5728\uff0c\u5728\u6839\u8282\u70b9\u4e0a\u8fd0\u884c\u63a8\u7406\u3002<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>.\/dllama inference \\\n   --model dllama_model_meta-llama-3-405b_q40.m \\\n   --tokenizer dllama_tokenizer_llama_3_1.t \\\n   --buffer-float-type q80 \\\n   --prompt \"Hello world\" \\\n   --steps 64 \\\n   --nthreads 4 \\\n   --workers 10.0.0.1:9998 10.0.0.2:9998 10.0.0.3:9998<\/code><\/code><\/pre>\n\n\n\n<p>\u8bf7\u6ce8\u610f\uff0c<strong>&#8211;workers<\/strong> \u53c2\u6570\u63a5\u53d7\u5e26\u6709\u5de5\u4f5c\u8282\u70b9\u7aef\u53e3\u7684IP\u5730\u5740\u3002\u5730\u5740\u7528\u7a7a\u683c\u5206\u9694\u3002\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e<strong>&#8211;steps N<\/strong> \u53c2\u6570\u6765\u5b9a\u4e49\u60a8\u671f\u671b\u7684\u5355\u8bcd\u9884\u6d4b\u6570\u91cf\u3002<\/p>\n\n\n\n<p>\u8fd8\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u4ee5\u540e\u60a8\u8981\u8fd0\u884c\u652f\u6301 \/v1\/chat\/completions \u7aef\u70b9\u7684 API \u670d\u52a1\uff08\u6807\u51c6openai api\u683c\u5f0f\uff09\uff0c\u5219\u5e94\u6784\u5efa dllama-api \u5e94\u7528\u7a0b\u5e8f\u5e76\u5728\u6839\u8bbe\u5907\u4e0a\u8fd0\u884c\uff0c\u800c\u4e0d\u662f dllama inference\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>.\/dllama-api \\\n  --model dllama_model_meta-llama-3-405b_q40.m \\\n  --tokenizer dllama_tokenizer_llama_3_1.t \\\n  --buffer-float-type q80 \\\n  --nthreads 4<\/code><\/code><\/pre>\n\n\n\n<p>\u5206\u5e03\u5f0fLlama\u8fd8\u652f\u6301&#8211;kv-cache-storage disk\u53c2\u6570\uff0c\u8be5\u53c2\u6570\u901a\u8fc7\u5c06KV\u7f13\u5b58\u79fb\u52a8\u5230\u78c1\u76d8\u6765\u51cf\u5c11RAM\u4f7f\u7528\u91cf\u3002Llama 3.1 \u6a21\u578b\u9700\u8981 ~34 GB \u5185\u5b58\u624d\u80fd\u5c06\u5b8c\u6574\u4e0a\u4e0b\u6587 (F32) \u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff08131k \u6807\u8bb0\uff09\u3002\u901a\u8fc7\u8bbe\u7f6e\u6b64\u53c2\u6570\uff0c\u60a8\u53ef\u4ee5\u51cf\u5c11RAM\u4f7f\u7528\u91cf\uff0c\u4f46\u9700\u8981\u989d\u5916\u7684\u78c1\u76d8\u7a7a\u95f4\u3002\u8bf7\u6ce8\u610f\uff0cKV\u7f13\u5b58\u662f\u5728\u6240\u6709\u8282\u70b9\u4e4b\u95f4\u5206\u5272\u7684\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u4e3a\u6bcf\u4e2a\u8282\u70b9\u8bbe\u7f6e\u6b64\u9009\u9879\u3002<\/p>\n\n\n\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u901a\u8fc7\u5bb6\u5ead\u8bbe\u5907\u5c31\u5b8c\u6210\u4e86AI\u96c6\u7fa4\u642d\u5efa\u7684Llama 3.1 405B\uff01\u5982\u679c\u60a8\u53d7\u6b64\u6587\u542f\u53d1\uff0c\u5728\u6b64\u57fa\u7840\u4e0a\u6709\u4e86\u521b\u65b0\uff0c\u522b\u5fd8\u4e86\u5728 <a href=\"https:\/\/github.com\/b4rtaz\/distributed-llama\/discussions\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub <\/a>\u4e0a\u5206\u4eab\u6210\u679c\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<br>\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\u3002<\/mark><\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2024\/08\/08\/%e5%ae%b6%e7%94%a8%e8%ae%be%e5%a4%87%e8%bd%bb%e6%9d%be%e6%90%ad%e5%bb%ba-ai-%e9%9b%86%e7%be%a4%ef%bc%8c%e7%95%85%e8%b7%91-llama-3-1-405b\/\">Continue reading<span class=\"screen-reader-text\">\u5bb6\u7528\u8bbe\u5907\u8f7b\u677e\u642d\u5efa AI \u96c6\u7fa4\uff0c\u7545\u8dd1 Llama 3.1 405B<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3,5],"class_list":{"0":"post-1293","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","9":"entry"},"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1293"}],"version-history":[{"count":1,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1293\/revisions"}],"predecessor-version":[{"id":1294,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1293\/revisions\/1294"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}