Open shailesh837 opened 6 months ago
Seems related to this issue. https://github.com/intel/intel-extension-for-pytorch/issues/317
@gc-fu Can we solve this issue in conda env?
The issue https://github.com/intel/intel-extension-for-pytorch/issues/317 was caused by self-built torch with pre-built intel-extension-for-pytorch.
I have tried install these two dependencies in conda and then import intel_extension_for_pytorch as ipex
. Everything works fine.
Can you try these through conda?
Hi @shailesh837
Can you share your OS and kernel version? This error is raised by intel-extension-for-pytorch. In most cases, it's caused by OS or glibc out of date.
I have ubuntu 22.04 LTS and Linux imu-nex-nuc13x2-arc770-dut 6.5.0-26-generic .
@gc-fu : Did you managed to run the code : import torch from TTS.api import TTS from ipex_llm import optimize_model
device = 'xpu' # Use 'xpu' to indicate Intel GPU
print(TTS().list_models())
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
tts = optimize_model(tts, cpu_embedding=True) tts = tts.to(device)
wav = tts.tts(text="Hello world!", speaker_wav="./audio.wav", language="en").to('cpu') # Move output to CPU if needed tts.tts_to_file(text="Hello world!", speaker_wav="./audio.wav", language="en", file_path="output.wav")
After some investigation, the issue was caused not installing the correct torchaudio version. Install using these instructions:
pip install TTS
pip install --pre --upgrade ipex-llm[xpu] --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
# Then pip install torchaudio
pip install torchaudio==2.1.0a0 --extra-index-url
https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
The code results: The unknown symbol issue should have been addressed.
The error here should be caused by the fact that ipex-llm not supporting TTS models for now.
I have managed to run the below TTS code on XPU, but it takes 23 seconds , seriously, it takes 3 second on CPU : Please can we check what issue on XPU: `(tts) spandey2@imu-nex-nuc13x2-arc770-dut:~/tts$ cat andrej_code_tts.py
import os
import torch import intel_extension_for_pytorch as ipex print(torch.version) print(ipex.version) [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())]
from TTS.utils.manage import ModelManager from TTS.utils.synthesizer import Synthesizer
import numpy as np import soundfile as sf
model_manager = ModelManager() model_path, config_path, model_item = model_manager.download_model("tts_models/en/vctk/vits") synthesizer = Synthesizer(model_path, config_path, use_cuda=False)
synthesizer.tts_model.to('xpu') synthesizer.tts_model.eval() # Set the model to evaluation mode for inference synthesizer.tts_model = ipex.optimize(synthesizer.tts_model, dtype=torch.float32)
speaker_manager = synthesizer.tts_model.speaker_manager speaker_names = list(speaker_manager.name_to_id.keys()) print("Available speaker names:", speaker_names)
speaker_name = "p229" # Replace with the actual speaker name you want to use
text = "Your last lap time was 117.547 seconds. That's a bit slower than your best, but you're still doing well. Keep pushing, a really good lap is around 100 seconds. You've got this, let's keep improving."
with torch.no_grad(), torch.xpu.amp.autocast(enabled=False): wavs = synthesizer.tts(text, speaker_name=speaker_name)
if isinstance(wavs, list):
tensor_list = [torch.tensor(wav, dtype=torch.float32).unsqueeze(0) if np.isscalar(wav) else torch.tensor(wav, dtype=torch.float32) for wav in wavs]
# Concatenate the tensor list into a single tensor
wav_concatenated = torch.cat(tensor_list, dim=0)
else:
wav_concatenated = wavs
wav_concatenated = wav_concatenated.cpu().numpy()
output_path = "output_vctk_vits.wav" sf.write(output_path, wav_concatenated, synthesizer.tts_config.audio['sample_rate']) `
The code you provided is using ipex, not ipex-llm. Please do check again.
The intel-extension-for-pytorch repo address is here: https://github.com/intel/intel-extension-for-pytorch
Your related code snippet:
import intel_extension_for_pytorch as ipex
synthesizer.tts_model = ipex.optimize(synthesizer.tts_model, dtype=torch.float32)
I am trying to run Synthesizing speech by TTS:
https://docs.coqui.ai/en/latest/
(llm) spandey2@imu-nex-sprx92-max1-sut:~/1worldsync_finetuning$ cat tts.py
ENV Set: source /opt/intel/oneapi/setvars.sh export LD_PRELOAD=${LD_PRELOAD}:${CONDA_PREFIX}/lib/libtcmalloc.so export SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 export SYCL_CACHE_PERSISTENT=1 export ENABLE_SDP_FUSION=1
Error :