jianchang512 / ChatTTS-ui

一个简单的本地网页界面,使用ChatTTS将文字合成为语音,同时支持对外提供API接口。A simple native web interface that uses ChatTTS to synthesize text into speech, along with support for external API interfaces.
https://pyvideotrans.com
Other
5.19k stars 570 forks source link

windows版本如何设置使用GPU? #13

Open finger24 opened 1 month ago

finger24 commented 1 month ago

windows版本如何设置使用GPU或是用CPU。 我这里打开后默认使用CPU[捂脸],是不是对GPU型号和参数有要求?我的显卡是笔记本Quadro P620

jianchang512 commented 1 month ago

不太清楚这个型号

需要英伟达显卡,并且按照 cuda toolkit 11.8+

yangbin8 commented 1 month ago

下载的windows预打包版,速度好慢啊,gpu占用也很少,请问怎么解决

jianchang512 commented 1 month ago

需要安装cuda toolkit11.8+版本,并且是英伟达显卡

yangbin8 commented 1 month ago

需要安装cuda toolkit11.8+版本,并且是英伟达显卡

我电脑已经安装了cuda_12.2版本

yangbin8 commented 1 month ago

我的显卡是 3060 12G,生成过程中显存占用3GB,显卡负载不超过30%,很慢

qq827435393 commented 1 month ago

解决了吗? 我这边也是cpu在跑,我是4070ti cuda_12.1

Cassianvale commented 1 month ago

我的显卡是RTX 3090,已有驱动如下: NVIDIA-SMI 555.85
Driver Version: 555.85
CUDA Version: 12.5(CUDA最高支持版本)

我已经尝试了两种版本的安装方式: Cuda Toolkit 11.8 pip install nvidia-cublas-cu11 nvidia-cudnn-cu11

Cuda Toolkit12.5 pip install nvidia-cublas-cu12 nvidia-cudnn-cu12

两种方法都无法检测到gpu

Cassianvale commented 1 month ago

找到解决方法了,因为项目默认安装的是cpu版本的torch,解决方法如下:

pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118 替换成 pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu121

然后我报错了RuntimeError: Windows not yet supported for torch.compile,需要在chat.load_models的参数中加入compile=False

Cassianvale commented 1 month ago

或者直接按照我的 python 3.10 的 requirements.txt 版本安装

Flask~=3.0.3
ipython~=8.25.0
modelscope~=1.14.0
numpy==1.26.4
omegaconf~=2.3.0
python-dotenv~=1.0.1
requests~=2.32.3
soundfile~=0.12.1
tokenizers~=0.19.1
transformers~=4.41.2
vector-quantize-pytorch~=1.14.24
vocos~=0.1.0
waitress~=3.0.0
torch~=2.1.2+cu121
torchaudio~=2.1.2+cu121
torchvision~=0.16.2+cu121
tqdm~=4.66.4
einops~=0.8.0
jianchang512 commented 1 month ago

仓库页面有说明啊,源码部署必须安装cuda版本的torch

spritenee commented 1 month ago

windows 预打包版怎么都是占用100%的CPU,GPU一点不用!怎么办呢?

jianchang512 commented 1 month ago
  1. 升级英伟达显卡驱动
  2. 安装CUDA 11.8+
spritenee commented 1 month ago

这两项工作都做了,我再部署版试一下

jianchang512 commented 1 month ago

如果源码部署

pip uninstall -y torch torchaudio

pip install torch==2.1.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118

spritenee commented 1 month ago

源码部署后成功运行了web ui,但生成时还是100的CPU,GPU没占用。于是改了 # 通过将 .env中 compile设为false,禁用推理优化. 其他为启用。一定情况下通过禁用,能提高GPU效率 chat.load_models(source="local",local_path=CHATTTS_DIR, compile=False if os.getenv('compile','true').lower()!='false' else False) 为compile=True 然后python app.py就提示: Traceback (most recent call last): File "D:\Program Files\chattts\chatTTS-ui\app.py", line 13, in <module> import soundfile as sf ModuleNotFoundError: No module named 'soundfile' 不管是否改回False都这样了

jianchang512 commented 1 month ago

pip install soundfile

spritenee commented 1 month ago

感谢及时回复! 应该是requirements中的依赖没有下载或被删除?反正一个个补回来,碰到dotenv模块时提示:


Collecting dotenv
  Using cached dotenv-0.0.5.tar.gz (2.4 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install backend dependencies did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Collecting distribute
        Using cached distribute-0.7.3.zip (145 kB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Installing backend dependencies: started
        Installing backend dependencies: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        Preparing metadata (pyproject.toml) did not run successfully.
        exit code: 1

        [6 lines of output]
        usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
           or: setup.py --help [cmd1 cmd2 ...]
           or: setup.py --help-commands
           or: setup.py cmd --help

        error: invalid command 'dist_info'
        [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed

      Encountered error while generating package metadata.

      See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install backend dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.```
帮忙看看怎么解决?不是使用pip install命令?
jianchang512 commented 1 month ago

pip install -r requirements.txt

spritenee commented 1 month ago

谢谢,不过很奇怪,之前运行过这个命令而且正常运行的。可以正常运行,但还是 use cpu image

jianchang512 commented 1 month ago

估计你搞错了虚拟环境

spritenee commented 1 month ago

按这个步骤来的: image

spritenee commented 1 month ago

之前的Windows预打包版也是这个效果,不使用GPU。对了,最新版的文件夹跟原来不一样了,需要多进一层,原来的文件夹名也找不到了

spritenee commented 1 month ago

可以了,先感谢jianchang512大神的及时耐心帮助!

  1. 最新版本的文件和文件夹已经同教程不一致了,原理大体相同,注意更改
  2. 我纠结的问题主要在于未使用GPU、未使用cuda。其实安装什么的都没问题,最终在于显卡有些老(N卡4G显存,符合要求的底限)。在chattts-ui\chattts文件夹下有个core.py文件,里面device = select_device(4096),这个4096要大于我这块N卡的4G显存(4095.75),所以不符合要求、不调用。只要改成4095或更小的数值就可以,马上调用GPU生成!
51fe commented 6 hours ago

貌似目前不支持 windows + zluda