GPT-SoVITS icon indicating copy to clipboard operation
GPT-SoVITS copied to clipboard

GPT训练:NameError: name 'trainer' is not defined

Open m-leave opened this issue 1 year ago • 3 comments

之前试过两次,训练都挺正常的,然后中途删了项目,重新git clone了一个最新版的,到了GPT训练这一步,总是报错。在s1_train.py的140行左右

    try:
        # 使用正则表达式匹配文件名中的数字部分,并按数字大小进行排序
        newest_ckpt_name = get_newest_ckpt(os.listdir(ckpt_dir))
        ckpt_path = ckpt_dir / newest_ckpt_name
    except Exception:
        ckpt_path = None
    print("ckpt_path:", ckpt_path)
    trainer.fit(model, data_module, ckpt_path=ckpt_path)

尝试过在trainer.fit()方法之前打印trainer,model,data_module,都能够打印出来,说明应该是定义了的,但是这个trainer接下来就总是报错,问各位大佬,是哪里的低级操作错误 我没有意识到吗

m-leave avatar Feb 07 '24 09:02 m-leave

看看报错截图

RVC-Boss avatar Feb 07 '24 15:02 RVC-Boss

"/Users/mao/miniconda3/envs/GPTSoVits/bin/python" GPT_SoVITS/s1_train.py --config_file "/Users/mao/Downloads/pyproject/GPT-SoVITS/TEMP/tmp_s1.yaml" Seed set to 1234 Using 16bit Automatic Mixed Precision (AMP) /Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/torch/cuda/amp/grad_scaler.py:126: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling. warnings.warn( GPU available: True (mps), used: True TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs <All keys matched successfully> ckpt_path: None semantic_data_len: 15 phoneme_data_len: 15 item_name semantic_audio 0 guodegang-full.MP3_0000005760_0000283200.wav 536 486 41 185 656 965 965 965 774 565 623 298... 1 guodegang-full.MP3_0000594240_0000851520.wav 208 103 216 232 305 604 142 462 551 369 572 26... 2 guodegang-full.MP3_0001112640_0001374080.wav 208 365 232 257 366 641 123 964 854 5 500 5 96... 3 guodegang-full.MP3_0001669120_0001929920.wav 921 519 939 840 208 884 406 237 42 989 680 626... 4 guodegang-full.MP3_0002185280_0002443840.wav 208 318 656 797 328 998 998 40 312 917 776 531... 5 guodegang-full.MP3_0002793920_0003050560.wav 208 965 318 656 965 837 758 687 933 422 606 54... 6 guodegang-full.MP3_0003352000_0003617280.wav 208 318 947 698 424 1018 662 846 846 846 329 6... 7 guodegang-full.MP3_0003933120_0004135040.wav 76 2 834 205 549 820 900 8 17 918 42 672 942 2... 8 guodegang-full.MP3_0000292480_0000594240.wav 837 208 837 160 787 1016 402 1017 795 555 808 ... 9 guodegang-full.MP3_0000851520_0001100160.wav 208 103 656 774 837 434 183 123 949 320 469 93... 10 guodegang-full.MP3_0001374080_0001669120.wav 214 844 14 851 439 794 777 356 777 400 569 420... 11 guodegang-full.MP3_0001929920_0002185280.wav 3 942 45 559 253 229 629 827 216 437 765 841 8... 12 guodegang-full.MP3_0002449280_0002792320.wav 208 837 837 612 582 921 657 106 409 590 341 92... 13 guodegang-full.MP3_0003050560_0003342400.wav 208 103 208 1005 837 1005 103 656 194 982 654 ... 14 guodegang-full.MP3_0003617280_0003933120.wav 1005 248 132 592 592 592 785 211 392 19 723 75... dataset.len(): 90

| Name | Type | Params

0 | model | Text2SemanticDecoder | 77.5 M

77.5 M Trainable params 0 Non-trainable params 77.5 M Total params 309.975 Total estimated model params size (MB) Traceback (most recent call last): File "/Users/mao/Downloads/pyproject/GPT-SoVITS/GPT_SoVITS/s1_train.py", line 170, in main(args) File "/Users/mao/Downloads/pyproject/GPT-SoVITS/GPT_SoVITS/s1_train.py", line 146, in main trainer.fit(model, data_module, ckpt_path=ckpt_path) File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 544, in fit call._call_and_handle_interrupt( File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py", line 44, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 580, in _fit_impl self._run(model, ckpt_path=ckpt_path) File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 989, in _run results = self._run_stage() File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1035, in _run_stage self.fit_loop.run() File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/loops/fit_loop.py", line 194, in run self.setup_data() File "/Users/mao/miniconda3/envs/GPTSoVits/lib/python3.9/site-packages/pytorch_lightning/loops/fit_loop.py", line 215, in setup_data pl_module = trainer.lightning_module NameError: name 'trainer' is not defined gpt-error1 gpt-error2 gpt-error3

m-leave avatar Feb 08 '24 01:02 m-leave

最后报错的trainer不是s1_train里的trainer,感觉是pytorch-lightning这个库的问题,建议重新安装

ISDHN avatar Feb 10 '24 01:02 ISDHN