首页 > 系统相关 >LangChain-Chatchat学习资料-Windows开发部署(踩坑篇)

LangChain-Chatchat学习资料-Windows开发部署(踩坑篇)

时间:2023-08-25 14:12:44浏览次数:65  
标签:25 26 Windows 08 LangChain 52 Chatchat stderr ERROR

LangChain-Chatchat学习资料-Windows开发部署(踩坑篇)

环境准备的坑

1.CUDA版本问题

我是用的RTX3060显卡,通过nvidia-smi命令,查看显卡支持的CUDA版本为12.2,然后下载版本的CUDA,后续发现这里是个坑,pytorch目前最新版为2.0.1,支持的cuda版本最高为11.8,所以想使用显卡跑pytorch,需要讲CUDA降到11.8版本。具体情况可查看pytorch的官网介绍

2.Python依赖包问题

1.依赖包安装不全
使用官方提供的requirements.txt进行依赖包安装,会出现包安装不完整的问题,需要根据后续服务启动报错,按照报错情况安装相对应的依赖包。
image

pip install accelerate

2.pytorch默认安装为CPU版本
如果想用GPU进行推理运算,需要安装pytorch的CUDA版本,使用官方提供的requirements.txt安装,只会安装CPU版本,后续运行起来非常慢。具体操作如下:

  • 首先按照pytorch官方推荐方式,安装pytorch==2.0.1+cu118版本
# CUDA 11.8
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
  • 再将requirements.txt中的torch~=2.0.0注释掉
#torch~=2.0.0
  • 在使用requirements.txt安装依赖包
pip install -r requirements.txt

配置文件的坑

chatglm-6b-int4的坑

在使用int4量化模型时,使用pytorch的cpu版本时正常,使用cuda版本时,发生以下报错。

点击查看代码
2023-08-25 13:52:26 | ERROR | stderr | Traceback (most recent call last):
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
2023-08-25 13:52:26 | ERROR | stderr |     result = await app(  # type: ignore[func-returns-value]
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     return await self.app(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\fastapi\applications.py", line 290, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     await super().__call__(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\applications.py", line 122, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     await self.middleware_stack(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     raise exc
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     await self.app(scope, receive, _send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     raise exc
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     await self.app(scope, receive, sender)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 20, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     raise e
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 17, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     await self.app(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\routing.py", line 718, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     await route.handle(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\routing.py", line 276, in handle
2023-08-25 13:52:26 | ERROR | stderr |     await self.app(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\routing.py", line 69, in app
2023-08-25 13:52:26 | ERROR | stderr |     await response(scope, receive, send)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\responses.py", line 270, in __call__
2023-08-25 13:52:26 | ERROR | stderr |     async with anyio.create_task_group() as task_group:
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\anyio\_backends\_asyncio.py", line 597, in __aexit__
2023-08-25 13:52:26 | ERROR | stderr |     raise exceptions[0]
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\responses.py", line 273, in wrap
2023-08-25 13:52:26 | ERROR | stderr |     await func()
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\responses.py", line 262, in stream_response
2023-08-25 13:52:26 | ERROR | stderr |     async for chunk in self.body_iterator:
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\concurrency.py", line 63, in iterate_in_threadpool
2023-08-25 13:52:26 | ERROR | stderr |     yield await anyio.to_thread.run_sync(_next, iterator)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
2023-08-25 13:52:26 | ERROR | stderr |     return await get_asynclib().run_sync_in_worker_thread(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
2023-08-25 13:52:26 | ERROR | stderr |     return await future
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
2023-08-25 13:52:26 | ERROR | stderr |     result = context.run(func, *args)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\starlette\concurrency.py", line 53, in _next
2023-08-25 13:52:26 | ERROR | stderr |     return next(iterator)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\fastchat\serve\model_worker.py", line 231, in generate_stream_gate
2023-08-25 13:52:26 | ERROR | stderr |     for output in self.generate_stream_func(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\utils\_contextlib.py", line 35, in generator_context
2023-08-25 13:52:26 | ERROR | stderr |     response = gen.send(None)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\fastchat\model\model_chatglm.py", line 71, in generate_stream_chatglm
2023-08-25 13:52:26 | ERROR | stderr |     for total_ids in model.stream_generate(**inputs, **gen_kwargs):
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\utils\_contextlib.py", line 35, in generator_context
2023-08-25 13:52:26 | ERROR | stderr |     response = gen.send(None)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\modeling_chatglm.py", line 1143, in stream_generate
2023-08-25 13:52:26 | ERROR | stderr |     outputs = self(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
2023-08-25 13:52:26 | ERROR | stderr |     return forward_call(*args, **kwargs)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\modeling_chatglm.py", line 932, in forward
2023-08-25 13:52:26 | ERROR | stderr |     transformer_outputs = self.transformer(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
2023-08-25 13:52:26 | ERROR | stderr |     return forward_call(*args, **kwargs)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\modeling_chatglm.py", line 828, in forward
2023-08-25 13:52:26 | ERROR | stderr |     hidden_states, presents, all_hidden_states, all_self_attentions = self.encoder(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
2023-08-25 13:52:26 | ERROR | stderr |     return forward_call(*args, **kwargs)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\modeling_chatglm.py", line 638, in forward
2023-08-25 13:52:26 | ERROR | stderr |     layer_ret = layer(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
2023-08-25 13:52:26 | ERROR | stderr |     return forward_call(*args, **kwargs)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\modeling_chatglm.py", line 542, in forward
2023-08-25 13:52:26 | ERROR | stderr |     attention_output, kv_cache = self.self_attention(
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
2023-08-25 13:52:26 | ERROR | stderr |     return forward_call(*args, **kwargs)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\modeling_chatglm.py", line 374, in forward
2023-08-25 13:52:26 | ERROR | stderr |     mixed_x_layer = self.query_key_value(hidden_states)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
2023-08-25 13:52:26 | ERROR | stderr |     return forward_call(*args, **kwargs)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization.py", line 502, in forward
2023-08-25 13:52:26 | ERROR | stderr |     output = W8A16Linear.apply(input, self.weight, self.weight_scale, self.weight_bit_width)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive\miniconda3\envs\Langchain-Chatchat\lib\site-packages\torch\autograd\function.py", line 506, in apply
2023-08-25 13:52:26 | ERROR | stderr |     return super().apply(*args, **kwargs)  # type: ignore[misc]
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization.py", line 75, in forward
2023-08-25 13:52:26 | ERROR | stderr |     weight = extract_weight_to_half(quant_w, scale_w, weight_bit_width)
2023-08-25 13:52:26 | ERROR | stderr |   File "C:\Users\vrive/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization.py", line 287, in extract_weight_to_half
2023-08-25 13:52:26 | ERROR | stderr |     func = kernels.int4WeightExtractionHalf
2023-08-25 13:52:26 | ERROR | stderr | AttributeError: 'NoneType' object has no attribute 'int4WeightExtractionHalf'

需要安装cpm_kernels包

pip install cpm_kernels

安装完毕后问题解决,可正常使用显卡继续推理计算。

标签:25,26,Windows,08,LangChain,52,Chatchat,stderr,ERROR
From: https://www.cnblogs.com/vriverh/p/17656463.html

相关文章

  • 如何在WindowsServer服务器上配置SQL Server数据库?
    作者:西瓜程序猿主页传送门:https://www.cnblogs.com/kimiliucn服务器版本:WindowsServer2016数据库版本:SQLServer2016当时买了一台WindowsServer服务器,然后安装上SQLServer后,想通过外网访问到数据库,遇到了一些问题,查了很多资料也踩了很多坑。本文主要介绍如何配置SQL......
  • Windows PC、 Linux、 Android、 iOS多平台支持H5无插件播放RTSP摄像机解决方案
    需求分析视频流媒体监控行业已经进入互联网时代,浏览器承载了绝大多数的互联网访问流量,目前在网页上播RTSP流的普遍做法是将RTSP转成互联网直播协议RTMP或者HLS;而RTMP协议播放需要Flash插件,且其衍生的FLV或者HLS协议延迟很大(2s以上),根本达不到视频流媒体传输低延迟的要求。早年风靡......
  • windows10下腾讯会议安装
    一、下载官网:腾讯会议官方——腾讯会议会开会(tencent.com)  根据自己操作系统选择版本,我选择windows 点击版本,会下载。 下载完成后,找到路径。  2、安装选择路径的安装包,右键,管理员身份运行。 默认:中文 选择我接受 可以修改安装目录,然后点击安装......
  • windows11 安装kabka客户端
    1、下载安装包http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html注意:根据32/64位操作系统下载对应的安装包2、点击新建系统变量:JAVA_HOME=C:\ProgramFiles\Java\jdk-1.8  截图   如图安装成功环境 1、下载安装包http:/......
  • LangChain-Chatchat学习资料-Windows开发部署
    在windows10下的安装部署参考资料1.LacnChain-Chatchat项目基础环境准备本人使用的是Windows10专业版22H2版本,已经安装了Python3.10,CUDA11.8版本,miniconda3。硬件采用联想R9000P,AMDR75800H,16G内存,RTX30606G。安装依赖#使用conda安装激活环境condacreate-nLangchain......
  • Windows 虚拟地址 到底是如何映射到 物理地址 的?
    一:背景1.讲故事我发现有很多的.NET程序员写了很多年的代码都没弄清楚什么是虚拟地址,更不用谈什么是物理地址以及Windows是如何实现地址映射的了?这一篇我们就来聊一聊这两者之间的联系。二:地址映射研究1.找虚拟地址怎么去找虚拟地址呢?相信很多朋友都知道应用程序用的......
  • windows wget与curl
     wget下载https://eternallybored.org/misc/wget/curl下载https://curl.se/download.html  ffmpet下载http://ffmpeg.org/......
  • Exceptionless系列:简介和部署(Windows、Linux、Docker)
    目录一、简介二、版本三、运行说明1、Exceptionless2、Elasticsearch3、Exceptionless.UI四、打包Exceptionless.UI五、window部署1.Elasticsearch2.Exceptionless六、Docker部署一、简介Exceptionless为您提供了跟踪错误、日志和事件的工具,同时指导您找到可行的解决方案。首先......
  • windows远程桌面到ubuntu16.04
    环境ubuntu:16.04windows:windows10目标让windows可以使用RemoteDesktop客记端远程到ubuntu16.04安装事宜windowns无需安装ubuntu16.04需要安装xrdp和xfce4安装sudoaptinstallxrdpxfce4查看安装版本,发现默认安装的是xrdp0.6.1修改配置sudoechoxfce4-sessi......
  • Windows Server2008R2 服务器Paged Pool占用过高的问题
    这台服务器一直运行的好好的,但最近发现经常内存占用了99%,重启后过几天内存又涨到99%。运行的应用软件占的内存并不高,任务管理器所有进程占用内存加起来也远远不到99%。下载了RamMap,发现是PagedPool占用了绝大多数的内存; 下载poolmon.exe,终端中运行poolmon.exe-p-b,再按下......