Windows10 Langchain-Chatchat 本地部署+常见问题解决+避坑指南(从0开始部署,附带全部模型安装包)

一、环境要求

1.安装 Anaconda (自行搜索,比较简单)
2.安装CUDA(先别急着下载最新的,下面有讲解)
3.python 3.8 - 3.11

二、安装流程

1.更新Conda

1.1 点击“开始”-打开Anaconda Powershell Prompt

打开Anaconda Powershell Prompt

1.2 更新conda

conda update conda

1.3 测试是否安装成功

conda list

安装成功

2.创建虚拟环境

2.1 创建虚拟环境

conda create -n Chatchat python==3.10

2.2 激活虚拟环境

conda activate Chatchat

3.下载Langchain-Chatchat

3.1 创建目录(还是在Anaconda Powershell Prompt里面执行)

md C:\Chatchat

3.2 进入目录

cd C:\Chatchat

在这里插入图片描述

3.3 下载Langchain-Chatchat代码

git clone https://github.com/chatchat-space/Langchain-Chatchat

这里也可以去官网(https://github.com/chatchat-space/Langchain-Chatchat)下载压缩包,然后解压到此目录
下载压缩包

我当时下载的文件:
Langchain-chatchat:百度网盘:https://pan.baidu.com/s/1rdiwt-9LYgT-ruHAqQnPIQ 提取码:hxy3

4.下载 LLM模型 和 Embedding 模型

4.1下载模型

这里可以去GitHub官网去按照教程下载:https://github.com/chatchat-space/Langchain-Chatchat
在这里插入图片描述
下面提供官网下载命令(需要代理)

THUDM/chatglm2-6b 模型:git clone https://huggingface.co/THUDM/chatglm2-6b
moka-ai/m3e-base 模型:git clone https://huggingface.co/moka-ai/m3e-base

也可以用我下载好的模型,我使用的是chatGLM2-6Bm3e-base模型
chatGLM2-6B:百度网盘:https://pan.baidu.com/s/1-7mdpLB85RHGjhpOrcmCCQ 提取码:qscm
m3e-base:百度网盘:https://pan.baidu.com/s/1XhJj1zFoMUrg0eM7TETgWg 提取码:5rlq
       阿里云盘:https://www.alipan.com/s/N3jgjuAuaKU 提取码: xf23

4.2内容修改

conda进入目录,执行

python copy_config_example.py

执行完上面语句之后,config目录变成下面样子
在这里插入图片描述
在model_config.py文件里面检索‘bge-large-zh’,'chatglm3-6m’替换成自己的api或者本地路径,换成本地路径时不要带中文,之后运行会报错
在这里插入图片描述
路径前面要加一个“r”
在这里插入图片描述
注释这俩个文件的里面的 jq (最新下载文件已经注释了,如果没注释就注释一下)
在这里插入图片描述
在这里插入图片描述

4.3下载依赖

依次执行下面三个语句,这里最好开一下代理(要确定自己的可以正常访问GitHub)

pip install -r requirements.txt
pip install -r requirements_api.txt
pip install -r requirements_webui.txt

安装pytorch(调用GPU) 这里版本一定要CUDA和python版本一致,否则大概率报错,这里的坑很多,好多教程就是提一句要python对应,其实CUDA也需要对应,自己踩了很多次才总结出来的。

先下载CUDA版本(别下载最新的,可能没有对应pytorch):https://developer.nvidia.com/cuda-toolkit-archive

下载成功后执行 nvcc -V 来查看cuda版本
cuda版本
这是我下载的CUDA(117)可以直接用,但是最好去官网下载
cu117:百度网盘:https://pan.baidu.com/s/1ZJJ7cUuHM6d8_JGkSFx5Ag 提取码:zgy4
      阿里云盘:https://www.alipan.com/s/NW491JWjBq8 提取码: 0mn6

查看python版本,这里去到自己conda创建的环境里面查看,执行 python 查看版本
python

这里我就是下载cu(cuda)是117,cp(python)是311的window文件
下载网址:https://download.pytorch.org/whl/torch_stable.html

在这里插入图片描述
把下载的文件放到目录下,执行

pip install torch-2.0.0+cu117-cp311-cp311-win_amd64.whl

这是我下载的cu117+cp311,如果和我版本一致,也可以直接用:
cu117+cp311:百度网盘:链接:https://pan.baidu.com/s/1bhbniNKOTDEjg_jrsHv9bA 提取码:svyh
附带给一个cu117+cp310版本的文件
cu117+cp310:百度网盘:链接:https://pan.baidu.com/s/1zfACKmj5DanI_zFUpeIVLg 提取码:qfxw

5.初始化数据库

python init_database.py --recreate-vs

可能遇到报错:ModuleNotFoundError: No module named ‘pwd‘
解决方法:https://blog.csdn.net/good_good_study5/article/details/136977435

6.运行web页面

python init_database.py -a

容易错误1:运行途中报错:OSError: Unable to load vocabulary from file. Please check that the provided vocabulary is accessible and not corrupted.
解决方法:https://blog.csdn.net/good_good_study5/article/details/136978019

容易错误2:运行中途报错:AttributeError: ‘ChatGLMTokenizer‘ object has no attribute ‘tokenizer‘
解决方法:https://blog.csdn.net/good_good_study5/article/details/136978109

容易错误3:AssertionError: Torch not compiled with CUDA enabled
导致原因: 1.安装的CUDA和安装的pytorch的版本不相互对应
2.没有安装GPU版本的pytorch
在conda目录下,运行 pip list 看tourch版本后面有没有“+cu”,没有就运行 pip uninstall torch 卸载,参考上面教程重新安装torch
在这里插入图片描述

容易错误4:RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx
导致原因:1.没安装显卡驱动 -------->>>> 安装显卡驱动
2.GPU虚拟化报错了 -------->>>> 重新配置一下

容易错误5:is not a supported wheel on this platform
导致原因: 1.安装的CUDA和安装的pytorch的版本不相互对应-------->>>> 参考上面教程重新安装torch

容易错误6:ModuleNotFoundError: No module named 'streamlit.cli
最后运行是这样的,导致进不去web页面
在这里插入图片描述
解决方法:去提示的路径里面修改成这样,把第6行注释,改写成第7行
在这里插入图片描述

7.打开页面

在这里插入图片描述
基本上到这里就部署完成了。

三、常见问题汇总

报错:ModuleNotFoundError: No module named ‘pwd‘
解决方法:https://blog.csdn.net/good_good_study5/article/details/136977435

报错:OSError: Unable to load vocabulary from file. Please check that the provided vocabulary is accessible and not corrupted.
解决方法:https://blog.csdn.net/good_good_study5/article/details/136978019

报错:AttributeError: ‘ChatGLMTokenizer‘ object has no attribute ‘tokenizer‘
解决方法:https://blog.csdn.net/good_good_study5/article/details/136978109

报错:AssertionError: Torch not compiled with CUDA enabled
导致原因: 1.安装的CUDA和安装的pytorch的版本不相互对应
2.没有安装GPU版本的pytorch
在conda目录下,运行 pip list 看tourch版本后面有没有“+cu”,没有就运行 pip uninstall torch 卸载,参考上面教程重新安装torch

报错:is not a supported wheel on this platform
导致原因: 1.安装的CUDA和安装的pytorch的版本不相互对应-------->>>> 参考上面教程重新安装torch

报错:ModuleNotFoundError: No module named 'streamlit.cli
解决方法:参考上面方法解决



创作不易,感谢观看,如果有用请点赞评论支持一下。
  • 34
    点赞
  • 48
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值