2025-03-10 17:25:01 +08:00

109 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 大模型
date: 2025-02-18 10:06:57
tags:
---
# Ollama
## 1. 安装
首先需要下载并安装Ollama这是运行模型的基础环境。
![image-20250218102658870](https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250218102658870.png)
## 2. 下载模型
打开命令行终端,根据需要运行以下命令之一来下载对应版本的模型:
![image-20250218104847668](https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250218104847668.png)
以DeepSeek为例
7B 版本(推荐显存 8G:
```bash
ollama pull deepseek-coder:7b
```
8B 版本(推荐显存 8G:
```bash
ollama run huihui_ai/deepseek-r1-abliterated:8b
```
14B 版本(推荐显存 12G:
```BASH
ollama run huihui_ai/deepseek-r1-abliterated:14b
```
32B 版本(推荐显存 32G:
```bash
ollama run huihui_ai/deepseek-r1-abliterated:32b
```
70B 版本(需要高端显卡支持):
```bash
ollama run huihui_ai/deepseek-r1-abliterated:70b
```
## 3. Ollama 常用命令
在使用 Ollama 时,以下是一些常用的命令操作:
```bash
# 启动 Ollama 服务
ollama serve
# 从 Modelfile 创建模型
ollama create <模型名称>
# 显示模型信息
ollama show <模型名称>
# 运行模型
ollama run <模型名称>
# 停止运行中的模型
ollama stop <模型名称>
# 从仓库拉取模型
ollama pull <模型名称>
# 推送模型到仓库
ollama push <模型名称>
# 列出所有已安装的模型
ollama list
# 列出正在运行的模型
ollama ps
# 复制模型
ollama cp <源模型> <目标模型>
# 删除模型
ollama rm <模型名称>
```
## 4. Ollama模型存储目录
- macOS: `~/.ollama/models`
- Linux: `/usr/share/ollama/.ollama/models`
- Windows: `C:\Users\%username%\.ollama\models`
### 如何将它们设置为不同的位置?
如果需要使用不同的目录,可以将环境变量 `OLLAMA_MODELS` 设置为你选择的目录。
> 注意:在 Linux 上使用标准安装程序时,`ollama` 用户需要对指定目录有读写权限。要将目录分配给 `ollama` 用户,请运行 `sudo chown -R ollama:ollama <directory>`.
请参考[上面的部分](https://ollama.readthedocs.io/faq/#how-do-i-configure-ollama-server)了解如何在你的平台上设置环境变量。
![image-20250218132430850](https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250218132430850.png)