Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

训练T5Copy出现AttributeError #61

Open
lyh124 opened this issue Mar 30, 2023 · 1 comment
Open

训练T5Copy出现AttributeError #61

lyh124 opened this issue Mar 30, 2023 · 1 comment

Comments

@lyh124
Copy link

lyh124 commented Mar 30, 2023

错误情况如下:

Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.309 seconds.
Prefix dict has been built successfully.
You are using a model of type mt5 to instantiate a model of type t5. This is not supported for all configurations of models and can yield errors.
The tokenizer class you load from this checkpoint is not the same type as the class this function is called from. It may result in unexpected tokenization. 
The tokenizer class you load from this checkpoint is 'T5Tokenizer'. 
The class this function is called from is 'JieBaTokenizer'.
Global seed set to 12
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
Global seed set to 12
initializing ddp: GLOBAL_RANK: 0, MEMBER: 1/1
----------------------------------------------------------------------------------------------------
distributed_backend=nccl
All DDP processes registered. Starting ddp with 1 processes
----------------------------------------------------------------------------------------------------

LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]

  | Name  | Type   | Params
---------------------------------
0 | model | T5Copy | 275 M 
---------------------------------
275 M     Trainable params
0         Non-trainable params
275 M     Total params
1,100.123 Total estimated model params size (MB)
Validation sanity check: 0it [00:00, ?it/s]/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/data_loading.py:105: UserWarning: The dataloader, val dataloader 0, does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` (try 16 which is the number of cpus on this machine) in the `DataLoader` init to improve performance.
  rank_zero_warn(
Validation sanity check:   0%|                                                                                                                                      | 0/2 [00:00<?, ?it/s]Traceback (most recent call last):
  File "train.py", line 29, in <module>
    trainer.fit(model, train_data, dev_data)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 552, in fit
    self._run(model)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 922, in _run
    self._dispatch()
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 990, in _dispatch
    self.accelerator.start_training(self)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 92, in start_training
    self.training_type_plugin.start_training(trainer)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 161, in start_training
    self._results = trainer.run_stage()
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1000, in run_stage
    return self._run_train()
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1035, in _run_train
    self._run_sanity_check(self.lightning_module)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1122, in _run_sanity_check
    self._evaluation_loop.run()
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/loops/base.py", line 111, in run
    self.advance(*args, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 110, in advance
    dl_outputs = self.epoch_loop.run(
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/loops/base.py", line 111, in run
    self.advance(*args, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 111, in advance
    output = self.evaluation_step(batch, batch_idx, dataloader_idx)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 158, in evaluation_step
    output = self.trainer.accelerator.validation_step(step_kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 211, in validation_step
    return self.training_type_plugin.validation_step(*step_kwargs.values())
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/ddp.py", line 392, in validation_step
    return self.model(*args, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/fairscale/nn/data_parallel/sharded_ddp.py", line 230, in forward
    return self.module(*inputs, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/pytorch_lightning/overrides/base.py", line 93, in forward
    output = self.module.validation_step(*inputs, **kwargs)
  File "/home/admin0/Longyuhui/t5-pegasus-pytorch/models.py", line 113, in validation_step
    pred = self.predict_batch(batch)
  File "/home/admin0/Longyuhui/t5-pegasus-pytorch/models.py", line 96, in predict_batch
    pred = self.model.generate(**model_kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/transformers/generation_utils.py", line 907, in generate
    model_kwargs = self._prepare_encoder_decoder_kwargs_for_generation(input_ids, model_kwargs)
  File "/home/admin0/Longyuhui/t5-pegasus-pytorch/models.py", line 1276, in _prepare_encoder_decoder_kwargs_for_generation
    model_input_name = model_input_name if model_input_name is not None else self.main_input_name
  File "/home/admin0/anaconda3/envs/t5/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1265, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'T5Copy' object has no attribute 'main_input_name'
@renmada
Copy link
Owner

renmada commented Apr 3, 2023

试试最新版的transformers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants