{"id":237,"date":"2025-02-03T03:34:06","date_gmt":"2025-02-02T19:34:06","guid":{"rendered":"https:\/\/nds.cool\/?p=237"},"modified":"2025-02-03T03:41:20","modified_gmt":"2025-02-02T19:41:20","slug":"237","status":"publish","type":"post","link":"https:\/\/blog.wcld.top\/?p=237","title":{"rendered":"2\u3001\u5728 Ubuntu \u4e0a\u901a\u8fc7 Ollama \u90e8\u7f72 DeepSeek-R1-7B \u5927\u6a21\u578b\u5b8c\u6574\u6307\u5357"},"content":{"rendered":"<h1><span style=\"font-size: 16px\">\u672c\u6587\u5c06\u624b\u628a\u624b\u6307\u5bfc\u60a8\u5728 Ubuntu \u7cfb\u7edf\u4e2d\u5229\u7528 Ollama \u6846\u67b6\u90e8\u7f72\u56fd\u4ea7\u5f00\u6e90\u5927\u6a21\u578b DeepSeek-R1-7B\uff0c\u5305\u542b GPU \u52a0\u901f\u914d\u7f6e\u3001\u91cf\u5316\u6a21\u578b\u9009\u62e9\u53ca\u5e38\u89c1\u95ee\u9898\u89e3\u51b3\u65b9\u6848\u3002\u65e0\u8bba\u60a8\u662f AI \u5f00\u53d1\u8005\u8fd8\u662f\u6280\u672f\u7231\u597d\u8005\uff0c\u90fd\u80fd\u5728 30 \u5206\u949f\u5185\u5b8c\u6210\u5168\u6d41\u7a0b\u90e8\u7f72\u3002<\/span><\/h1>\n<!-- \u524d\u7f6e\u6761\u4ef6 -->\n<div class=\"wp-block-group has-background\" style=\"background-color: #f8f9fa;padding: 20px;border-radius: 8px\">\n<h2>? \u524d\u7f6e\u51c6\u5907<\/h2>\n<div class=\"wp-block-list\">\n<ul>\n\n<li>\u5df2\u5b89\u88c5 Ollama \u8fd0\u884c\u73af\u5883\uff08<a href=\"https:\/\/nds.cool\/?p=232\">\u5b89\u88c5\u6559\u7a0b\u53c2\u8003<\/a>\uff09<\/li>\n\n<li>NVIDIA \u663e\u5361\u9a71\u52a8\u7248\u672c \u2265 535\uff08<code>nvidia-smi<\/code> \u9a8c\u8bc1\uff09<\/li>\n\n<li>\u78c1\u76d8\u7a7a\u95f4 \u2265 8GB\uff08\u63a8\u8350 SSD \u5b58\u50a8\uff09<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<!-- \u6838\u5fc3\u6b65\u9aa4 -->\n<h2>? \u4e09\u9636\u6bb5\u90e8\u7f72\u6d41\u7a0b<\/h2>\n<h3>\u9636\u6bb5\u4e00\uff1a\u83b7\u53d6\u6a21\u578b\u6587\u4ef6<\/h3>\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\" style=\"flex-basis: 50%\">\n<h4>\u65b9\u6cd5 1\uff1a\u76f4\u63a5\u4e0b\u8f7d GGUF \u683c\u5f0f\uff08\u63a8\u8350\uff09<\/h4>\n<pre class=\"wp-block-code\"><code># \u521b\u5efa\u6a21\u578b\u76ee\u5f55\nmkdir -p ~\/.ollama\/models\n\n# \u4e0b\u8f7d 4-bit \u91cf\u5316\u6a21\u578b\nwget -P ~\/.ollama\/models \\\nhttps:\/\/huggingface.co\/deepseek-ai\/DeepSeek-R1-7B-GGUF\/resolve\/main\/deepseek-r1-7b.Q4_K_M.gguf<\/code><\/pre>\n<\/div>\n<div class=\"wp-block-column\" style=\"flex-basis: 50%\">\n<h4>\u65b9\u6cd5 2\uff1a\u81ea\u4e3b\u8f6c\u6362\u6a21\u578b<\/h4>\n<pre class=\"wp-block-code\"><code># \u5b89\u88c5\u8f6c\u6362\u5de5\u5177\ngit clone https:\/\/github.com\/ggerganov\/llama.cpp\ncd llama.cpp &amp;&amp; make\n\n# \u6267\u884c\u91cf\u5316\uff08\u793a\u4f8b\uff1a6-bit\uff09\n.\/quantize input.fp16.gguf \\\noutput.q6_k.gguf q6_k<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"wp-block-media-text alignwide\">\n<div class=\"wp-block-media-text__content\">\n<h3>? \u91cf\u5316\u65b9\u6848\u9009\u62e9\u5efa\u8bae<\/h3>\n<table class=\"wp-block-table\">\n<thead>\n<tr>\n<th>\u91cf\u5316\u7b49\u7ea7<\/th>\n<th>\u663e\u5b58\u5360\u7528<\/th>\n<th>\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Q8_0<\/td>\n<td>10GB<\/td>\n<td>\u4ee3\u7801\u751f\u6210\/\u6570\u5b66\u8ba1\u7b97<\/td>\n<\/tr>\n<tr>\n<td>Q6_K<\/td>\n<td>7GB<\/td>\n<td>\u591a\u8f6e\u5bf9\u8bdd<\/td>\n<\/tr>\n<tr>\n<td>Q4_K_M<\/td>\n<td>5GB<\/td>\n<td>\u8f7b\u91cf\u7ea7\u90e8\u7f72<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u9636\u6bb5\u4e8c\uff1a\u521b\u5efa\u6a21\u578b\u914d\u7f6e\u6587\u4ef6<\/h3>\n<pre class=\"wp-block-code\"><code># \u65b0\u5efa Modelfile\ncat &lt;&lt; EOF &gt; ~\/.ollama\/Modelfile\/deepseek-r1-7b\nFROM ~\/.ollama\/models\/deepseek-r1-7b.Q4_K_M.gguf\n\n# \u6027\u80fd\u53c2\u6570\nPARAMETER num_ctx 4096  # \u4e0a\u4e0b\u6587\u957f\u5ea6\nPARAMETER temperature 0.8  # \u521b\u610f\u6307\u6570\nPARAMETER num_gpu 45  # GPU \u663e\u5b58\u5206\u914d\u6bd4\u4f8b\nEOF<\/code><\/pre>\n<h3>\u9636\u6bb5\u4e09\uff1a\u6ce8\u518c\u5e76\u8fd0\u884c\u6a21\u578b<\/h3>\n<pre class=\"wp-block-code\"><code># \u6ce8\u518c\u6a21\u578b\u5230 Ollama\nollama create deepseek-r1-7b -f ~\/.ollama\/Modelfile\/deepseek-r1-7b\n\n# \u542f\u52a8\u63a8\u7406\u670d\u52a1\nollama run deepseek-r1-7b\n\n# \u6d4b\u8bd5\u751f\u6210\u6548\u679c\n&gt;&gt;&gt; \u8bf7\u7528 Python \u5b9e\u73b0\u6590\u6ce2\u90a3\u5951\u6570\u5217\u751f\u6210\u5668<\/code><\/pre>\n<!-- \u6027\u80fd\u9a8c\u8bc1 -->\n<div class=\"tech-tip\">\n<h4>\u2705 \u6210\u529f\u8fd0\u884c\u9a8c\u8bc1\u70b9<\/h4>\n<div class=\"wp-block-list\">\n<ul>\n\n<li>\u7ec8\u7aef\u8f93\u51fa\u5305\u542b <code>total duration<\/code> \u65f6\u95f4\u7edf\u8ba1<\/li>\n\n<li><code>nvidia-smi<\/code> \u663e\u793a\u663e\u5b58\u5360\u7528 \u22654GB<\/li>\n\n<li>\u751f\u6210\u6587\u672c\u7b26\u5408\u903b\u8f91\u4e14\u65e0\u4e71\u7801<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<!-- \u9ad8\u7ea7\u914d\u7f6e -->\n<h2>\u2699\ufe0f \u751f\u4ea7\u7ea7\u4f18\u5316\u65b9\u6848<\/h2>\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<h3>GPU \u5185\u5b58\u4f18\u5316<\/h3>\n<pre class=\"wp-block-code\"><code># \u52a8\u6001\u663e\u5b58\u5206\u914d\nPARAMETER numa true  # \u542f\u7528 NUMA \u4f18\u5316\nPARAMETER low_vram  # \u4f4e\u663e\u5b58\u6a21\u5f0f<\/code><\/pre>\n<\/div>\n<div class=\"wp-block-column\">\n<h3>API \u670d\u52a1\u5316<\/h3>\n<pre class=\"wp-block-code\"><code># \u542f\u52a8 REST API\nollama serve\n\n# \u8c03\u7528\u793a\u4f8b\ncurl http:\/\/localhost:11434\/api\/generate -d &#039;{\n  &quot;model&quot;: &quot;deepseek-r1-7b&quot;,\n  &quot;prompt&quot;: &quot;\u4e3a\u4ec0\u4e48\u5929\u7a7a\u662f\u84dd\u8272\u7684\uff1f&quot;\n}&#039;<\/code><\/pre>\n<\/div>\n<\/div>\n<!-- \u6545\u969c\u6392\u67e5 -->\n<h2>?\ufe0f \u5e38\u89c1\u95ee\u9898\u6392\u67e5\u8868<\/h2>\n<div class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>\u95ee\u9898\u73b0\u8c61<\/th>\n<th>\u89e3\u51b3\u65b9\u6848<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Error: CUDA out of memory<\/td>\n<td>\u964d\u4f4e\u91cf\u5316\u7b49\u7ea7\u6216\u6dfb\u52a0 <code>low_vram<\/code> \u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>\u6a21\u578b\u54cd\u5e94\u901f\u5ea6\u6162<\/td>\n<td>\u8bbe\u7f6e <code>PARAMETER num_threads 8<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u751f\u6210\u5185\u5bb9\u4e71\u7801<\/td>\n<td>\u68c0\u67e5\u6a21\u578b\u6587\u4ef6 MD5 \u6821\u9a8c\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c06\u624b\u628a\u624b\u6307\u5bfc\u60a8\u5728 Ubuntu \u7cfb\u7edf\u4e2d\u5229\u7528 Ollama \u6846\u67b6\u90e8\u7f72\u56fd\u4ea7\u5f00\u6e90\u5927\u6a21\u578b DeepSeek-R1-7B\uff0c\u5305\u542b\u2026<\/p>","protected":false},"author":1,"featured_media":239,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=237"}],"version-history":[{"count":1,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":238,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions\/238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/media\/239"}],"wp:attachment":[{"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}