resume会报错,已解决
DuZzzs opened this issue · comments
commit: e86bae4, resume报错如下:
File "/monodle/tools/train_val.py", line 87, in <module>
main()
File "/monodle/tools/train_val.py", line 75, in main
trainer.train()
File "/monodle/lib/helpers/trainer_helper.py", line 72, in train
self.train_one_epoch()
File "/monodle/lib/helpers/trainer_helper.py", line 106, in train_one_epoch
self.optimizer.step()
File "/env/miniconda3/envs/monodle/lib/python3.6/site-packages/torch/optim/adam.py", line 93, in step
exp_avg.mul_(beta1).add_(1 - beta1, grad)
RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float
Exception ignored in: <bound method tqdm.__del__ of <tqdm.std.tqdm object at 0x7f904072d780>>
解决办法:
# self.epoch = load_checkpoint(model=self.model,
self.epoch = load_checkpoint(model=self.model.to(self.device),
optimizer=self.optimizer,
filename=cfg['resume_model'],
map_location=self.device,
logger=self.logger)
Thanks! I will update it.