Files
nexus/wiki/sources/zai-ubuntu-an-zhuang-ollama-bing-yun-hang-qwen2-5-coder-7b.md
2026-04-14 16:02:50 +08:00

2.2 KiB
Raw Blame History

title, type, tags, date, source_file
title type tags date source_file
在 Ubuntu 安装 Ollama 并运行 Qwen2.5-Coder 7B source
ollama
qwen
qwen-coder
ubuntu
local-llm
2026-04-13 raw/Technical/Home Office/在 Ubuntu 安装 Ollama 并运行 Qwen2.5Coder 7B.md

Summary

  • 核心主题Ubuntu服务器安装Ollama运行Qwen2.5-Coder 7B本地大模型
  • 问题域本地LLM部署、模型服务化、API开放
  • 方法/机制Ollama一键安装 + systemd服务 + REST API暴露
  • 结论/价值构建本地AI编码助手基础设施

Key Claims

  • Ollama提供一键式LLM部署
  • Qwen2.5-Coder 7B适合代码生成和DevOps任务
  • 默认只监听127.0.0.1,需配置才能远程访问
  • GPU加速开箱即用需CUDA

Key Concepts

Key Entities

系统要求

资源 最低 推荐
CPU 4核 8+核
RAM 8GB 16GB
GPU 无需 NVIDIA
磁盘 10GB 20GB

模型大小约4.5GB

安装步骤

# 1. 安装
curl -fsSL https://ollama.com/install.sh | sh

# 2. 下载模型
ollama pull qwen2.5-coder:7b

# 3. 运行
ollama run qwen2.5-coder:7b

API调用

REST API

curl http://localhost:11434/api/chat -d '{
  "model": "qwen2.5-coder:7b",
  "messages": [{"role": "user", "content": "Write a bash script"}]
}'

Python调用

from ollama import chat
response = chat(model="qwen2.5-coder:7b", messages=[{"role": "user", "content": "..."}])

NodeJS调用

import ollama from 'ollama'
const response = await ollama.chat({ model: 'qwen2.5-coder:7b', messages: [...] })

开放远程API

编辑/etc/systemd/system/ollama.service,添加:

Environment="OLLAMA_HOST=0.0.0.0"

然后:

sudo systemctl daemon-reload
sudo systemctl restart ollama

推荐搭配

工具 用途
Open WebUI ChatGPT UI
n8n AI自动化
OpenClaw AI coding agent
LangChain Agent framework