ChatGLM.cpp 安装使用(支持CPU、Metal及CUDA推理)
1.ChatGLM.cpp 安装使用(支持CPU、Metal及CUDA推理)
2.llama.cpp 安装使用(支持CPU、Metal及CUDA的单卡/多卡推理)3.Ollama 安装、运行大模型(CPU 实操版)4.迁移 ollama 模型文件到新机器(支持离线运行)5.Ollama WebUI 安装使用(pip 版)1. 详细步骤
1.1 拉取源码
# 确保网络通畅
git clone --recursive https://github.com/li-plus/chatglm.cpp.git && cd chatglm.cpp
1.2 模型转换/量化
1.2.1 安装所需 Python 依赖
torch
pip install torch -U
其他依赖
pip install tabulate tqdm transformers accelerate sentencepiece tiktoken -U
1.2.1 模型转换/量化
f16
python chatglm_cpp/convert.py -i /path/THUDM/chatglm-6b -t f16 -o /path/THUDM/chatglm-6b/f16.bin
q8_0
python chatglm_cpp/convert.py -i /path/THUDM/chatglm-6b -t q8_0 -o /path/THUDM/chatglm-6b/q8_0.bin
q4_0
python chatglm_cpp/convert.py -i /path/THUDM/chatglm-6b -t q4_0 -o /path/THUDM/chatglm-6b/q4_0.bin
1.3 模型测试
1.3.1 编译所需 C/C++ 环境
通过 Python Binding
来调用也可以
CPU
cmake -B build && cmake --build build -j --config Release
CUDA
cmake -B build -DGGML_CUDA=ON && cmake --build build -j
Metal(MPS)
cmake -B build -DGGML_METAL=ON && cmake --build build -j
1.3.2 模型测试
单次推理
./build/bin/main -m /path/THUDM/chatglm-6b/f16.bin -p 你好
多轮对话
./build/bin/main -m /path/THUDM/chatglm-6b/f16.bin -i
2. 参考资料
2.1 ChatGLM.cpp
2.1.1 GitHub
Getting Started (Preparation, Quantize, Build & Run...)
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#getting-started
Using BLAS (CUDA, Metal...)
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#using-blas
3. 资源
3.1 ChatGLM.cpp
3.1.1 GitHub
官方页面
https://github.com/li-plus/chatglm.cpp
Python Binding
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#python-binding
API Server
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#api-server
Using Docker
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#using-docker
Performance
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#performance
Model Quality
https://github.com/li-plus/chatglm.cpp?tab=readme-ov-file#model-quality
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)