tortoise-tts icon indicating copy to clipboard operation
tortoise-tts copied to clipboard

Guide: How to install on windows for GPU

Open windowpane opened this issue 1 year ago • 7 comments

Hey,

I spent the last 10 hours trying to install tortoise-tts on windows 10 with CUDA GPU support, and finally got it working. I thought I would share my instructions to help others in case anyone else gets stuck.

  1. Create environment.yml file:

    name: tortoise
    channels:
      - conda-forge
    dependencies:
      - python=3.8
      - charset-normalizer
      - pip
      - pillow
    
  2. Create a new requirements.txt named requirements.new.txt. the old one requirements.txt has some issues.

    tqdm
    rotary_embedding_torch
    transformers==4.19
    tokenizers
    inflect
    progressbar
    einops==0.4.1
    unidecode
    scipy==1.10.1
    librosa==0.9.1
    numba
    ffmpeg
    numpy
    threadpoolctl
    llvmlite
    appdirs
    soundfile
    
  3. Then run the following:

    • create a local conda environment in the ./env folder
      conda env create -f environment.yml -p ./env 
      
    • activate the conda environment
      source activate ./env
      # if this doesn't work, use: "conda activate ./env"
      
    • Install torch and cuda
      conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
      
    • Install the requirements.new.txt file
      python -m pip install -r  requirements.new.txt
      
    • Run the setup.py file, which is necessary in order for some of the tortoise imports to run.
      python setup.py install
      

    Alternatively, you can try doing this in one shot:

    conda env create -f environment.yml -p ./env \
        && source activate ./env
        && conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia -y
        && python -m pip install -r requirements.new.txt
        && python setup.py install
    
  4. you can test if it worked using the following:

# test cuda is working. should print true that gpu is available. 
python -c "import torch; print(torch.cuda.is_available());torch.zeros(1).cuda()"

# test tortoise:
python tortoise/do_tts.py --text "I'm going to speak this" --voice random --preset fast

Hopefully this helps.

windowpane avatar May 14 '23 19:05 windowpane

Thanks for posting. It worked for me. I agree that it would be very helpful to this as part of a readme.

mehanig avatar May 15 '23 21:05 mehanig

I have a Win11 64bit setup using Anaconda Navigator 2.4.0.

Reproducing the steps above work fine, until # test tortoise: python tortoise/do_tts.py --text "I'm going to speak this" --voice random --preset fast is executed.

Then I get the following: UserWarning: torchaudio C++ extension is not available. warnings.warn('torchaudio C++ extension is not available.') Traceback (most recent call last): File "tortoise/do_tts.py", line 7, in <module> from api import TextToSpeech, MODELS_DIR File "C:\xxx\yyy\tortoise-tts\tortoise\api.py", line 13, in <module> from tortoise.models.diffusion_decoder import DiffusionTts File "C:\xxx\yyy\env\lib\site-packages\tortoise-2.4.2-py3.8.egg\tortoise\models\diffusion_decoder.py", line 8, in <module> from torch import autocast ImportError: cannot import name 'autocast' from 'torch' (C:\xxx\yyy\env\lib\site-packages\torch\__init__.py)

Looking for a solution to torchaudio C++ extension is not available. tells me, that this extension is not available on Windows.

Any ideas here? Thank you!

mindster-at avatar May 16 '23 14:05 mindster-at

Any ideas here? Thank you!

I used this line to install pytorch and torch audio. It's probably will be specific to your version of CUDA installed, but for me it works for all of the places where pytorch and cuda is required

pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118

I also have win11 and Anaconda, so I think torchaudio is available, but just not installed correctly

mehanig avatar May 16 '23 14:05 mehanig

you can also try rerunning the torchaudio installation:

conda activate ./env
conda install torchaudio -c pytorch -c nvidia

Otherwise, you might need to have visual studio community edition installed to get the c++ compilers.

windowpane avatar May 16 '23 15:05 windowpane

That did the trick! Thank you!

mindster-at avatar May 19 '23 08:05 mindster-at

What Python version did you use when creating the conda environment? Can you use multiple GPUs, e.g. GPU0 and GPU1 ?

jameswan avatar May 29 '23 11:05 jameswan

what if you have Cuda 12.0 ?

naseemshanbour avatar May 31 '23 04:05 naseemshanbour

CUDA 12 is not supported by PyTorch You should uninstall CUDA12

jameswan avatar Jul 09 '23 01:07 jameswan

For 40xx cards, you have to use CUDA18

Use this instead.

conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

IgorCulafic avatar Jul 20 '23 09:07 IgorCulafic

You might want to use the mrq repo. It has directml support

fakerybakery avatar Oct 18 '23 23:10 fakerybakery