跳到主要内容
极客日志极客日志面向AI+效率的开发者社区
首页博客GitHub 精选镜像AI 生图工具UI配色美学隐私政策关于联系
搜索内容 / 工具 / 仓库 / 镜像...⌘K搜索
注册
博客列表
PythonAI算法

DCU BW1000 使用 llama.cpp 推理 Qwen3-Coder-30B 模型失败记录

记录了在 DCU BW1000 环境下尝试使用 llama.cpp 和 transformers 库推理 Qwen3-Coder-30B-A3B-Instruct-AWQ 模型的过程。通过 llmfit 分析模型资源需求后,安装 llama.cpp 遇到共享库加载问题,修正环境变量后解决。模型下载阶段发现指定路径模型文件缺失。使用 transformers 推理时因 AWQ 量化需要 gptqmodel 依赖,但该库在当前环境中无法通过 pip 或 conda 安装,导致推理失败。最终结论为环境兼容性不足,暂时搁置。

协议工匠发布于 2026/4/5更新于 2026/7/2153 浏览

使用 llmfit 查看模型情况

llmfit info stelterlab/Qwen3-Coder-30B-A3B-Instruct-AWQ

=== stelterlab/Qwen3-Coder-30B-A3B-Instruct-AWQ ===
Provider: stelterlab
Parameters: 4.6B
Quantization: Q4_K_M
Best Quant: Q8_0
Context Length: 262144 tokens
Use Case: Code generation and completion
Category: Coding
Released: 2025-07-31
Runtime: llama.cpp (est. ~17.2 tok/s)

Score Breakdown:
  Overall Score: 66.7 / 100
  Quality: 68  Speed: 43  Fit: 61  Context: 100
  Estimated Speed: 17.2 tok/s

Resource Requirements:
  Min VRAM: 2.4 GB
  Min RAM: 2.6 GB (CPU inference)
  Recommended RAM: 4.3 


         
         


    
   
       


       
       
      
   
    
GB
MoE Architecture:
Experts:
8
active
/
128
total
per
token
Active VRAM:
0.5
GB
(vs
2.4
GB
full
model)
Fit Analysis:
Status:
🟡
Good
Run Mode:
CPU+GPU
Memory Utilization:
0.6
%
(2.6
/
405.5
GB)
Notes:
MoE:
insufficient
VRAM
for
expert
offloading
Spilling
entire
model
to
system
RAM
Performance
will
be
significantly
reduced
Best quantization for hardware: Q8_0 (model default:
Q4_K_M)
Estimated speed:
17.2
tok/s

安装 llama.cpp

下载 llama.cpp 源代码

git clone https://gitcode.com/GitHub_Trending/ll/llama.cpp

编译 llama.cpp

cd llama.cpp cmake -B build cmake --build build --config Release

加入路径

export PATH=/root/llama.cpp/build/bin:$PATH

或者也可以直接使用 make install

cd build make install 

但是安装好后报错

root@crdnotebook-2027598444851879937-denglf-12859:~/llama.cpp/build# llama-cli
llama-cli: error while loading shared libraries: libmtmd.so.0: cannot open shared object file: No such file or directory
root@crdnotebook-2027598444851879937-denglf-12859:~/llama.cpp/build# llama-gguf
llama-gguf: error while loading shared libraries: libggml-base.so.0: cannot open shared object file: No such file or directory

原来是没有把路径加入的缘故,加入路径后问题解决:

export PATH=/root/llama.cpp/build/bin:$PATH

模型下载

安装 modelscope

pip install modelscope

下载

from modelscope import snapshot_download
snapshot_download('tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ', cache_dir="models")

推理

用 llama-cli 推理
llama-cli -m models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ

报错:

root@crdnotebook-2027598444851879937-denglf-12859:~# llama-cli -m models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ
Loading model... |gguf_init_from_file_impl: failed to read magic
llama_model_load: error loading model: llama_model_loader: failed to load model from models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ
llama_model_load_from_file_impl: failed to load model
llama_params_fit: encountered an error while trying to fit params to free device memory: failed to load model
gguf_init_from_file_impl: failed to read magic
llama_model_load: error loading model: llama_model_loader: failed to load model from models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ
llama_model_load_from_file_impl: failed to load model
common_init_from_params: failed to load model 'models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ'
srv    load_model: failed to load model, 'models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ'

Failed to load the model

检查发现模型路径应为:stelterlab/Qwen3-Coder-30B-A3B-Instruct-AWQ。问题是该模型在指定仓库中不存在。

尝试用 transformers 推理
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "/root/models/tclf90/Qwen3-Coder-30B-A3B-Instruct-AWQ"
# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name, torch_dtype="auto", device_map="auto"
)
# prepare the model input
prompt = "Write a quick sort algorithm."
messages = [
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
# conduct text completion
generated_ids = model.generate(
    **model_inputs, max_new_tokens=65536
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
content = tokenizer.decode(output_ids, skip_special_tokens=True)
print("content:", content)

也是失败

File /opt/conda/lib/python3.10/site-packages/transformers/quantizers/quantizer_awq.py:48, in AwqQuantizer.validate_environment(self, **kwargs)
46 def validate_environment(self, **kwargs):
47 if not is_gptqmodel_available():
---> 48 raise ImportError(
49     "Loading an AWQ quantized model requires gptqmodel. Please install it with `pip install gptqmodel`"
50 )
52 if not is_accelerate_available():
53 raise ImportError("Loading an AWQ quantized model requires accelerate (`pip install accelerate`)")
ImportError: Loading an AWQ quantized model requires gptqmodel. Please install it with `pip install gptqmodel`

总结

未调通,暂时搁置。

llama.cpp 是因为指定仓库没有那个模型,导致模型不匹配。 transformers 是因为库的问题,需要重新安装 torch 等库,导致需要的库无法安装上,推理失败。

调试

报错 ImportError: Loading an AWQ quantized model requires gptqmodel.

File /opt/conda/lib/python3.10/site-packages/transformers/quantizers/quantizer_awq.py:48, in AwqQuantizer.validate_environment(self, **kwargs) 46 def validate_environment(self, **kwargs): 47 if not is_gptqmodel_available(): ---> 48 raise ImportError( 49 "Loading an AWQ quantized model requires gptqmodel. Please install it with pip install gptqmodel" 50 ) 52 if not is_accelerate_available(): 53 raise ImportError("Loading an AWQ quantized model requires accelerate (pip install accelerate)") ImportError: Loading an AWQ quantized model requires gptqmodel. Please install it with pip install gptqmodel

安装提示执行

pip install gptqmodel

安装失败,

Exception: Unable to detect torch version via uv/pip/conda/importlib. Please install torch >= 2.7.1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed to build 'gptqmodel' when getting requirements to build wheel

用 conda 试试

conda install gptqmodel

也失败了。

PackagesNotFoundError: The following packages are not available from current channels:

  • gptqmodel

目录

  1. 使用 llmfit 查看模型情况
  2. 安装 llama.cpp
  3. 模型下载
  4. 推理
  5. 用 llama-cli 推理
  6. 尝试用 transformers 推理
  7. load the tokenizer and the model
  8. prepare the model input
  9. conduct text completion
  10. 总结
  11. 调试
  12. 报错 ImportError: Loading an AWQ quantized model requires gptqmodel.
  • 免费图片AI生成工具免费生成了解详情
  • Magick API 一键接入全球大模型注册送1000万token查看
  • 免费图片视频在线生成30秒,将你的创意变成现实开始设计
  • X/Twitter免费视频下载器免登陆无限额度免费视频解析下载了解详情
  • 100+免费在线小游戏爽一把
极客日志微信公众号二维码

微信扫一扫,关注极客日志

微信公众号「极客日志V2」,在微信中扫描左侧二维码关注。展示文案:极客日志V2 zeeklog

更多推荐文章

查看全部
  • 中国网络安全领域十大先驱人物回顾
  • 使用 Mergekit 扩展 Llama 3 至百万级上下文长度兼容微调版本
  • 从 MVP 到千万级并发:AI 在前后端开发中的差异化落地指南
  • Qwen3-4B 极速文本对话:搭建 AI 写作助手
  • HarmonyOS 6.0 分布式应用实战:多端协同办公工具开发
  • GitHub Copilot Pro 学生身份认证与配置指南
  • 微信朋友圈批量发送与自动同步工具使用指南
  • Verilog 零基础入门:语法、仿真与 FPGA 实战
  • 大语言模型原理必读的 10 篇论文
  • SpringAI Agent 开发实战:利用 Skills 构建代码评审工具
  • Git 疑难问题诊疗指南
  • 国内 8 个利用 AI 技能变现的在线兼职渠道
  • C++ 面向对象核心:多态详解
  • C 语言 Web 开发实战:CGI、FastCGI 与 Nginx 模块详解
  • 基于 YOLOv11/v8 与 PaddleOCR 的车牌识别系统实战
  • 华为 OD 机试算法题:矩阵扩散
  • FAIR plus 机器人全产业链接会:链动全球智能新机遇
  • GitHub Copilot 接入 Claude Code 本地技能的自动化映射方案
  • 基于 Q-Learning 的无人机三维动态避障路径规划(Matlab 实现)
  • OpenJDK HotSpot 虚拟机中 debug_zero.cpp 的实现与作用分析

相关免费在线工具

  • 加密/解密文本

    使用加密算法(如AES、TripleDES、Rabbit或RC4)加密和解密文本明文。 在线工具,加密/解密文本在线工具,online

  • RSA密钥对生成器

    生成新的随机RSA私钥和公钥pem证书。 在线工具,RSA密钥对生成器在线工具,online

  • Mermaid 预览与可视化编辑

    基于 Mermaid.js 实时预览流程图、时序图等图表,支持源码编辑与即时渲染。 在线工具,Mermaid 预览与可视化编辑在线工具,online

  • 随机西班牙地址生成器

    随机生成西班牙地址(支持马德里、加泰罗尼亚、安达卢西亚、瓦伦西亚筛选),支持数量快捷选择、显示全部与下载。 在线工具,随机西班牙地址生成器在线工具,online

  • Gemini 图片去水印

    基于开源反向 Alpha 混合算法去除 Gemini/Nano Banana 图片水印,支持批量处理与下载。 在线工具,Gemini 图片去水印在线工具,online

  • curl 转代码

    解析常见 curl 参数并生成 fetch、axios、PHP curl 或 Python requests 示例代码。 在线工具,curl 转代码在线工具,online