{"id":232,"date":"2025-02-03T03:20:36","date_gmt":"2025-02-02T19:20:36","guid":{"rendered":"https:\/\/nds.cool\/?p=232"},"modified":"2025-02-03T03:43:35","modified_gmt":"2025-02-02T19:43:35","slug":"%e5%9c%a8-ubuntu-%e6%a1%8c%e9%9d%a2%e7%89%88%e9%83%a8%e7%bd%b2-ollama-%e5%ae%8c%e6%95%b4%e6%8c%87%e5%8d%97%ef%bc%88%e9%9d%9e-docker-%e6%96%b9%e6%a1%88%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.wcld.top\/?p=232","title":{"rendered":"1\u3001\u5728 Ubuntu \u684c\u9762\u7248\u90e8\u7f72 Ollama \u5b8c\u6574\u6307\u5357\uff08\u975e Docker \u65b9\u6848\uff09"},"content":{"rendered":"<div><\/div>\n<!-- \u73af\u5883\u8981\u6c42 -->\n<div class=\"wp-block-heading\">\n<h3>\u4e00\u3001\u73af\u5883\u51c6\u5907<\/h3>\n<\/div>\n<div class=\"wp-block-list\">\n<ul>\n\n<li>\u64cd\u4f5c\u7cfb\u7edf\uff1aUbuntu 22.04 LTS \u6216\u66f4\u65b0\u7248\u672c<\/li>\n\n<li>\u786c\u4ef6\u8981\u6c42\uff1a\n<ul>\n\n<li>CPU\uff1a4 \u6838\u53ca\u4ee5\u4e0a<\/li>\n\n<li>\u5185\u5b58\uff1a16GB+<\/li>\n\n<li>GPU\uff08\u53ef\u9009\uff09\uff1aNVIDIA GTX 1060 6GB+\/RTX \u7cfb\u5217\uff08\u63a8\u8350\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<!-- \u5b89\u88c5\u6b65\u9aa4 -->\n<div class=\"wp-block-heading\">\n<h3>\u4e8c\u3001\u57fa\u7840\u73af\u5883\u914d\u7f6e<\/h3>\n<\/div>\n<div class=\"wp-block-heading\">\n<h4>\u6b65\u9aa4 1\uff1a\u5b89\u88c5\u7cfb\u7edf\u4f9d\u8d56<\/h4>\n<\/div>\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt upgrade -y\nsudo apt install -y curl git-lfs build-essential cmake python3-pip<\/code><\/pre>\n<div class=\"wp-block-heading\">\n<h4>\u6b65\u9aa4 2\uff1a\u914d\u7f6e NVIDIA \u663e\u5361\u9a71\u52a8<\/h4>\n<\/div>\n<pre class=\"wp-block-code\"><code># \u81ea\u52a8\u5b89\u88c5\u63a8\u8350\u9a71\u52a8\nsudo ubuntu-drivers autoinstall\nsudo reboot<\/code><\/pre>\n<!-- \u56fe\u7247\u63d2\u5165\u4f4d\u7f6e\u5efa\u8bae -->\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"nvidia-smi-screenshot.png\" alt=\"GPU\u72b6\u6001\u9a8c\u8bc1\u622a\u56fe\">\n<figcaption>\u4f7f\u7528 nvidia-smi \u9a8c\u8bc1\u9a71\u52a8\u5b89\u88c5<\/figcaption><\/figure>\n<!-- Ollama \u5b89\u88c5 -->\n<div class=\"wp-block-heading\">\n<h3>\u4e09\u3001\u5b89\u88c5 Ollama \u670d\u52a1<\/h3>\n<\/div>\n<pre class=\"wp-block-code\"><code># \u4e00\u952e\u5b89\u88c5\ncurl -fsSL https:\/\/ollama.com\/install.sh | sh\n\n# \u542f\u52a8\u670d\u52a1\nsudo systemctl start ollama\nsudo systemctl enable ollama<\/code><\/pre>\n<!-- \u6a21\u578b\u90e8\u7f72 -->\n<div class=\"wp-block-heading\">\n<h3>\u56db\u3001\u90e8\u7f72 DeepSeek-R1-7B \u6a21\u578b<\/h3>\n<\/div>\n<div class=\"wp-block-heading\">\n<h4>\u65b9\u6cd5 1\uff1a\u4f7f\u7528\u9884\u8f6c\u6362\u6a21\u578b<\/h4>\n<\/div>\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/.ollama\/models\nwget -P ~\/.ollama\/models https:\/\/huggingface.co\/\u6a21\u578b\u8def\u5f84\/deepseek-r1-7b.Q4_K_M.gguf<\/code><\/pre>\n<div class=\"wp-block-heading\">\n<h4>\u65b9\u6cd5 2\uff1a\u624b\u52a8\u8f6c\u6362\u6a21\u578b<\/h4>\n<\/div>\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/ggerganov\/llama.cpp\ncd llama.cpp &amp;&amp; make\n.\/quantize ~\/deepseek-r1-7b.f16.gguf ~\/deepseek-r1-7b.Q4_K_M.gguf Q4_K_M<\/code><\/pre>\n<!-- \u914d\u7f6e\u8bf4\u660e -->\n<div class=\"wp-block-heading\">\n<h3>\u4e94\u3001\u6a21\u578b\u670d\u52a1\u914d\u7f6e<\/h3>\n<\/div>\n<pre class=\"wp-block-code\"><code># \u521b\u5efa Modelfile\necho &#039;FROM ~\/.ollama\/models\/deepseek-r1-7b.Q4_K_M.gguf\nPARAMETER num_ctx 4096&#039; &gt; ~\/.ollama\/Modelfile\/deepseek\n\n# \u6ce8\u518c\u6a21\u578b\nollama create deepseek-r1-7b -f ~\/.ollama\/Modelfile\/deepseek<\/code><\/pre>\n<!-- \u9a8c\u8bc1\u90e8\u5206 -->\n<div class=\"wp-block-heading\">\n<h3>\u516d\u3001\u8fd0\u884c\u9a8c\u8bc1<\/h3>\n<\/div>\n<pre class=\"wp-block-code\"><code># \u547d\u4ee4\u884c\u4ea4\u4e92\u6d4b\u8bd5\nollama run deepseek-r1-7b &quot;\u89e3\u91ca\u91cf\u5b50\u8ba1\u7b97\u7684\u57fa\u672c\u539f\u7406&quot;\n\n# \u76d1\u63a7 GPU \u72b6\u6001\nwatch -n 1 nvidia-smi<\/code><\/pre>\n<!-- \u6545\u969c\u6392\u67e5 -->\n<div class=\"wp-block-heading\">\n<h3>\u5e38\u89c1\u95ee\u9898\u89e3\u51b3<\/h3>\n<\/div>\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>\u6a21\u578b\u52a0\u8f7d\u5931\u8d25<\/td>\n<td>\u68c0\u67e5\u6587\u4ef6\u6743\u9650\uff1a<code>sudo chown -R $USER:$USER ~\/.ollama<\/code><\/td>\n<\/tr>\n<tr>\n<td>\u663e\u5b58\u4e0d\u8db3\u9519\u8bef<\/td>\n<td>\u4fee\u6539 Modelfile \u7684 <code>num_gpu<\/code> \u53c2\u6570\u964d\u4f4e\u663e\u5b58\u5206\u914d\u6bd4\u4f8b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<!-- \u603b\u7ed3 -->\n<div class=\"wp-block-heading\">\n<h3>\u6700\u4f73\u5b9e\u8df5\u5efa\u8bae<\/h3>\n<\/div>\n<div class=\"wp-block-list\">\n<ul>\n\n<li>\u4f18\u5148\u4f7f\u7528 4-bit \u91cf\u5316\u6a21\u578b\u5e73\u8861\u6027\u80fd\u4e0e\u7cbe\u5ea6<\/li>\n\n<li>\u5b9a\u671f\u6267\u884c <code>ollama prune<\/code> \u6e05\u7406\u65e7\u6a21\u578b\u7f13\u5b58<\/li>\n\n<li>\u751f\u4ea7\u73af\u5883\u5efa\u8bae\u914d\u5408 Nginx \u505a\u53cd\u5411\u4ee3\u7406<\/li>\n<\/ul>\n<\/div>\n<!-- \u6269\u5c55\u9605\u8bfb -->\n<div class=\"wp-block-heading\">\n<h3>\u5ef6\u4f38\u9605\u8bfb<\/h3>\n<\/div>\n<div class=\"wp-block-list\">\n<ul>\n\n<li><a href=\"https:\/\/ollama.ai\/\" target=\"_blank\" rel=\"noreferrer noopener\">Ollama \u5b98\u65b9\u6587\u6863<\/a><\/li>\n\n<li><a href=\"https:\/\/github.com\/ggerganov\/llama.cpp\" target=\"_blank\" rel=\"noreferrer noopener\">llama.cpp GitHub \u4ed3\u5e93<\/a><\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u73af\u5883\u51c6\u5907 \u64cd\u4f5c\u7cfb\u7edf\uff1aUbuntu 22.04 LTS \u6216\u66f4\u65b0\u7248\u672c \u786c\u4ef6\u8981\u6c42\uff1a CPU\uff1a4 \u6838\u53ca\u4ee5\u4e0a \u5185\u5b58\uff1a16GB+\u2026<\/p>","protected":false},"author":1,"featured_media":241,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-232","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\/232","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=232"}],"version-history":[{"count":0,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/posts\/232\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=\/wp\/v2\/media\/241"}],"wp:attachment":[{"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wcld.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}