欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > linux ollama deepseek等大语言模型的model文件的存储目录

linux ollama deepseek等大语言模型的model文件的存储目录

2025/2/20 18:31:59 来源:https://blog.csdn.net/gianttj/article/details/145610659  浏览:    关键词:linux ollama deepseek等大语言模型的model文件的存储目录
linux ollama deepseek等大语言模型的model文件的存储目录

一、用ollama serve启动的,模型数据存放在:

/usr/share/ollama/.ollama/models

二、如果在自启动文件中指定了工作目录,则在工作目录下的.ollama/models

1.自启动服务 /etc/systemd/system/ollama.service:

[Unit]
Description=Ollama Service
After=network.target[Service]
Environment="OLLAMA_HOST=0.0.0.0"
Environment="OLLAMA_ORIGINS=*"
Type=simple
User=root
WorkingDirectory=/root
ExecStart=/usr/local/bin/ollama serve
Restart=on-failure
RestartSec=30[Install]
WantedBy=multi-user.target

文件中指定了工作目录(WorkingDirectory)是/root,但未设置OLLAMA_MODELS环境变量,用systemctl start ollama或开机自启后,模型目录为

/root/.ollama/models

2.修改自定义模型目录,设置OLLAMA_MODELS环境变量即可:

[Unit]
Description=Ollama Service
After=network-online.target[Service]
Environment="OLLAMA_HOST=0.0.0.0"
Environment="OLLAMA_ORIGINS=*"
Environment="OLLAMA_MODELS=/data/ollama/.ollama/models"
ExecStart=/usr/local/bin/ollama serve
Type=simple
User=root
Group=root
Restart=always
RestartSec=3[Install]
WantedBy=multi-user.target

三、自启动文件属性说明:

  • Description 是服务的简单描述。
  • After 指定了在哪个服务启动后启动此服务。
  • Type 定义了服务进程的启动类型,simple 表示启动主进程。
  • User 指定运行服务的用户,本文用的是root ,也可以用其他账户。
  • Group 指定运行服务的工用户组,本文用的是root,即用户root所在的用户组。
  • WorkingDirectory 设置服务的工作目录,本文用的/root,也可以切换成其他用户目录。
  • ExecStart 指定启动服务的命令。
  • Restart 指定服务崩溃时的重启策略。
  • RestartSec 设置重启服务前等待的时间。
  • WantedBy 指定了服务所在的 target,multi-user.target 表示多用户系统。
  • Environment 启动服务的环境变量,只对启动该服务有用。

四、服务启动命令

# 重新加载 systemd 以识别新服务
sudo systemctl daemon-reload
# 启动服务
sudo systemctl start ollama.service
# 使服务开机自启
sudo systemctl enable ollama.service
# 检查服务状态
sudo systemctl status ollama.service

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词