LLM | ChatGLM.cpp 安装使用(支持CPU、Metal及CUDA推理)

news/2024/10/4 20:51:10 标签: chatglm.cpp

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


http://www.niftyadmin.cn/n/5690316.html

相关文章

浅谈memset和memcpy的区别

memcpy 和 memset 都是 C 语言标准库中的函数&#xff0c;用于内存操作&#xff0c;但它们的用途和行为有所不同&#xff1a; memcpy: memcpy 是一个函数&#xff0c;定义在 <string.h> 头文件中。它用于从源内存地址复制指定数量的字节到目标内存地址。memcpy 会逐字节地…

netty之Netty心跳服务与断线重连

前言 使用netty中&#xff0c;需要监测服务是否稳定以及在网络异常链接断开时候可以自动重连。需要实现监听&#xff1b;f.addListener(new MyChannelFutureListener()) 代码目录结构 package com.lm.demo.netty.client;import io.netty.channel.ChannelFuture; import io.nett…

MATLAB中数据导入与导出的全面指南

在MATLAB中&#xff0c;数据的导入与导出是数据处理工作流中的两个基本步骤。导入是将外部数据加载到MATLAB工作区的过程&#xff0c;而导出则是将工作区中的数据保存到外部文件中。这两个步骤对于数据分析、可视化和结果共享至关重要。本文将详细介绍如何在MATLAB中进行数据的…

PostgreSQL常用数值处理函数简介

PostgreSQL 提供了许多用于数值处理的函数&#xff0c;涵盖数学运算、取整、取余、随机数生成等操作。以下是一些常用的数值处理函数及其使用示例&#xff1a; 1. ABS() - 取绝对值 返回数字的绝对值。 SELECT ABS(-10); -- 返回 10 SELECT ABS(3.5); -- 返回 3.52. CEIL(…

【React】入门Day04 —— 项目搭建及登录与表单校验、token 管理、路由鉴权实现

项目搭建 创建项目 # 使用npx创建项目 npx create-react-app my-react-app # 进入项目目录 cd my-react-app # 创建项目目录结构 mkdir -p src/{apis,assets,components,pages,store,utils} touch src/{App.js,index.css,index.js} 使用npx create-react-app创建项目&#xff0…

苹果盛宴:iPhone 16系列领衔,智能穿戴新潮流来袭

在科技界备受瞩目的苹果秋季发布会上&#xff0c;众多新品悉数亮相&#xff0c;从全新的Apple Watch系列到AirPods系列&#xff0c;再到备受期待的iPhone 16系列&#xff0c;每一款产品都以其独特的创新和卓越的性能&#xff0c;再次定义了智能设备的高标准。 本文将带您领略这…

Yolov11项目实战1:道路缺陷检测系统设计【Python源码+数据集+运行演示】

一、项目背景 随着城市化进程的加速和交通网络的不断扩展&#xff0c;道路维护成为城市管理中的一个重要环节。道路缺陷&#xff08;如裂缝、坑洞、路面破损等&#xff09;不仅影响行车安全&#xff0c;还会增加车辆的磨损和维修成本。传统的道路缺陷检测方法主要依赖人工巡检…

ACT调试pycharm报错

在运行ACT 代码时&#xff0c;根据官方readme使用命令行需要在wandb选择的时候输入3 但是&#xff0c;使用pycharm运行的时候会报错 wandb.errors.UsageError: api_key not configured (no-tty). call wandb.login(key[your_api_key]) 网上搜索都是说要注册什么key&#xf…