您现在的位置是:首页 > 技术教程 正文

text-generation-Webui-AI本地部署踩坑记录

admin 阅读: 2024-04-01
后台-插件-广告管理-内容页头部广告(手机)

准备工作

  1. 下载源码
    text-generation-Webui

  2. 下载模型
    chinese-alpaca-2-7b-hf下载完成的模型需要放置在项目下的models目录下在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

  3. 安装conda
    Free Download | Anaconda

  4. 安装python
    ​ python

  5. 设置环境变量
    在这里插入图片描述

  6. 下载最新的显卡驱动

英伟达2060显卡驱动需要与自己显卡匹配

  • 查看显卡驱动版本

在这里插入图片描述

部署工作

  1. 创建conda环境
conda create -n textgen python=3.10.9
  • 1
  1. 初始化
conda init
  • 1
  1. 激活
conda activate textgen
  • 1
  1. 安装pytorch注意此处安装的版本需要与显卡对应否则会报各种错误
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu121/torch_stable.html
  • 1

cu121表示对应显卡版本12,可以从官网查看,这个很关键

在这里插入图片描述

  1. 安装项目的依赖
pip install -r requirements.txt
  • 1
  1. 加载模型并启动
python server.py --model chinese-alpaca-2-7b --chat
  • 1
  1. 加载成功后显示

在这里插入图片描述

  1. 打开浏览器输入对应的地址

在这里插入图片描述
9. 设置模型参数

在这里插入图片描述

踩坑记录

  1. ‘conda’ 不是内部或外部命令,也不是可运行的程序 或批处理文件。

    没有安装conda导致,且需要配置环境变量

  2. 版本太高

    Channels: - defaults Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - python=3.12.1* Current channels: - defaults To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page.
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    这个错误是因为在当前Conda默认的渠道(defaults)中找不到名为 python且版本为3.12.1 的包。这可能是因为3.12.1版本的Python还没有被添加到默认的Conda渠道中。

  3. conda需要先初始化

User F:\AI\text-generation-webui-main>conda activate textgen CondaError: Run 'conda init' before 'conda activate' F:\AI\text-generation-webui-main>conda activate textgen CondaError: Run 'conda init' before 'conda activate'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

执行 conda init命令

  1. 执行 conda init 命令后无法激活
User F:\AI\text-generation-webui-main>conda init no change D:\ProgramData\miniconda3\Scripts\conda.exe no change D:\ProgramData\miniconda3\Scripts\conda-env.exe no change D:\ProgramData\miniconda3\Scripts\conda-script.py no change D:\ProgramData\miniconda3\Scripts\conda-env-script.py no change D:\ProgramData\miniconda3\condabin\conda.bat no change D:\ProgramData\miniconda3\Library\bin\conda.bat no change D:\ProgramData\miniconda3\condabin\_conda_activate.bat no change D:\ProgramData\miniconda3\condabin\rename_tmp.bat no change D:\ProgramData\miniconda3\condabin\conda_auto_activate.bat no change D:\ProgramData\miniconda3\condabin\conda_hook.bat no change D:\ProgramData\miniconda3\Scripts\activate.bat no change D:\ProgramData\miniconda3\condabin\activate.bat no change D:\ProgramData\miniconda3\condabin\deactivate.bat modified D:\ProgramData\miniconda3\Scripts\activate modified D:\ProgramData\miniconda3\Scripts\deactivate modified D:\ProgramData\miniconda3\etc\profile.d\conda.sh modified D:\ProgramData\miniconda3\etc\fish\conf.d\conda.fish no change D:\ProgramData\miniconda3\shell\condabin\Conda.psm1 modified D:\ProgramData\miniconda3\shell\condabin\conda-hook.ps1 no change D:\ProgramData\miniconda3\Lib\site-packages\xontrib\conda.xsh modified D:\ProgramData\miniconda3\etc\profile.d\conda.csh modified C:\Users\li132\Documents\WindowsPowerShell\profile.ps1 modified HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun ==> For changes to take effect, close and re-open your current shell. <== F:\AI\text-generation-webui-main>conda activate textgen CondaError: Run 'conda init' before 'conda activate' F:\AI\text-generation-webui-main>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

请按照指示关闭当前的命令提示符或PowerShell窗口。然后重新打开一个新窗口,并尝试再次激活你的Conda环境:

  1. 目录名称无效
Building wheels for collected packages: hqq, rouge-score, ffmpy, sqlitedict ERROR: Error [WinError 267] 目录名称无效。 while executing command python setup.py bdist_wheel Building wheel for hqq (setup.py) ... error ERROR: Failed building wheel for hqq Running setup.py clean for hqq ERROR: Error [WinError 267] 目录名称无效。 while executing command python setup.py clean ERROR: Failed cleaning build dir for hqq ERROR: Error [WinError 267] 目录名称无效。 while executing command python setup.py bdist_wheel Building wheel for rouge-score (setup.py) ... error ERROR: Failed building wheel for rouge-score Running setup.py clean for rouge-score ERROR: Error [WinError 267] 目录名称无效。 while executing command python setup.py clean ERROR: Failed cleaning build dir for rouge-score Building wheel for ffmpy (setup.py) ... done Created wheel for ffmpy: filename=UNKNOWN-0.0.0-py3-none-any.whl size=929 sha256=c39123b3685649e5c5b9257c5604bff8e38ba7fd93f903cde779483dde2b9e3c Stored in directory: c:\users\li132\appdata\local\pip\cache\wheels\01\a6\d1\1c0828c304a4283b2c1639a09ad86f83d7c487ef34c6b4a1bf WARNING: Built wheel for ffmpy is invalid: Wheel has unexpected file name: expected 'ffmpy', got 'UNKNOWN' ERROR: Error [WinError 267] 目录名称无效。 while executing command python setup.py bdist_wheel Building wheel for sqlitedict (setup.py) ... error ERROR: Failed building wheel for sqlitedict Running setup.py clean for sqlitedict ERROR: Error [WinError 267] 目录名称无效。 while executing command python setup.py clean ERROR: Failed cleaning build dir for sqlitedict Failed to build hqq rouge-score ffmpy sqlitedict ERROR: Could not build wheels for hqq, rouge-score, ffmpy, sqlitedict, which is required to install pyproject.toml-based projects
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

不要用cmd ,用Powershell

  1. 加载模型名称错误

在这里插入图片描述

拼写正确即可

  1. 安装了错误的torch,不支持gpu计算

在这里插入图片描述

运行 python -c "impot torch;print(torch.cuda.is_available()) 判断返回值,false表示不支持,true表示支持,卸载重装"

在这里插入图片描述

  1. 前方高能,这里有个大坑
    在这里插入图片描述

之前看其他博主安装时通过start_windows.bat 安装,网页启动后加载模型然后报 ExLlama这个模块找不到的错误,于是乎看到国内的Gitee上的项目说exllama需要安装微软的编译器环境及英伟达的CUDA驱动(这个驱动安装包3G),按照操作走流程。最终还是找不到这个模块,于是放弃了,采用conda的方式进行安装,安装的时候CUDA驱动一直没有删除,直到看到这里

在这里插入图片描述

通过mvcc -version 命令查看显卡CUDA驱动版本11.8,下载了对应的torch版本对应的为11.8

在这里插入图片描述

该版本的torch显示支持显卡驱动了,启动报错显示找不到模块。

在这里插入图片描述
说明11.8的torch与CUDA 11.8 不匹配。卸载了11.8的torch和删除了CUDA驱动,后重写安装。torch用官网的12.1 ,驱动下载最新的12(600MB)再次启动才成功。

  • 卸载

在这里插入图片描述

  • 安装12.1torch

在这里插入图片描述

  • 此时CUDA驱动(3GB)还没有卸载,安装了最新的torch启动报错提示版本低

在这里插入图片描述

  • 从官网下载通用版的驱动(600MB)后再次执行,启动成功!
    在这里插入图片描述
    参考文献:(https://bbs.huaweicloud.com/blogs/412544)
标签:
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

在线投稿:投稿 站长QQ:1888636

后台-插件-广告管理-内容页尾部广告(手机)
关注我们

扫一扫关注我们,了解最新精彩内容

搜索