ModuleNotFoundError: No module named ‘auto_gptq’

用户在 Windows 系统上使用 oobabooga TextGen WebUI 时,尝试加载 yarn-mistral-7b-128k.Q4_K_M.gguf 模型(GGUF 格式)后出现报错。用户下载的是 CPU 版本安装包,但模型加载过程中意外调用了 auto_gptq 模块,最终因找不到

ModuleNotFoundError: No module named 'auto_gptq'

ModuleNotFoundError: No module named ‘auto_gptq’

快速结论:该报错通常出现在用户下载了包含 AutoGPTQ 等额外依赖的模型(如 exl2/hf 格式),但只安装了 CPU 版 TextGen WebUI,导致缺少对应 Python 包。优先排查模型加载器是否选错或依赖未完整安装。

问题场景

用户在 Windows 系统上使用 oobabooga TextGen WebUI 时,尝试加载 yarn-mistral-7b-128k.Q4_K_M.gguf 模型(GGUF 格式)后出现报错。用户下载的是 CPU 版本安装包,但模型加载过程中意外调用了 auto_gptq 模块,最终因找不到 CUDA 路径而失败。

报错原文

ModuleNotFoundError: No module named 'auto_gptq'

File "E:\...\llama_cpp_cuda\__init__.py", line 1, in
    from .llama_cpp import *
File "E:\...\llama_cpp_cuda\llama_cpp.py", line 38, in
    _lib = load_shared_library(_lib_base_name, _base_path)
File "E:\...\llama_cpp_cuda\ctypes_extensions.py", line 56, in load_shared_library
    os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin"))
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'E:\...\bin'

原因分析

可能原因:用户将模型下载到错误的文件夹(如 exl2 或 hf 模型文件夹),导致 WebUI 自动选择了 AutoGPTQ 加载器(而非正确的 llama.cpp 加载器)。同时,由于用户安装的是 CPU 版本,缺少 CUDA 环境变量和 llama-cpp-python GPU 支持,引发连锁错误。

环境排查

  • 确认 TextGen WebUI 版本是否为 CPU-only 安装包。
  • 确认模型文件是否放置在正确的 models 子目录(例如 models/gguf 而非 models/exl2)。
  • 检查 Python 版本及 pip list 中是否包含 auto_gptq、llama-cpp-python、llama-cpp-cuda 等包。
  • 确认 CUDA_PATH 环境变量是否存在(对于 CPU-only 安装通常不需要)。

解决步骤

  1. 打开 TextGen WebUI 界面,在 Model 标签页的 “Model loader” 下拉菜单中,手动选择 llama.cppAutoGPTQ(如果模型格式不支持 GGUF,则使用 autogptq 加载器 —— 可优先尝试)。
  2. 如果手动切换加载器无效,将模型文件移动到 models/gguf 文件夹下,确保 WebUI 自动匹配正确的加载器。
  3. 若问题依旧,重新运行 CPU 版安装脚本(start_windows.bat 选择 CPU only 选项),确保所有依赖完整安装。安装完成后重启 WebUI 再试。

验证方法

成功加载模型后,在界面右侧输出区域看到 “Loaded the model in Y.YY seconds” 信息,且不再弹出 ModuleNotFoundError 或 FileNotFoundError 错误。可以正常进行对话测试。

参考来源

oobabooga/textgen #4602

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 9201

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注