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

NameError: name 'trainer' is not defined #343

Open
liuyangyu2003 opened this issue Feb 5, 2024 · 4 comments
Open

NameError: name 'trainer' is not defined #343

liuyangyu2003 opened this issue Feb 5, 2024 · 4 comments

Comments

@liuyangyu2003
Copy link

Traceback (most recent call last):
File "/root/autodl-tmp/LDM/main.py", line 535, in
model = instantiate_from_config(config.model)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 353, in getattr
self._format_and_raise(
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/base.py", line 190, in _format_and_raise
format_and_raise(
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/_utils.py", line 821, in format_and_raise
_raise(ex, cause)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/_utils.py", line 719, in _raise
raise ex.with_traceback(sys.exc_info()[2]) # set end OC_CAUSE=1 for full backtrace
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 351, in getattr
return self._get_impl(key=key, default_value=DEFAULT_MARKER)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 438, in _get_impl
node = self._get_node(key=key, throw_on_missing_key=True)
File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 470, in _get_node
raise ConfigKeyError(f"Missing key {key}")
omegaconf.errors.ConfigAttributeError: Missing key model
full_key: model
object_type=dict

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/autodl-tmp/LDM/main.py", line 740, in
if trainer.global_rank == 0:
NameError: name 'trainer' is not defined
how can I sovle this problem?

@railgun122
Copy link

Did you try with pytorch lightning==1.6.1? The problem arised for me when my pytorch lightning is 1.7.0 and above

@BaselOmari
Copy link

The actual issue isn't with trainer being undefined, it's in the try block that precedes it. Remove all the code in the try block out of it, and rerun the code to see what the caught error is.

For me it was FileNotFoundError: [Errno 2] No such file or directory: 'configs/first_stage_models/vq-f4/model.yaml' which I fixed with this: #87 (comment)

@liuyangyu2003
Copy link
Author

Did you try with pytorch lightning==1.6.1? The problem arised for me when my pytorch lightning is 1.7.0 and above

my pytorch_lightning==1.4.2,and I try with pytorch lightning==1.6.1 ,however it didn't work

@molongIT
Copy link

How fix it? It confuse me a lot.

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

5 participants
@BaselOmari @molongIT @railgun122 @liuyangyu2003 and others