在FAQ中给出加载量化版本失败的原因和解决方案

This commit is contained in:
hzg0601 2023-07-14 13:45:07 +08:00
parent f68d347c25
commit 3d082bf566
1 changed files with 17 additions and 0 deletions

View File

@ -177,3 +177,20 @@ download_with_progressbar(url, tmp_path)
Q14 调用api中的 `bing_search_chat`接口时,报出 `Failed to establish a new connection: [Errno 110] Connection timed out`
这是因为服务器加了防火墙需要联系管理员加白名单如果公司的服务器的话就别想了GG--!
---
Q15 加载chatglm-6b-int8或chatglm-6b-int4抛出`RuntimeError: Only Tensors of floating point andcomplex dtype can require gradients`
疑为chatglm的quantization的问题或torch版本差异问题针对已经变为Parameter的torch.zeros矩阵也执行Parameter操作从而抛出`RuntimeError: Only Tensors of floating point andcomplex dtype can require gradients`。解决办法是在chatglm-项目的原始文件中的quantization.py文件374行改为
```
try:
self.weight =Parameter(self.weight.to(kwargs["device"]), requires_grad=False)
except Exception as e:
pass
```
虽然模型可以顺利加载但在cpu上仍存在推理失败的可能即针对每个问题模型一直输出gugugugu。
因此最好不要试图用cpu加载量化模型原因可能是目前python主流量化包的量化操作是在gpu上执行的,会天然地存在gap。