Bootstrap

处理报错deepspeed使用trainer object.__init__() takes exactly one argument (the instance to initialize)

项目场景:

在kaggle上结合deepspeed使用trainer


问题描述

报错

TypeError: object.init() takes exactly one argument (the instance to initialize)
具体如下:

File /opt/conda/lib/python3.10/site-packages/transformers/training_args.py:1934, in TrainingArguments.__post_init__(self)
   1930 from transformers.integrations.deepspeed import HfTrainerDeepSpeedConfig
   1932 # will be used later by the Trainer
   1933 # note: leave self.deepspeed unmodified in case a user relies on it not to be modified)
-> 1934 self.hf_deepspeed_config = HfTrainerDeepSpeedConfig(self.deepspeed)
   1935 self.hf_deepspeed_config.trainer_config_process(self)
   1937 # Accelerate DeepSpeed Plugin

File /opt/conda/lib/python3.10/site-packages/transformers/integrations/deepspeed.py:90, in HfTrainerDeepSpeedConfig.__init__(self, config_file_or_dict)
     89 def __init__(self, config_file_or_dict):
---> 90     super().__init__(config_file_or_dict)
     91     self._dtype = None
     92     self.mismatches = []

File /opt/conda/lib/python3.10/site-packages/transformers/integrations/deepspeed.py:80, in HfDeepSpeedConfig.__init__(self, config_file_or_dict)
     78 dep_version_check("accelerate")
     79 dep_version_check("deepspeed")
---> 80 super().__init__(config_file_or_dict)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

解决方案:版本不同导致

更新到最新版本即可

!pip install -q --upgrade transformers deepspeed
;