背景
公司需要部署一套内部的deepseek大模型,服务器是OpenEuler系统,没有外网,只能内部VPN访问。
1.离线下载安装Ollama
- 登录github,搜索ollama,进入到ollama的项目库,进入到releases库,查看历史版本。
- 下载之后导入到需要部署的机器上,我的是Euler系统,安装目录在/usr/local:
tar -zxvf ollama-linux-amd64.tgz -C /usr/local
#解压完成后给予执行权限
sudo chmod +x /usr/local/bin/ollama
#执行ollama
ollama --version
2.离线下载安装deepseek
- 在本地使用ollama
#本地先拉取deepseek-r1
ollama pull deepseek-r:1.5b
- 生成modelfile文件,并下载权重
ollama show deepseek-r1:1.5b --modelfile
生成数据如下
# Modelfile generated by "ollama show"
# To build a new Modelfile based on this, replace FROM with:
# FROM deepseek-r1:1.5b
FROM /home/user/.ollama/models/blobs/sha256-aabd4debf0c8f08881923f2c25fc0fdeed24435271c2b3e92c4af36704040dbc
TEMPLATE """{{- if .System }}{{ .System }}{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1}}
{{- if eq .Role "user" }}<|User|>{{ .Content }}
{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}
{{- end }}
{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}
{{- end }}"""
PARAMETER stop <|begin▁of▁sentence|>
PARAMETER stop <|end▁of▁sentence|>
PARAMETER stop <|User|>
PARAMETER stop <|Assistant|>
LICENSE """MIT License
Copyright (c) 2023 DeepSeek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
- 查找模型的gguf文件,使用ollama pull拉取的是sha256文件
本地运行的权重文件地址,linux:/home/user/.ollama/models/blobs
或者windows:C:/Users/C/.ollama/models/blobs
找到sha256文件,将比较大的文件复制一份,放到离线服务器上/home/user/.ollama/blobs
4. 修改modelfile文件,将此路径改为服务器的路径
3.创建deepseek
在服务器上运行
ollama create deepseek-r1:1.5b -f modelfile
安装结束
ollama run mydeepseek