ollama,免费低门槛的开源大模型推理平台

阅读原文

建议阅读原文,始终查看最新文档版本,获得最佳阅读体验:《ollama,免费低门槛的开源大模型推理平台》

https://docs.dingtalk.com/i/nodes/np9zOoBVBYA16qAPTEkzObKgW1DK0g6l

介绍

Ollama 是一个轻量化的大模型本地运行与管理平台,用户无需复杂配置即可在个人电脑上快速下载、部署和运行各类开源大模型。它提供统一的命令行工具与 API 接口,方便与应用程序集成,同时支持模型管理、版本控制和高效推理,帮助开发者在本地环境中灵活构建和测试 AI 应用。

官网

Ollama

github网址

ollama/ollama: Get up and running with OpenAI gpt-oss, DeepSeek-R1, Gemma 3 and other models.

安装

linux

curl -fsSL https://ollama.com/install.sh | sh

Windows

winget install --id Ollama.Ollama
#安装完成后,要重新打开终端才能使用ollama命令

image.png

ollama常用命令

下载大模型

ollama pull qwen2.5vl:7b

image.png

运行大模型

ollama run qwen2.5vl:7b #ollama默认在本地环回地址上监听

将端口包括在网络上

官方文档:ollama/docs/faq.md at main · ollama/ollama

OLLAMA_HOST=0.0.0.0:11434 ollama run qwen2.5vl:7b

查询当前计算机下载了哪些大模型

image.png

查询大模型的基本信息

ollama show qwen2.5vl:7b

image.png

停止大模型

ollama stop qwen2.5vl:7b

查询当前已加载的大模型

也可以理解为当前正在运行的大模型

ollama ps

image.png

通过api调用大模型

生成一次回答

curl http://10.65.37.46:11434/api/chat -d '{
  "model": "qwen2.5vl:7b",
  "messages": [
    {
      "role": "user",
      "content": "why is the sky blue?"
    }
  ],
  "stream": false
}' | jq .

完整输出:

[ubuntu@keycloak-test ~]$ curl http://10.65.37.46:11434/api/chat -d '{
  "model": "qwen2.5vl:7b",
  "messages": [
    {
      "role": "user",
      "content": "why is the sky blue?"
    }
  ],
  "stream": false
}' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1544  100  1401  100   143    259     26  0:00:05  0:00:05 --:--:--   318
{
  "model": "qwen2.5vl:7b",
  "created_at": "2025-08-14T11:10:12.755802Z",
  "message": {
    "role": "assistant",
    "content": "The sky appears blue due to a phenomenon called Rayleigh scattering. This occurs when sunlight enters the Earth's atmosphere and interacts with the molecules in the air, primarily nitrogen and oxygen. These molecules are much smaller than the wavelength of visible light, which causes the light to scatter in all directions.\n\nThe shorter wavelengths of blue and violet light are scattered more than the longer wavelengths of red and orange light. This is because the shorter wavelengths are more easily deflected by the smaller molecules. As a result, when you look at the sky, you are seeing the scattered blue light that has been reflected back to your eyes from all directions.\n\nThe scattering of blue light is more pronounced than the scattering of other colors, which is why the sky appears blue. However, during sunrise and sunset, the angle at which the sunlight enters the atmosphere is different, and the shorter wavelengths of light are more easily scattered. This causes the sky to appear reddish or orange, as the blue light is scattered away and the longer wavelengths are more prominent."
  },
  "done_reason": "stop",
  "done": true,
  "total_duration": 5394303700,
  "load_duration": 37043400,
  "prompt_eval_count": 26,
  "prompt_eval_duration": 26298200,
  "eval_count": 205,
  "eval_duration": 5327213300
}

多GPU推理

ollama默认支持单节点多GPU并行推理,参考:ollama/docs/faq.md at main · ollama/ollama (github.com)

02ceac3b9cc52f6a6687a6ab22f49c93.png

关于作者和DreamAI

https://docs.dingtalk.com/i/nodes/Amq4vjg890AlRbA6Td9ZvlpDJ3kdP0wQ?iframeQuery=utm_source=portal&utm_medium=portal_recent

关注微信公众号“AI发烧友”,获取更多IT开发运维实用工具与技巧,还有很多AI技术文档!

梦幻智能logo-01(无水印).png

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐