You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已安装torch但无法安装auto-gptq,提示需先安装torch

安装auto-gptq时提示“torch未安装”但实际已安装的问题解决

问题描述

我尝试在本地安装auto-gptq时遇到以下错误:

Collecting auto-gptq
  Using cached auto_gptq-0.3.2.tar.gz (63 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 4294967295
  ╰─> [1 lines of output]
      torch is not installed, please install torch first!
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 4294967295
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

我已安装torch,执行安装命令时显示:

PS > C:\...\python.exe -m pip install torch        
Requirement already satisfied: torch in c:\... (2.0.1)
Requirement already satisfied: filelock in c:\... (from torch) (3.12.2)
Requirement already satisfied: typing-extensions in c:\... (from torch) (4.7.1)
Requirement already satisfied: sympy in c:\... (from torch) (1.12)
Requirement already satisfied: networkx in c:\... (from torch) (3.1)
Requirement already satisfied: jinja2 in c:\... (from torch) (3.1.2)
Requirement already satisfied: MarkupSafe>=2.0 in c:\... (from jinja2->torch) (2.1.3)
Requirement already satisfied: mpmath>=0.19 in c:\... (from sympy->torch) (1.3.0)

但仍出现上述错误,请问这是为什么?

可能的原因及解决方法

  • Python环境不匹配:安装auto-gptq时使用的Python环境,与安装torch的环境不一致。比如默认终端调用的是系统Python,但torch装在虚拟环境里。解决方式:激活torch所在的虚拟环境后再执行安装命令,或者直接用torch所在的Python解释器运行安装:

    C:\...\python.exe -m pip install auto-gptq
    

    替换路径为你实际的Python可执行文件路径。

  • 版本兼容性问题:auto-gptq 0.3.2对torch版本有特定要求,torch 2.0.1可能不在支持范围内。可以核对auto-gptq的版本兼容说明,要么升级/降级torch到兼容版本,要么安装对应兼容的auto-gptq版本。

  • pip缓存干扰:pip缓存可能导致依赖检测失效。先清除缓存再重新安装:

    pip cache purge
    

    之后再执行auto-gptq的安装命令。

  • CUDA依赖缺失:如果安装的是CPU版torch,但auto-gptq默认需要GPU版torch支持,也会触发该错误。确认安装的是带CUDA的torch版本,或者安装时指定auto-gptq的CPU兼容版本(如果官方支持)。

内容的提问来源于stack exchange,提问作者Daniel Burmester

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 00:37:42