准备工作
-
下载源码
text-generation-Webui -
下载模型
chinese-alpaca-2-7b-hf下载完成的模型需要放置在项目下的models目录下 -
安装conda
Free Download | Anaconda -
安装python
python -
设置环境变量
-
下载最新的显卡驱动
英伟达2060显卡驱动需要与自己显卡匹配
- 查看显卡驱动版本
部署工作
- 创建conda环境
conda create -n textgen python=3.10.9
- 初始化
conda init
- 激活
conda activate textgen
- 安装pytorch注意此处安装的版本需要与显卡对应否则会报各种错误
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu121/torch_stable.html
cu121表示对应显卡版本12,可以从官网查看,这个很关键
- 安装项目的依赖
pip install -r requirements.txt
- 加载模型并启动
python server.py --model chinese-alpaca-2-7b --chat
- 加载成功后显示
- 打开浏览器输入对应的地址
9. 设置模型参数
踩坑记录
-
‘conda’ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
没有安装conda导致,且需要配置环境变量
-
版本太高
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.
这个错误是因为在当前Conda默认的渠道(
defaults)中找不到名为
python且版本为
3.12.1的包。这可能是因为3.12.1版本的Python还没有被添加到默认的Conda渠道中。
-
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'
执行 conda init命令
- 执行 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>
请按照指示关闭当前的命令提示符或PowerShell窗口。然后重新打开一个新窗口,并尝试再次激活你的Conda环境:
- 目录名称无效
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
不要用cmd ,用Powershell
- 加载模型名称错误
拼写正确即可
- 安装了错误的torch,不支持gpu计算
运行 python -c "impot torch;print(torch.cuda.is_available()) 判断返回值,false表示不支持,true表示支持,卸载重装"
- 前方高能,这里有个大坑
之前看其他博主安装时通过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
文章来源:https://www.toymoban.com/news/detail-787819.html
- 此时CUDA驱动(3GB)还没有卸载,安装了最新的torch启动报错提示版本低
文章来源地址https://www.toymoban.com/news/detail-787819.html
- 从官网下载通用版的驱动(600MB)后再次执行,启动成功!
参考文献:(https://bbs.huaweicloud.com/blogs/412544)
到了这里,关于text-generation-Webui-AI本地部署踩坑记录的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!