首次部署
本地部署
克隆项目到本地
独立下载模型到项目文件夹
{project_dir}/ChatGLM2-6B
中修改
./web_demo.py
# 原始
model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True)
# 我的1080ti 11G
model = (
AutoModel.from_pretrained("chatglm2-6b", trust_remote_code=True) # 这里修改成项目模型位置
.cuda()
.quantize(8)
.cuda()
)可能会遇到报错
Torch not compiled with CUDA enabled
这个报错说明当前系统还没安装nvdia的cuda模型依赖环境,或者当前使用的是cpu版本
# 卸载本地不合符的torch版本
pip uninstall torch
# 方案1 让pip重新下载gpu版的torch并自动安装
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
# 方案2 自己到pytorch的官方下载对应的版本的whl文件到本地安装
Pip install xxx.whl安装
下载模型
由于网络比较渣,所以通过度盘等其他途径将模型提前下载到了本地