auto-gptq安装以及不适配软硬件环境可能出现的问题及解决方式

目录

1、auto-gptq是什么?

Auto-GPTQ 是一种专注于 量化深度学习模型 的工具库。它的主要目标是通过量化技术(Quantization)将大型语言模型(LLM)等深度学习模型的大小和计算复杂度显著减少,从而提高推理效率,同时尽可能保持模型的性能。

2、auto-gptq安装

在Linux和Windows上,AutoGPTQ可以通过预先构建的轮子为特定的PyTorch版本安装:

AutoGPTQ version CUDA/ROCm version Installation Built against PyTorch
latest (0.7.1) CUDA 11.8 pip install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ 2.2.1+cu118
latest (0.7.1) CUDA 12.1 pip install auto-gptq 2.2.1+cu121
latest (0.7.1) ROCm 5.7 pip install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/rocm571/ 2.2.1+rocm5.7
0.7.0 CUDA 11.8 pip install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ 2.2.0+cu118
0.7.0 CUDA 12.1 pip install auto-gptq 2.2.0+cu121
0.7.0 ROCm 5.7 pip install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/rocm571/ 2.2.0+rocm5.7
0.6.0 CUDA 11.8 pip install auto-gptq==0.6.0 --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ 2.1.1+cu118
0.6.0 CUDA 12.1 pip install auto-gptq==0.6.0 2.1.1+cu121
0.6.0 ROCm 5.6 pip install auto-gptq==0.6.0 --extra-index-url https://huggingface.github.io/autogptq-index/whl/rocm561/ 2.1.1+rocm5.6
0.5.1 CUDA 11.8 pip install auto-gptq==0.5.1 --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ 2.1.0+cu118
0.5.1 CUDA 12.1 pip install auto-gptq==0.5.1 2.1.0+cu121
0.5.1 ROCm 5.6 pip install auto-gptq==0.5.1 --extra-index-url https://huggingface.github.io/autogptq-index/whl/rocm561/ 2.1.0+rocm5.6

AutoGPTQ is not available on macOS.
注意:安装的auto-gptq版本必须与CUDA和pytorch版本都适配,安装完之后推理速度很慢可能是需要从源码安装

3、auto-gptq不正确安装可能会出现的问题

(1)爆出:CUDA extension not installed.

这个问题我一直以为是CUDA和pytorch没配置好,或者不适配硬件,甚至以为是没有安装cudnn的原因,但最后发现原来是安装的auto-gptq不适配当下环境。

注意按照上面的方法安装auto-gptq仍然可能报错或者不适配,此时应该从源码安装,可以参考教程AutoGPTQ/README_zh.md at main · AutoGPTQ/AutoGPTQ,或者解决 GPTQ 模型导入后推理生成 Tokens 速度很慢的问题(从源码重新安装 Auto-GPTQ)_auto gptq 源码构建非cuda版本-CSDN博客

以下摘自官方文档

克隆源码:

git clone https://github.com/PanQiWei/AutoGPTQ.git && cd AutoGPTQ

然后,从项目目录安装:

pip install .

正如在快速安装一节,你可以使用 BUILD_CUDA_EXT=0 来取消构建 cuda 拓展。

如果你想要使用 triton 加速且其能够被你的操作系统所支持,请使用 .[triton]

对应 AMD GPUs,为了从源码安装以支持 RoCm,请设置 ROCM_VERSION 环境变量。同时通过设置
PYTORCH_ROCM_ARCH

(reference)

可提升编译速度,例如:对于 MI200 系列设备,该变量可设为 gfx90a。例子:

ROCM_VERSION=5.6 pip install .

对于 RoCm 系统,在从源码安装时额外需要提前安装以下包:rocsparse-dev, hipsparse-dev,
rocthrust-dev, rocblas-dev and hipblas-dev

(2)没有报错但是推理速度超级慢

此时查看auto-gptq版本,如果版本后没有带cu1xx,则可能是需要从源码安装

相关推荐
InternLM6 小时前
基于InternLM的情感调节大师FunGPT
大模型·大语言模型·大模型应用·书生
sg_knight7 小时前
大模型连接万物的“万能插座”:深度解析模型上下文协议MCP
人工智能·ai·大模型·agent·ai大模型·mcp·模型上下文协议
audyxiao00112 小时前
数据挖掘顶刊《IEEE Transactions on Knowledge and Data Engineering》2025年5月研究热点都有些什么?
大数据·人工智能·数据挖掘·大模型·图技术·智能体·时序动态建模
无风听海1 天前
Milvus单机模式安装和试用
大模型·llm·milvus·向量数据库
Tadas-Gao1 天前
从 GPT 的发展看大模型的演进
人工智能·gpt·机器学习·大模型·llm
cooldream20091 天前
华为云Flexus+DeepSeek征文|利用华为云 Flexus 云服务一键部署 Dify 平台开发文本转语音助手全流程实践
大模型·华为云·dify
cooldream20091 天前
华为云Flexus+DeepSeek征文|华为云 Flexus X 加速 Dify 平台落地:高性能、低成本、强可靠性的云上选择
大模型·华为云·dify·deepseek
中杯可乐多加冰2 天前
采用Bright Data+n8n+AI打造自动化新闻助手:每天5分钟实现内容日更
运维·人工智能·自动化·大模型·aigc·n8n
AI大模型系统化学习2 天前
AI产品风向标:从「工具属性」到「认知引擎」的架构跃迁
大数据·人工智能·ai·架构·大模型·ai大模型·大模型学习
汪汪汪侠客2 天前
源码解析(一):GraphRAG
算法·面试·大模型·rag·graphrag