Closed woyijkl1 closed 3 years ago
使用GPU同样报错
you need delete the parameter of verbose
. Then it will be ok.
ok I have fixed it! thanks
我使用CPU训练,删除了verbose之后,仍然报如下错误: torch.nn.modules.module.ModuleAttributeError: 'SoftMaskedBertModel' object has no attribute 'device'
我的torch版本是 1.6.0+cu101,python是3.6
win10系统,使用CPU训练,使用的库版本和requirements.txt要求的完全一致 1、训练SoftMaskedBertModel会报错torch.nn.modules.module.ModuleAttributeError: 'SoftMaskedBertModel' object has no attribute 'device' 2、训练train_bert4csc.yml和train_macbert4csc.yml就可以
更新一下torch
发件人: wshzd @.> 发送时间: 2021年9月27日 17:32 收件人: gitabtion/BertBasedCorrectionModels @.> 抄送: Subscribed @.***> 主题: Re: [gitabtion/BertBasedCorrectionModels] 使用cpu训练报错 (#16)
我使用CPU训练,删除了verbose之后,仍然报如下错误: torch.nn.modules.module.ModuleAttributeError: 'SoftMaskedBertModel' object has no attribute 'device'
我的torch版本是 1.6.0+cu101,python是3.6
― You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/gitabtion/BertBasedCorrectionModels/issues/16#issuecomment-927693496, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEYR4SB3CC5TWVAAE2GHBCTUEA23TANCNFSM5DAGXEOA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
使用config文件如下: MODEL: BERT_CKPT: "bert-base-chinese" DEVICE: "cpu" NAME: "SoftMaskedBertModel"
[loss_coefficient]
HYPER_PARAMS: [0.8]
DATASETS: TRAIN: "datasets/csc/train.json" VALID: "datasets/csc/dev.json" TEST: "datasets/csc/test.json"
SOLVER: BASE_LR: 0.0001 WEIGHT_DECAY: 5e-8 BATCH_SIZE: 32 MAX_EPOCHS: 10 ACCUMULATE_GRAD_BATCHES: 4
TEST: BATCH_SIZE: 16
TASK: NAME: "csc"
OUTPUT_DIR: "checkpoints/SoftMaskedBert"
运行命令: python tools/train_csc.py --config_file csc/train_SoftMaskedBert.yml
报错: /Users//opt/anaconda3/envs/sc/lib/python3.6/site-packages/pytorch_lightning/utilities/distributed.py:49: UserWarning: Checkpoint directory /Users///Documents/personal/BertBasedCorrectionModels/checkpoints/SoftMaskedBert exists and is not empty. warnings.warn(*args, kwargs) GPU available: False, used: False TPU available: None, using: 0 TPU cores Traceback (most recent call last): File "tools/train_csc.py", line 52, in
main()
File "tools/train_csc.py", line 48, in main
train(cfg, model, loaders, ckpt_callback)
File "/Users/ //Documents/personal/BertBasedCorrectionModels/tools/bases.py", line 78, in train
trainer.fit(model, train_loader, valid_loader)
File "/Users//opt/anaconda3/envs/sc/lib/python3.6/site-packages/pytorch_lightning/trainer/trainer.py", line 454, in fit
self.accelerator_backend.setup(model)
File "/Users///opt/anaconda3/envs/sc/lib/python3.6/site-packages/pytorch_lightning/accelerators/cpu_accelerator.py", line 49, in setup
self.setup_optimizers(model)
File "/Users///opt/anaconda3/envs/sc/lib/python3.6/site-packages/pytorch_lightning/accelerators/accelerator.py", line 145, in setup_optimizers
optimizers, lr_schedulers, optimizer_frequencies = self.trainer.init_optimizers(model)
File "/Users///opt/anaconda3/envs/sc/lib/python3.6/site-packages/pytorch_lightning/trainer/optimizers.py", line 30, in init_optimizers
optim_conf = model.configure_optimizers()
File "/Users///Documents/personal/BertBasedCorrectionModels/bbcm/engine/bases.py", line 21, in configure_optimizers
scheduler = build_lr_scheduler(self.cfg, optimizer)
File "/Users///Documents/personal/BertBasedCorrectionModels/bbcm/solver/build.py", line 49, in build_lr_scheduler
scheduler = getattr(lr_scheduler, cfg.SOLVER.SCHED)(scheduler_args)
File "/Users///Documents/personal/BertBasedCorrectionModels/bbcm/solver/lr_scheduler.py", line 73, in init
super().init(optimizer, last_epoch, verbose)
TypeError: init() takes from 2 to 3 positional arguments but 4 were given