大模型 linux 安装ollama
大模型 linux 安装ollama
ollama 常用命令
ollama serve #启动ollama
ollama create #从模型文件创建模型
ollama show #显示模型信息
ollama run #运行模型
ollama pull #从注册表中拉取模型
ollama push #将模型推送到注册表
ollama list #列出模型
ollama cp #复制模型
ollama rm #删除模型
ollama help #获取有关任何命令的帮助信息
在线安装
访问官网: https://ollama.com/
选则linux,粘贴上面的脚本
// 粘贴执行即可
curl -fsSL https://ollama.com/install.sh | sh
如果脚本运行时报错,无法连接github,请修改 /etc/hosts
vim /etc/hosts # 添加
140.82.114.3 github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.108.153 assets-cdn.github.com
重新执行脚本
离线安装
下载
// 需要FQ下载
https://github.com/ollama/ollama/releases/latest/download/ollama-linux-amd64.tgz
安装
// 下载后上传到linux安装
tar -C /usr/ -xzf ollama-linux-amd64.tgz
允许外部访问
// 追加环境变量
export OLLAMA_HOST=0.0.0.0:11434
ollama serve &
导出导入模型
导出模型
// 以qwen:7b 这个模型为例,查看信息
// 并将modelfile保存,后面我们要用
ollama show --modelfile qwen:7b >> qwen-7b.modelfile
// 查看刚保存的modelfile
// 跟dokcerfile一样,有个 FROM /Users/m2max/.ollama/models/blobs/sha256-46bb65206e0e2b00424f33985a5281bd21070617ebcfda9be86eb17e6e00f793 这样类似的
cat qwen-7b.modelfile
//拷贝模型
// 这样,qwen:7b模型就被导出为qwen_7b.gguf文件
// 至此,我们得到两个文件 qwen_7b.gguf 和 qwen-7b.modelfile
cp /Users/m2max/.ollama/models/blobs/sha256-46bb65206e0e2b00424f33985a5281bd21070617ebcfda9be86eb17e6e00f793 qwen_7b.gguf
导入模型
// 上面我们有qwen-7b.modelfile 和 qwen_7b.gguf,都拷贝到目标服务器上同一目录
// 修改FROM ,改为 FROM ./qwen_7b.gguf
// 转化模型
ollama create qwen-7b:v1 -f qwen-7b.modelfile
//查看模型
ollama list
本文来自博客园,作者:liwenchao1995,转载请注明原文链接:https://www.cnblogs.com/liwenchao1995/p/18704698