AlexandaJerry / whisper-vits-japanese

Vits Japanese with Whisper as data processor (you can train your VITS even you only have audios)
MIT License
158 stars 28 forks source link

IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1) #12

Open bachelorwang opened 1 year ago

bachelorwang commented 1 year ago

您好,我按照教學一步步執行單人訓練的步驟,在最後要進行訓練時遇到了以下錯誤:

IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/mnt/d/work/whisper-vits-japanese/env/lib/python3.9/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "/mnt/d/work/whisper-vits-japanese/env/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 54, in fetch
    return self.collate_fn(data)
  File "/mnt/d/work/whisper-vits-japanese/data_utils.py", line 121, in __call__
    print([x[1].size(1) for x in batch])
  File "/mnt/d/work/whisper-vits-japanese/data_utils.py", line 121, in <listcomp>
    print([x[1].size(1) for x in batch])
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

我再三確認過與教學中的步驟,實在是想不出原因,我的執行環境是在本機,Cuda版本為11.8,使用python 3.9,pytorch版本是2.0.0

以下是我的pip package版本清單

absl-py==1.4.0
attrs==22.2.0
audioread==3.0.0
Babel==2.12.1
cachetools==5.3.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
clldutils==3.19.0
cmake==3.26.1
colorama==0.4.6
colorlog==6.7.0
csvw==3.1.3
cycler==0.11.0
Cython==0.29.21
decorator==5.1.1
ffmpeg-python==0.2.0
filelock==3.10.7
future==0.18.3
google-auth==2.17.1
google-auth-oauthlib==1.0.0
grpcio==1.53.0
idna==3.4
importlib-metadata==6.1.0
isodate==0.6.1
Jinja2==3.1.2
joblib==1.2.0
jsonschema==4.17.3
kiwisolver==1.4.4
language-tags==1.2.0
librosa==0.8.0
lit==16.0.0
llvmlite==0.39.1
lxml==4.9.2
Markdown==3.4.3
MarkupSafe==2.1.2
matplotlib==3.3.1
more-itertools==9.1.0
mpmath==1.3.0
networkx==3.0
numba==0.56.4
numpy==1.23.1
nvidia-cublas-cu11==11.10.3.66
nvidia-cuda-cupti-cu11==11.7.101
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99
nvidia-cudnn-cu11==8.5.0.96
nvidia-cufft-cu11==10.9.0.58
nvidia-curand-cu11==10.2.10.91
nvidia-cusolver-cu11==11.4.0.1
nvidia-cusparse-cu11==11.7.4.91
nvidia-nccl-cu11==2.14.3
nvidia-nvtx-cu11==11.7.91
oauthlib==3.2.2
openai-whisper @ git+https://github.com/openai/whisper.git@b5851c6c40e753606765ac45b85b298e3ae9e00d
packaging==23.0
pandas==2.0.0
phonemizer==2.2.1
Pillow==9.5.0
platformdirs==3.2.0
pooch==1.7.0
protobuf==4.22.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pydub==0.25.1
pylatexenc==2.10
pyopenjtalk==0.2.0
pyparsing==3.0.9
pyrsistent==0.19.3
python-dateutil==2.8.2
pytz==2023.3
rdflib==6.3.2
regex==2023.3.23
requests==2.28.2
requests-oauthlib==1.3.1
resampy==0.4.2
rfc3986==1.5.0
rsa==4.9
scikit-learn==1.2.2
scipy==1.5.2
segments==2.2.1
six==1.16.0
soundfile==0.12.1
sympy==1.11.1
tabulate==0.9.0
tensorboard==2.12.1
tensorboard-data-server==0.7.0
tensorboard-plugin-wit==1.8.1
threadpoolctl==3.1.0
tiktoken==0.3.1
torch==2.0.0
tqdm==4.65.0
triton==2.0.0
typing_extensions==4.5.0
tzdata==2023.3
Unidecode==1.1.1
uritemplate==4.1.1
urllib3==1.26.15
Werkzeug==2.2.3
zipp==3.15.0

因為pandas還有pytorch的問題,我有對程式碼進行幾束修改:

  1. torch.stft 會擲出runtime error提示return_complex沒有設定為True,因此修改

    spec = torch.stft(y, n_fft, hop_length=hop_size, win_length=win_size, window=hann_window[wnsize_dtype_device],
                      center=center, pad_mode='reflect', normalized=False, onesided=True, return_complex=True)
  2. pandas.DataFrameappend已經被刪除,因此改為使用concat

    data = pd.concat([data, df], ignore_index=True, sort=False)

不知道是不是有什麼地方出錯了,懇請指教

bachelorwang commented 1 year ago

請問是必須在stft寫

spec = torch.view_as_real(spec)

Raincarnator commented 1 year ago

显然,这个问题来自于 pip 自动安装了最新版本的 torch 2.0.0 (因为在本仓库中,requirements.txt 中并没有指定 torch 版本,由于 2.0.0 版本的发布而出现了问题)。

虽然我不知道如何在最新版本的 torch 上解决问题,但如果你只是希望正常运行,那么我推荐你将 torch 版本退回到 <=1.19.1即可,例如 1.12.1。 你可以在运行 train.py 前添加这一代码块:

!pip install torch==1.12.1

经过我的测试,该版本的 torch 可以正常运行。

bachelorwang commented 1 year ago

感謝協助,第一次接觸深度學習的東西 發現python在解決套件衝突上真的是滿頭大的

AlexandaJerry commented 1 year ago

显然,这个问题来自于 pip 自动安装了最新版本的 torch 2.0.0 (因为在本仓库中,requirements.txt 中并没有指定 torch 版本,由于 2.0.0 版本的发布而出现了问题)。

虽然我不知道如何在最新版本的 torch 上解决问题,但如果你只是希望正常运行,那么我推荐你将 torch 版本退回到 <=1.19.1即可,例如 1.12.1。 你可以在运行 train.py 前添加这一代码块:

!pip install torch==1.12.1

经过我的测试,该版本的 torch 可以正常运行。

非常感谢反馈!PR已经合并,欢迎成为本项目的第二名contributor! @Mitr-yuzr