人工智能大数据,工作效率生产力
Ctrl + D 收藏本站,更多好用AI工具
当前位置:首页 » 最新消息

本地运行DeepSeek大模型

2025-03-13 9

2025年的春节,比烟花爆竹还“火”的一样东西就是DeepSeek的R1大模型。

888317bf6d2fc6a1bd0bd9e84a9d8e6e.png

前几天到湖州玩了几天。今天坐到电脑前的第一件事就是想亲自试试这个东西。先是在网页上聊了几句,感觉不过瘾。于是想自己安装在本地运行。

b5150434a766da1f458b5a0e152881fa.png

打开幽兰代码本,先安装Ollama。Ollama是一个开源的大模型推理软件。并且具有非常好的模型管理功能。

我先是使用Ollama官网的安装脚本,但是在下载软件包时出错:

geduer@ulan:~$ curl -fsSL https://ollama.com/install.sh | sh >>> Installing ollama to /usr/local [sudo] password for geduer: >>> Downloading Linux arm64 bundle curl: (28) Failed to connect to github.com port 443 after 129139 ms: Couldn't connect to server gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now

值得说明的是,虽然脚本中的下载链接指向的是ollama.com:

"https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_PARAM}"

但其实会被重定向到github,所以上面的错误信息说无法连接到github。试了几次都不成功后,我换了一种方法,手工把文件下载下来,再复制到幽兰上。

然后wget https://ollama.com/install.sh把安装脚本下载到本地,然后略作编辑:

status "Installing ollama to $OLLAMA_INSTALL_DIR" $SUDO install -o0 -g0 -m755 -d $BINDIR $SUDO install -o0 -g0 -m755 -d "$OLLAMA_INSTALL_DIR" if test -e ollama-linux-${ARCH}.tgz; then status "Expanding local file now" $SUDO tar -xzf ollama-linux-${ARCH}.tgz -C "$OLLAMA_INSTALL_DIR" else status "Downloading Linux ${ARCH} bundle" curl --fail --show-error --location --progress-bar \ "https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_PARAM}" | \ $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR" fi

测试本地文件的几行是我修改的。

这样修改后,再执行脚本,便顺利安装了。

>>> Install complete. Run "ollama" from the command line.

接下来,便可以通过ollama命令来使用ollama了。

geduer@ulan:~$ ollama Usage: ollama [flags] ollama [command] Available Commands: serve Start ollama create Create a model from a Modelfile show Show information for a model run Run a model stop Stop a running model pull Pull a model from a registry push Push a model to a registry list List models ps List running models cp Copy a model rm Remove a model help Help about any command Flags: -h, --help help for ollama -v, --version Show version information Use "ollama [command] --help" for more information about a command.

接下来可以使用pull命令下载模型,也可以直接使用run命令下载和运行模型。我直接使用run命令,担心下载速度不够,先下载一个小的1.5b模型。

ollama run deepseek-r1:1.5b。

没想到下载速度还挺快,大约十几分钟就下载好了。而且成功运行起来了。

geduer@ulan:ollama run deepseek-r1:1.5b pulling manifest pulling aabd4debf0c8... 100% ▕█████████████████████████████████████████████████████████████████▏ 1.1 GB pulling 369ca498f347... 100% ▕█████████████████████████████████████████████████████████████████▏ 387 B pulling 6e4c38e1172f... 100% ▕█████████████████████████████████████████████████████████████████▏ 1.1 KB pulling f4d24e9138dd... 100% ▕█████████████████████████████████████████████████████████████████▏ 148 B pulling a85fe2a2e58e... 100% ▕█████████████████████████████████████████████████████████████████▏ 487 B verifying sha256 digest writing manifest success >>>

4ee16e69afa55fd082457c3e4b5f9274.png

我随便提了一个问题:how to debug linux panic

想了大约1秒钟后,回答开始了,速度还挺快:

>>> how to debug linux panic <think> Alright, so I'm trying to figure out how to debug my Linux system. I remember that some bugs or crashes can happen when th system doesn't know where it is, like on a remote server or in a script on the client side. But honestly, I don't know muc about this, and I'm worried because even minor errors might cause big problems down the line. First off, what exactly is panic mode? The user mentioned something about missing directory access or file permissions being accessed when they shouldn't be. That makes sense in a way—it's like if you're on the wrong machine to do your homework or fix something, which can mess up your work. I should make sure I'm using the right software and that my environment is set up correctly. I think I'll start by checking some basic things. Maybe unmounting unnecessary directories could help prevent conflicts with other programs. But how exactly do I do that? I remember there's something like `sudo umount /var/log/` if I want to remove a directory entirely. That seems simple enough. Maybe after doing that, the application should start without issues Then, I've heard about using tools like `-l` and `-nul` for logging file changes. So maybe running something like `ls -l --lrat` could show me which files are changing in real-time. But wait, I'm not sure how to use that correctly. Should it b on the root directory or specific directories? I think it should start from the root because otherwise, if I specify a different place, the logs won't match.

我是使用幽兰代码本做试验的。ollama不支持Mali GPU,所以安全使用CPU做的推理。基本占满了8个CPU。使用gdb附加到关键的计算进程,可以看到多个线程都在使用ggml库做大矩阵乘法。

a4a4c4a2b3599c50da0ab718f63042dc.png

在DeepSeek的回答中,很容易感受到几个明显特征:

– 使用第一人称,比如I think,I've heard about 等等

– 呈现思考的过程,一开始是<think>,开始回答后也会陈述思路,比如“首先,我需要理解为什么会有这个情况。或许问题出在路由器的配置上,或者是在如何连接网络和数据包转换方面出现了问题。让我一步步分析一下可能的原因。”

– 场景化,会自动把前面的问题当作场景信息,比如“Alright, so I'm trying to figure out what "ollama" means in this context. ”

单凭以上三个特征,真的让人感受到DeepSeek大模型真的更像“人类”了,仿佛学会了人类的思考方法。果然名不虚传!大模型的进步速度实在太快了,不断推陈出新,“探索未至之境”……

(写文章很辛苦,恳请各位读者点击“在看”,欢迎转发)

*************************************************

正心诚意,格物致知,以人文情怀审视软件,以软件技术改变人生

扫描下方二维码或者在微信中搜索“盛格塾”小程序,可以阅读更多文章和有声读物

4e641378c2f384d35d6223fb5e301312.png

也欢迎关注格友公众号

1f69e75f0b19348b5cecc07befc513a1.jpeg

原文链接:https://blog.csdn.net/advdbgger/article/details/145435206?ops_request_misc=%257B%2522request%255Fid%2522%253A%25223b225299839f95f1c92386dccc58cf9f%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=3b225299839f95f1c92386dccc58cf9f&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-27-145435206-null-null.nonecase&utm_term=deepseek%E5%91%BD%E4%BB%A4

相关推荐

阅读榜

hellenandjeckett@outlook.com

加入QQ群:849112589

回顶部