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

Fixing Errors: RuntimeError and ModuleNotFoundError #96

Open
doammii opened this issue Oct 29, 2024 · 0 comments
Open

Fixing Errors: RuntimeError and ModuleNotFoundError #96

doammii opened this issue Oct 29, 2024 · 0 comments

Comments

@doammii
Copy link

doammii commented Oct 29, 2024

I referred to the link below to fine-tune the Tortoise model with GPT-2.
During training, I encountered two errors and found ways to fix them.

Error 1) ModuleNotFoundError: No module named 'torch._six'

Traceback (most recent call last):
File "C:\Users\oldgu\DL-Art-School\codes\train.py", line 12, in
from data.data_sampler import DistIterSampler
File "C:\Users\oldgu\DL-Art-School\codes\data_init_.py", line 6, in
from utils.util import opt_get
File "C:\Users\oldgu\DL-Art-School\codes\utils\util.py", line 25, in
from torch._six import inf
ModuleNotFoundError: No module named 'torch._six'

Solution
: In line 25 of /content/DL-Art-School/codes/utils/util.py

  • from torch._six import inf => from torch import inf

Error 2) RuntimeError: Error(s) in loading state_dict for UnifiedVoice

Traceback (most recent call last):
  File "/content/DL-Art-School/codes/train.py", line 398, in <module>
    trainer.init(args.opt, opt, args.launcher)
  File "/content/DL-Art-School/codes/train.py", line 146, in init
    self.model = ExtensibleTrainer(opt)
  File "/content/DL-Art-School/codes/trainer/ExtensibleTrainer.py", line 192, in __init__
    self.load()  # load networks from save states as needed
  File "/content/DL-Art-School/codes/trainer/ExtensibleTrainer.py", line 539, in load
    self.load_network(load_path, net, self.opt['path']['strict_load'], opt_get(self.opt, ['path', f'pretrain_base_path_{name}']))
  File "/content/DL-Art-School/codes/trainer/base_model.py", line 131, in load_network
    network.load_state_dict(load_net_clean, strict=strict)
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 2152, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for UnifiedVoice:
	Unexpected key(s) in state_dict: "gpt.h.0.attn.bias", "gpt.h.0.attn.masked_bias", "gpt.h.1.attn.bias", "gpt.h.1.attn.masked_bias"

Solution
: In line 131 of /content/DL-Art-School/codes/trainer/base_model.py

  • network.load_state_dict(load_net_clean, strict=strict) => network.load_state_dict(load_net_clean, strict=False)
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

1 participant